• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to Paste into Outlook 2011 using keystorkes/System Events
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to Paste into Outlook 2011 using keystorkes/System Events


  • Subject: Re: How to Paste into Outlook 2011 using keystorkes/System Events
  • From: Dave <email@hidden>
  • Date: Thu, 25 Feb 2016 17:21:33 +0000

Hi,

This is my Script now. It’s actually run using AppleScript-ObjC, so this code is inside an XCode project if that makes any odds.

When I run it from the containing App, the it sets what ever I last put on the Clipboard NOT what is passed in “ theContentString”, I’ve tried a few different variations but can’t seem to get it right.
I’m wonder if I need to “copy” the Clipboard or something.

on setOutlookContent:(theContentString as string)

tell application id "com.microsoft.Outlook"
	activate
	set myClipboard to the clipboard

tell application "System Events" to tell process "Microsoft Outlook"
	set frontmost to true
	set the clipboard to theContentString
	keystroke "a" using {command down}
	keystroke "v" using {command down}
end tell

	set the clipboard to myClipboard
end tell

end setOutlookContent:

If I understand you correctly, you mean the script should look like this:

on setOutlookContent:(theContentString as string)

tell application id "com.microsoft.Outlook"
	activate
	set myClipboard to the clipboard

tell application "System Events"
	set the clipboard to theContentString
	keystroke "a" using {command down}
	keystroke "v" using {command down}
end tell

	set the clipboard to myClipboard
end tell

end setOutlookContent:

on run
	get my setOutlookContent:("HELLO BRAVE NEW CONTENT")
end run

I tried Running the above new version of the script in the Script Editor and it pastes over the Script itself……

Any ideas what couple be wrong?

I wish I could find the original code that I know worked but I think I lost it when I has to re-install 10.10…….

All the Best
Dave


> On 25 Feb 2016, at 16:50, Bill Cheeseman <email@hidden> wrote:
>
>
>> 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.
>
> --
>
> Bill Cheeseman - email@hidden
>
> _______________________________________________
> 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


 _______________________________________________
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


  • Follow-Ups:
    • Re: How to Paste into Outlook 2011 using keystorkes/System Events
      • From: Yvan KOENIG <email@hidden>
    • Re: How to Paste into Outlook 2011 using keystorkes/System Events
      • From: Bill Cheeseman <email@hidden>
References: 
 >Kind Of Annoying Droplet Behavior (From: "S. J. Cunningham" <email@hidden>)
 >How to Paste into Outlook 2011 using keystorkes/System Events (From: Dave <email@hidden>)
 >Re: How to Paste into Outlook 2011 using keystorkes/System Events (From: Yvan KOENIG <email@hidden>)
 >Re: How to Paste into Outlook 2011 using keystorkes/System Events (From: Bill Cheeseman <email@hidden>)

  • Prev by Date: Re: How to Paste into Outlook 2011 using keystorkes/System Events
  • Next by Date: Re: How to Paste into Outlook 2011 using keystorkes/System Events
  • Previous by thread: Re: How to Paste into Outlook 2011 using keystorkes/System Events
  • Next by thread: Re: How to Paste into Outlook 2011 using keystorkes/System Events
  • Index(es):
    • Date
    • Thread