Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'If you want to paste the text into the frontmost application…' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
If you want to paste the text into the frontmost application…
Authored by: Stef@nK on Sep 07, '07 07:52:12AM
try this:

try
	set the clipboard to Unicode text of (the clipboard as record)
	tell application "System Events"
		tell process (get 1st process whose frontmost is true)
			keystroke "v" using command down
		end tell
	end tell
on error errMsg
	display dialog errMsg
end try


[ Reply to This | # ]
If you want to paste the text into the frontmost application…
Authored by: mistersquid on Sep 07, '07 10:14:47AM

Did you test the code you proposed?

I've tried my own version of the code you offer as well as your specific code and both do not work.

The failure is due to the fact that the frontmost process ends up being the AppleScript itself! You have to tell System Events to go to the 2nd frontmost process which cannot be done by using "get 2nd process whose frontmost is true".



[ Reply to This | # ]
If you want to paste the text into the frontmost application…
Authored by: Stef@nK on Sep 07, '07 11:28:24AM

Of course I've tested it ;-)
if you start the script from the script menu and not in Script Editor, it should work.



[ Reply to This | # ]