|
SampleScripts
Sample AutoKey Scripts.
IntroductionThis page contains some very basic script examples to demonstrate the capabilities of AutoKey's scripting service. For specific details on the custom functions available to AutoKey scripts, see the API reference. ScriptsInsert Current Date/TimeThis script uses the simplified system.exec_command() function to execute the Unix date program, get the output, and send it via keyboard output output = system.exec_command("date")
keyboard.send_keys(output)List MenuThis script shows a simple list menu, grabs the chosen option and sends it via keyboard output. choices = ["something", "something else", "a third thing"]
retCode, choice = dialog.list_menu(choices)
if retCode == 0:
keyboard.send_keys("You chose " + choice)X SelectionThis script grabs the current mouse selection, then erases it, and inserts it again as part of a phrase. text = clipboard.get_selection()
keyboard.send_key("<delete>")
keyboard.send_keys("The text %s was here previously" % text)Persistent ValueThis script demonstrates 'remembering' a value in the store between separate invocations of the script. if not store.has_key("runs"):
# Create the value on the first run of the script
store.set_value("runs", 1)
else:
# Otherwise, get the current value and increment it
cur = store.get_value("runs")
store.set_value("runs", cur + 1)
keyboard.send_keys("I've been run %d times!" % store.get_value("runs"))
|
Sign in to add a comment
This may seem obvious once you know, but I haven't seen it mentioned anywhere else. In order to turn a Phrase into a Script, choose Edit > Convert to Script. If you don't do this, Autokey will just paste your script's code instead of running it.
Is it possible to control the mouse?