Hi. I’m a Windows guy and have a large GUI / Macro interface written for the Windows language autohotkey. Basically it is a GUI that is toggled with CAPS and contains 9 tabs of 15 buttons. Whenever a button a pressed, specific function / macros run.
Currently AHK does all of this but now I’m rewriting the GUI itself in Python in hopes of making it cross platform (and take advantage of python’s more flexible GUI libraries). The windows version will use a port of AHK that is autohotkey.dll to integrate with python. The Mac version I was HOPING would do something similar using applescript.
I wonder a few things:
is Applescript the best equivalent to AutoHotkey? The commands I use the most are things like winwaitactive, control clicking buttons, control check/uncheck, control set text, control choose (combo box), winmenuselectitem, controlfocus, control choose string, lot’s of keyboard sends… etc. Are all/most of these things possible in AppleScript in some form? Is there a better language on mac geared for this? In the end I could do it all with keyboard sends and winwaitactives, but it’s not ideal.
Can AppleScript integrate with Python? ahk.dll allows ahk to run inside of python on the same process which makes things much faster than simply running separate individual files (in win, ahk or exe) everytime a button is pressed as a new process must begin.
But it is possible with Pashua. It’s a simple application that can provide a GUI for languages that don’t have GUI capabilities. You can drive it with both AppleScript and Python, and a handful of others. And you already know Python, yes?
I’m familiar with Python and have used it sparingly in the past. Just to clarify: did you mean those type of automation commands (winwaitactive, wingetmenuitem, etc. etc.) are NOT possible with AppleScript? Or was the “no” a response to the integration with Python (which Pashua would make it possible, though) and those automation commands ARE possible?
I understood you want to translate a Windows GUI to Mac. That’s not possible with AppleScript; the only user interaction it has are display dialog, display alert, and recently display notification.
The only ‘elements’ available are one textfield, and buttons.
See the A/S dictionary for Standard Additions: in the Editor, open the Library palette (cmd-shft-L), and double-click Standard Additions.
Because you want it to be cross platform I would definitely take a look at REALBasic, because for Mac OS X it supports AppleEvents which means it can do the same as AppleScript and more. AppleScript relies on AppleEvents but uses an nicer syntax by using a dictionary that translates nice looking English syntax into AppleEvents.
All these things can be done using AppleEvents (implicitly AppleScript too)
Your last question would be integrating Python with REALBasic, no you can’t but AppleScript can’t be intergrated with Python either. The best you can do is opening a shell, run python on the command line and grab it’s output (if needed).
Ok. So what might be a decent idea of using Python/AHK.dll in Windows will absolutely not work in OS X: not even reusing python code to simply make the GUI will not work/integrate with the automation language. Ok.
The best ideas are to either use 1. Pashua to make a GUI for A/S or REALBasic (which is now Xojo…?) to design the entire thing? I’m not immediately sure how Xojo would work doing the Windows automation. Maybe it’s actually good. It might make more sense to simply keep two different programs. Hmmm…
I would have a look at Shane Stanley’s Dialog Toolkit library file.
To keep a decent number of UI elements I would create 9 popups with 16 menu items : a blank one and 15 corresponding to your buttons.
Selecting a “no-blank” menu item would launch the wanted command.
From my point of view it would be neater than 9 * 15 buttons.
Yvan KOENIG (VALLAURIS, France) jeudi 23 avril 2015 16:57:37
After considering the design of this entire thing, I’ve figured out that I can get around most things with what in AHK is WinMenuSelectItem. Simply selecting like File – > Save or Edit – > Undo. Or a specific case… “Plug-ins → JWTools → JW Accidentals” for example.
Is there one simple way of doing this in AppleScript?
The would toggle between two programs. There’s a lot of ways I’d do that differently though with different circumstances, but basically, does anything close to that exist in AppleScript or a similar language?