--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/33a867c4-f075-4f16-b142-0f110020ea18n%40googlegroups.com.
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5") to set focused of first UI element of group 1 of splitter group 1 of window 1 whose accessibility description is "cue number" to true
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5") to set focused of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
tell application id "com.figure53.QLab.5" to tell front workspace
set notesFormatRecord to {fontSize:48.0, rgbaColor:{red:1.0, alpha:1.0, blue:0, green:0}, fontName:"Comic Sans MS"} -- Desired formatting for Notes
set dummyCue to cue "text" -- Uses a dummy Text Cue numbered “text”; you could test for one, make it if not and then delete…
activate
set selectedCues to (selected as list)
if (count selectedCues) is 0 then return
-- Prepare Inspector
set inspectorWasOpen to inspector visibility
if not inspectorWasOpen then set inspector visibility to true
set selected to dummyCue
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5") to click (first button of group 1 of splitter group 1 of window 1 whose description contains "Text")
-- Process cues
repeat with eachCue in selectedCues
set selected to dummyCue
set text of dummyCue to notes of eachCue
set text format of dummyCue to notesFormatRecord
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5")
set focused of text area 1 of scroll area 1 of group 1 of splitter group 1 of window 1 to true
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Copy" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
set selected to eachCue
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5")
set focused of text area 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
end repeat
set inspector visibility to inspectorWasOpen
end tell
tell application id "com.figure53.QLab.5" to tell front workspace
set htmlPrefix to "<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/></head><body style=\"color:red;font-size:48px;font-family:'Comic Sans MS'\">" -- Use style tags to set desired formatting for Notes
set htmlSufffix to "</body>"
activate
repeat with eachCue in (selected as list)
do shell script "echo " & quoted form of (htmlPrefix & notes of eachCue & htmlSufffix) & " | textutil -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
set selected to eachCue
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5")
set focused of text area 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
end repeat
end tell
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5") to set focused of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
-- Only works properly when run as a separate process!
-- ###FIXME### This is not guaranteed to handle all possible characters or formatting, but has been tested with <>&"'£€¢¥©®
set userStyle to "color:pink;font-size:42px;font-weight:bold;font-family:'Brush Script MT'" -- Use style object for desired formatting
(* Also see https://www.w3schools.com/jsref/dom_obj_style.asp – this approach could even be scaled up to include span styles *)
-- Declarations
set htmlPrefix to "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body style=\""
set htmlMidfix to "\">"
set htmlSufffix to "</body>"
-- Use UI scripting to paste (yuck!)
try
tell application id "com.figure53.QLab.5" to tell front workspace
-- activate -- ###TESTING### Need this line if testing from Script Editor!
-- my leaveField() -- ###TESTING### This line is useful if testing from Script Editor: make sure any current edits are committed
repeat with eachCue in (selected as list)
set originalNotes to notes of eachCue
set cleanNotes to my searchReplaceText(originalNotes, linefeed, "<br>") -- Deal with linefeeds…
set htmlString to htmlPrefix & userStyle & htmlMidfix & cleanNotes & htmlSufffix
do shell script "echo " & quoted form of htmlString & " | textutil -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
set selected to eachCue
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5")
set focused of text area 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
click menu item "Select All" of menu 1 of menu bar item "Edit" of menu bar 1
click menu item "Paste" of menu 1 of menu bar item "Edit" of menu bar 1
end tell
end repeat
end tell
leaveField()
on error
my displayAlert("UI scripting failed!", "You need to adjust your privacy settings to allow QLab to control your computer…", "critical", {"Cancel", "OK"}, 2, 1)
(* ###FIXME### Broken in Ventura 13.1
tell application "System Settings"
activate
reveal anchor "Privacy_Assistive" of pane id "com.apple.preference.security"
end tell
*)
return
end try
-- Subroutines
(* === ERROR HANDLING === *)
on displayAlert(theWarning, theMessage, theIcon, theButtons, defaultButton, cancelButton) -- [Shared subroutine]
tell application id "com.figure53.QLab.5"
if cancelButton is "" then
if theIcon is "critical" then -- Triangle with app icon
display alert theWarning message theMessage as critical buttons theButtons ¬
default button item defaultButton of theButtons
else if theIcon is "informational" then -- App icon
display alert theWarning message theMessage as informational buttons theButtons ¬
default button item defaultButton of theButtons
else if theIcon is "warning" then -- App icon
display alert theWarning message theMessage as warning buttons theButtons ¬
default button item defaultButton of theButtons
end if
else
if theIcon is "critical" then
display alert theWarning message theMessage as critical buttons theButtons ¬
default button item defaultButton of theButtons cancel button item cancelButton of theButtons
else if theIcon is "informational" then
display alert theWarning message theMessage as informational buttons theButtons ¬
default button item defaultButton of theButtons cancel button item cancelButton of theButtons
else if theIcon is "warning" then
display alert theWarning message theMessage as warning buttons theButtons ¬
default button item defaultButton of theButtons cancel button item cancelButton of theButtons
end if
end if
end tell
end displayAlert
(* === TEXT WRANGLING === *)
on searchReplaceText(theText, searchFor, replaceWith) -- [Shared subroutine]
set currentTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to searchFor
set searchedText to text items of theText
set AppleScript's text item delimiters to replaceWith
set replacedText to searchedText as text
set AppleScript's text item delimiters to currentTIDs
return replacedText
end searchReplaceText
(* === QLAB SPECIFIC === *)
on leaveField()
tell application "System Events" to tell (first application process whose bundle identifier is "com.figure53.QLab.5") to set focused of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of splitter group 1 of window 1 to true
end leaveField
--
Contact support anytime: sup...@figure53.com
Follow QLab on Twitter: https://twitter.com/QLabApp
User Group Code of Conduct: https://qlab.app/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/9b212bc9-a5b6-475c-a2a2-ab4f933e1c33n%40googlegroups.com.