Re: JustWonedering
Re: JustWonedering
- Subject: Re: JustWonedering
- From: Shane Stanley <email@hidden>
- Date: Fri, 18 Sep 2009 18:39:13 +1000
- Thread-topic: JustWonedering
On 18/9/09 6:19 PM, "Ronald Hofmann" <email@hidden> wrote:
> Very interesting, and how are you doing it?
> Can you give us an example?
>
> Greetings, Ronald
> ---
>
> Am 18.09.2009 um 01:23 schrieb Shane Stanley:
>
>> On 18/9/09 8:58 AM, "email@hidden" <email@hidden> wrote:
>>
>>> I believe that was from Jon's Commands
>>
>> And it's probably worth noting that stuff like this is relatively
>> simple
>> using AppleScriptObjC, if you really need it in an app.
This thread seems to be jumping between lists, so excuse the cross-post. It
started out about looking to see if a modifier key was pressed...
I set up a property for NSEvent class at the top level of the script, for
convenience:
property eventClass : class "NSEvent"
Then I do the equivalent of calling NSEvent's modifierFlags method, which
returns a (large) number. From that I can work out what modifier keys are
down.
So this handler will cover the main ones:
on getModifiers_(sender)
set theMods to {false, false, false, false, false, false} -- Fn,
Cmd, Opt, Ctrl, Shift, Caps Lock
set theNum to ((eventClass's modifierFlags()) div 65536)
if theNum > 127 then
set item 1 of theMods to true
end if
--set theNum to theNum mod 32
if theNum mod 32 > 15 then
set item 2 of theMods to true
end if
-- set theNum to theNum mod 16
if theNum mod 16 > 7 then
set item 3 of theMods to true
end if
-- set theNum to theNum mod 8
if theNum mod 8 > 3 then
set item 4 of theMods to true
end if
-- set theNum to theNum mod 4
if theNum mod 4 > 1 then
set item 5 of theMods to true
end if
-- set theNum to theNum mod 2
if theNum mod 2 = 1 then set item 6 of theMods to true
return theMods
end getModifiers_
If you're only interested in a particular modifier, it becomes a lot simpler
obviously.
--
Shane Stanley <email@hidden>
AppleScript Pro, April 2010, Florida <http://www.applescriptpro.com>
_______________________________________________
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