Re: How to Paste into Outlook 2011 using keystorkes/System Events
Re: How to Paste into Outlook 2011 using keystorkes/System Events
- Subject: Re: How to Paste into Outlook 2011 using keystorkes/System Events
- From: Yvan KOENIG <email@hidden>
- Date: Thu, 25 Feb 2016 18:01:51 +0100
Le 2016/02/25 à 17:50, Bill Cheeseman < email@hidden> a écrit :
On Feb 25, 2016, at 11:17 AM, Yvan KOENIG < email@hidden> wrote:
tell application id "com.microsoft.Outlook" activate set myClipboard to the clipboard
set the clipboard to “HELLO WORLD"
tell application "System Events" to tell process "Microsoft Outlook" set frontmost to true keystroke "a" using {command down} keystroke "v" using {command down} end tell
set the clipboard to myClipboard end tell
The curly braces are a good idea. But I have some quibbles:
It is not necessary to enclose the 'keystroke' command in a 'tell process "Microsoft Outlook"' block. The 'keystroke' command automatically goes to the frontmost process.
You don't need to 'tell process "Microsoft Outlook" [to] set frontmost to true' because you already told 'application id "com.microsoft.Outlook" [to] activate'.
It would be nice to move the GUI Scripting block outside of the 'tell application id "com.microsoft.Outlook"' block. Perhaps put it in a subroutine handler, or perhaps just use more 'tell application id "com.microsoft.Outlook"' blocks.
Hello Bill
What you wrote is perfect in theory. It works too when the running system is El Capitan. Alas, under Yosemite - and maybe with older system - activate required a loooong delay to do its duty. It's why I decided to explicitly bring the process to front which was faster than introducing a fixed delay which was done by many users. For my own scripts, I put the GUIScripting code in handlers but here I just wanted to give a quick working answer.
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) jeudi 25 février 2016 18:00:37
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden