• 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: Sending Key Commands?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending Key Commands?


  • Subject: Re: Sending Key Commands?
  • From: Bill Cheeseman <email@hidden>
  • Date: Sat, 11 Oct 2014 10:41:13 -0400

Use the System Events application, which has 'keystroke' and 'key code' commands in its Processes Suite. For example, to create a new folder on the desktop:

activate application "Finder"
tell application "System Events"
keystroke "n" using {shift down, command down}
end tell

I don't think of this as being part of what we call "GUI Scripting" because it is not necessary to have a nested block inside the tell block to 'tell process "Finder"' to send the keystroke. Instead, System Events sends the keystroke to the active application. That's why the script activates the Finder first.


On Oct 11, 2014, at 10:11 AM, Alex Hall <email@hidden> wrote:

I know AS can send key commands, but I can't seem to find documentation on it. I just want to script a short series of commands I use all the time in Xcode:

cmd-ctrl-option-f5
cmd-ctrl-option-shift-space
ctrl-option-shift-f3

My Mac is set to require the function key for using the F keys to control things like volume or brightness, so I don't need to simulate it's pressing in this sequence. Oh, I may also add ctrl-option-arrows at some point. Thanks for any suggestions.

-- 

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

  • Follow-Ups:
    • Re: Sending Key Commands?
      • From: Alex Hall <email@hidden>
References: 
 >Sending Key Commands? (From: Alex Hall <email@hidden>)

  • Prev by Date: Sending Key Commands?
  • Next by Date: Re: Sending Key Commands?
  • Previous by thread: Sending Key Commands?
  • Next by thread: Re: Sending Key Commands?
  • Index(es):
    • Date
    • Thread