2

Right now I've got two Autokey scripts (for modularity), one that opens a file, and one that puts text in it.

The one that opens the file has hotkey F1 (and we'll call this script 1 for simplicity), and the one that puts text in it has hotkey F2. I want a new Autokey script, that when I hit F3, it runs both the 1 script and the 2 script.

I've tried making the 3 script just send the F1 and F2 keys, but the timing is all off. It would be better if I could just call 1 and 2 from 3. Is this possible?

Thanks!

Dr-Bracket
  • 1,276
  • 8
  • 18

2 Answers2

4

https://github.com/autokey/autokey/blob/fc7c6b90f3f28a57ad256829ef2b69e3be5148d2/lib/autokey/scripting.py#L1242

engine.run_script("<description>")

ought to do the trick

"Description" in this context is generally the name of the script in the side bar in the AutoKey interface. If you open up the .json file for the script you can see it for sure, but it will be the name displayed in the side bar unless you have duplicate names for scripts in the same folder or some other edge scenario

Icallitvera
  • 167
  • 1
  • 3
  • 13
3

AutoKey is not recursive. It does not inspect the output of an AutoKey phrase or script to look for hotkeys or trigger abbreviations which would invoke further actions. That's why your initial solution does not work.

It depends on what you're actually trying to do.

If you have multiple independently useful scripts, the best approach is the one @Icallitvera offers.

If you just want to modularize shared functionality, you can create Python modules of functions and place them in the AutoKey Modules directory. Then, you can import them into any AutoKey script which needs them.

You can find/set the Modules directory from the AutoKey Main Menu via Settings->Configure AutoKey->Script Engine.

At the moment, this approach is limited because scripts invoked this way do not (easily) have access to the AutoKey API, so they can't include any API calls. We plan to fix this in the next major release, AutoKey 0.96. If you really need to do that now, ask on our support list or on Gitter.

Joe
  • 246
  • 1
  • 14