Wie kann ich 1 zurückgeben, wenn fngedrückt wird, und sonst 0?
Ich habe diese Seite gefunden, die behauptet, dass sie eine Lösung hat, aber sie stützt sich auf eine externe Shell-Skriptdatei (ich hätte lieber eine reine AppleScript-Lösung, wenn das möglich ist), die ich nicht herunterladen kann, weil sie mich durch einige seltsame niederländische Betrugsseiten umleitet.
Das Ziel ist eigentlich, eine Möglichkeit zu haben, in ControllerMate nach Kombinationen aus Funktionstaste + Fn-Taste zu suchen, die anscheinend keine Möglichkeit haben, zu prüfen, ob Fn gedrückt ist oder nicht.
Direkt aus der Post von Oscar ...
property vers : "1.0"
my isModifierKeyPressed("function") // the only addition to his raw script
on isModifierKeyPressed(checkKey)
set modiferKeysDOWN to {command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:false}
if checkKey = "" or checkKey = "option" or checkKey = "alt" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlternateKeyMask '") > 1 then
set option_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "command" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSCommandKeyMask '") > 1 then
set command_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "shift" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSShiftKeyMask '") > 1 then
set shift_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "control" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSControlKeyMask '") > 1 then
set control_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "caps" or checkKey = "capslock" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSAlphaShiftKeyMask '") > 1 then
set caps_down of modiferKeysDOWN to true
end if
end if
if checkKey = "" or checkKey = "numlock" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSNumericPadKeyMask'") > 1 then
set numlock_down of modiferKeysDOWN to true
end if
end if
--Set if any key in the numeric keypad is pressed. The numeric keypad is generally on the right side of the keyboard. This is also set if any of the arrow keys are pressed
if checkKey = "" or checkKey = "function" or checkKey = "func" or checkKey = "fn" then
if (do shell script "/usr/bin/python -c 'import Cocoa; print Cocoa.NSEvent.modifierFlags() & Cocoa.NSFunctionKeyMask'") > 1 then
set function_down of modiferKeysDOWN to true
end if
end if
--Set if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys)
return modiferKeysDOWN
end isModifierKeyPressed
wenn Fn unten ist
Result:
{command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:true}
anders
Result:
{command_down:false, option_down:false, control_down:false, shift_down:false, caps_down:false, numlock_down:false, function_down:false}
theonlygusti
Ken Jones