Posts

Post not yet marked as solved
0 Replies
110 Views
I would like to be able to get either the key code or the characters/text from an NSEvent/KeyEvent. Absolutely no idea how to do this as the documentation I have found so far has been very limited. I believe I need to create an instance of NSEvent but I do not know how. My script is below. I am working on a speedrun macro for Minecraft. This script is fully functioning as is, but currently all it does is check if the control key has been pressed via checking the modifier flags of NSEvent. use framework "AppKit" use scripting additions global ca set ca to current application # you may change the following variables global seed set seed to "8398967436125155523" # do not change anything below this line to isModifierPressed(modifier) ((ca's NSEvent's modifierFlags()) / modifier as integer) mod 2 is equal to 1 end isModifierPressed repeat if isModifierPressed(ca's NSEventModifierFlagControl) then execute() delay 0.01 end repeat on execute() tell application "System Events" delay 0.1 keystroke tab delay 0.02 keystroke return delay 0.02 repeat 3 times keystroke tab delay 0.02 end repeat keystroke return delay 0.02 repeat 2 times keystroke tab delay 0.02 end repeat repeat 3 times keystroke return delay 0.02 end repeat repeat 4 times keystroke tab delay 0.02 end repeat keystroke return delay 0.02 repeat 3 times keystroke tab delay 0.02 end repeat keystroke seed delay 0.02 repeat 6 times keystroke tab delay 0.02 end repeat keystroke return end tell end execute
Posted Last updated
.