• 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: System Events & Key Code
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: System Events & Key Code


  • Subject: Re: System Events & Key Code
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 16 Sep 2015 10:18:13 +1000

On 16 Sep 2015, at 9:11 AM, Christopher Stone <email@hidden> wrote:

I may be misremembering, but didn't ASCII Number used to get the proper number for key code?

I don't know if it used to, but it sure doesn't now.

I need to convert a-zA-Z to the correct Key Codes to use with key code.

The definitive source is still the Events.h file in Carbon's HIToolbox framework, I gather. These are defined based on keyboard position on an ANSI standard US keyboard (the original ADB extended keyboard, in fact).

I suspect you'll need to build a conversion table because there's no usable pattern to it -- A = 0, S = 1, Z = 6. And you'll need to use a modifier key for uppercase -- these are codes for keys, not letters.

Given that a few milliseconds in neither here nor there in GUI scripting, you could also use this:

set theLetter to "D"
set x to run script "use framework \"Foundation\"" & linefeed & "current application's kVK_ANSI_" & theLetter

Just remember it is US keyboard-dependent.

Any reason you're not using keystroke instead?

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
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: System Events & Key Code
      • From: Christopher Stone <email@hidden>
References: 
 >System Events & Key Code (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Found a chimera
  • Next by Date: Re: Icon size / Button in Display Dialog
  • Previous by thread: System Events & Key Code
  • Next by thread: Re: System Events & Key Code
  • Index(es):
    • Date
    • Thread