Re: System Events & Key Code
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?
|
_______________________________________________
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