My favorites | Sign in
Logo
                
Search
for
Updated Oct 20, 2009 by cdek...@gmail.com
Labels: Featured
SampleScripts  
Sample AutoKey Scripts.

Introduction

This 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.

Scripts

Insert Current Date/Time

This 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 Menu

This 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 Selection

This 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 Value

This 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"))

Comment by inductiveload, Oct 01, 2009

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.

Comment by mailryan, Oct 15, 2009

Is it possible to control the mouse?


Sign in to add a comment
Hosted by Google Code