Add a delay before the keystroke. Right now the script is executing so
fast that it tries to do the keystroke before you fingers have
released the keys from pressing the trigger. Something like this
should do the job:
(*rest of your script code...*)
set the clipboard to "(" & thePrefix & ")"
delay 0.5
tell application "System Events" to keystroke "v" using {command down}
On Apr 17, 4:20 am, Maksim <[email protected]> wrote:
> Hi all,
>
> I have written a short applescript that will take the name of the
> frontmost pdf and copy it to clipboard and paste while I'm writing
> (see below). When I run the script manually through the QS panes,
> everything works, but a trigger will not work. Would any of you have a
> suggestion as to how to fix this? Does it have something to do with
> the 'command + v' part of the script? (I am currently running ß54 on
> leopard)
>
> Thanks in advance,
>
> M
>
> [applescript]
> tell application "System Events"
> get name of window 1 of application process "Preview"
> set doc_name to result
> end tell
>
> set thePrefix to text 1 thru ((offset of "." in doc_name) - 1) of
> doc_name
>
> set the clipboard to "(" & thePrefix & ")"
>
> tell application "System Events" to keystroke "v" using {command down}
> [/applescript]