All the problem was linked to the fact that I wanted to keep the original clipboard unchanged.
If I decide to behave like a pig, I may use :
--{code}
on run my germaine() end run
on germaine()
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.1 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 the clipboard to leMessage
tell application "System Events" to tell process theApp set frontmost to true keystroke "v" using {command down} end tell
end germaine --{/code}
And this dirty one inserts leMessage correctly … but of course, the original clipboard is lost.
Yvan KOENIG running Yosemite 10.10.4 in French (VALLAURIS, France) lundi 3 août 2015 15:02:55
|