I'm new to Hammerspoon, but interested in automating some macOS workflows with it.
Many examples seem to directly access functions provided by a target application itself - but how does one find out which functions are provided and how they have to be used?
Thanks in advance for any help!
since I may have found an answer myself (or s.th. which comes close to it) let me summarize it here:
One possible approach may be to exploit the built-in macOS "Script Editor" (to be found in folder "Applications" > "Utilities").
Just open the "Script Editor" and - from the menu - choose "Window" > "Library". This will give you a list of automatable applications. Double-clicking on any of these applications will give you a documented list of methods and properties that application provides.
By default, the documentation will use AppleScript syntax - it may be useful to switch to JavaScript using the dropdown just below the window's title bar instead.
Right now, I have no idea if the list (of applications and/or provided properties and methods) is complete or not.
Additionally, you will need a little bit of "fantasy" to map AppleScript/JavaScript definitions to Lua...
I found this recipe in an "DevOps Zone" article
An alternative seems to be the "Script Debugger" from "Late Night Software" - the free "Lite" version seems to be sufficient.
From the menu, simply choose "File" > "Open Dictionary" for an (already open) application of your choice. The "Preview Dictionary" window will then show you a list of all properties and methods provided - and the "Explorer" tab will allow you to inspect them.