Hello
To insert my signature at the ned of my messages, I use a script. In its "old" state, it was keystroking the signature. Alas, in French August is spelled "août" and keystroking it inserts "aogt" which is annoying.
So I edited the script so that it paste the signature.
At this time, the code is
--{code} on run my germaine() end run
on germaine()
set testSay to true tell application "System Events" -- get frontmost process set frontmostProcess to first process where it is frontmost -- this will be the script process if name of frontmostProcess is in {"Script Editor", "AppleScript Editor"} then set visible of frontmostProcess to false -- hide the script process repeat while (frontmostProcess is frontmost) -- wait until the script is hidden delay 0.2 end repeat set theApp to name of first process where it is frontmost -- get name of frontmost process (ignoring the script process) set frontmost of frontmostProcess to true -- unhide the script process else set theApp to name of frontmostProcess end if end tell set theDate to current date
set leMessage to "Yvan KOENIG running Yosemite 10.10.4 in French (VALLAURIS, France) " & date string of theDate & space & time string of theDate
set oldClipBoard to the clipboard as record # save it to reset it on exit
tell application theApp activate # changes nothing set the clipboard to leMessage if testSay then set inTheClipBoard to the clipboard as text end tell --delay 0.2 # changes nothing tell application "System Events" to tell process theApp set frontmost to true keystroke "v" using {command down} end tell --end tell set the clipboard to oldClipBoard # reset the original content
if testSay then say inTheClipBoard end germaine
--===== --{code}
I'm really puzzled. When I run it from the Script Editor, with TextEdit as target application, it works well.
When I run it from the Script Editor, with Mail as target application, orexecute it from the Script menu or trigger it thru Fastscripts, it pastes the original clipboard content BUT when testSay is set to true, it says my signature (leMessage)
Am I doing something wrong ? Is it the normal behavior ? Is it any chance that using ASObjC to fill the pasteboard will give what I want ?
Yvan KOENIG running Yosemite 10.10.4 in French (VALLAURIS, France) dimanche 2 août 2015 18:06:32
To insert the signature above, I ran the script from the editor with TextEdit as target then copied from TextEdit and pasted here, awful isn't it ?
|