I created a script in windows in AutoHotKey for the game Minecraft. Basically what it did was take server commands and turned them into keyboard shortcuts. e.g. Alt + B displayed Enter Player Name: silent input while user typed name then it typed into the chat /ban *playername {enter}. And like that the player was banned. One of the server admins I wrote the script for asked if I could write an OSX verions of the script for him. Since there is not AHK for OSX I started with Applescript. Thus far I can get things to work great, when it doesn’t require user input but I need to use a third party app to monitor the keyboard for hotkeys (spark).
Player hits Alt + E, Result:
Spark Fires up corresponding applescript
tell application "system events" to keystroke "t"
delay .25
tell application "system events" to keystroke "/cuboid air"
delay .25
tell application "system events" to keystroke return
That part works like a charm. Now when I try with Alt+B for ban the dialog prompt appears behind the game. Is there a way to just type and after return is hit to continue with the script? Is there a way to monitor the keyboard from within applescript for the hotkeys? Like a loop and if key is pressed do?