I try the use the following AppleScript in the “New Item” tab to copy a selected text with Hook:
set theSelectedText to ""
set savedClipboard to the clipboard
-- Copy selected text to clipboard:
set thePasteboard to current application's NSPasteboard's generalPasteboard()
set theCount to thePasteboard's changeCount()
-- Copy selected text to clipboard:
tell application "System Events" to keystroke "c" using {command down}
-- Check for changed clipboard:
repeat 20 times
if thePasteboard's changeCount() is not theCount then exit repeat
delay 0.1
end repeat
set theSelectedText to the clipboard
-- Restore clipboard:
set the clipboard to savedClipboard
It seems that Hook is the frontmost app so no selected text is there to copy. Any ideas how to solve this?