System API

class autokey.scripting.System[source]

Simplified access to some system commands.

static create_file(file_name, contents='')[source]

Create a file with contents

Usage: system.create_file(fileName, contents="")

Parameters:
  • fileName – full path to the file to be created

  • contents – contents to insert into the file

static exec_command(command, getOutput=True)[source]

Execute a shell command

Usage: system.exec_command(command, getOutput=True)

Set getOutput to False if the command does not exit and return immediately. Otherwise AutoKey will not respond to any hotkeys/abbreviations etc until the process started by the command exits.

Parameters:
  • command – command to be executed (including any arguments) - e.g. “ls -l”

  • getOutput – whether to capture the (stdout) output of the command

Raises:

subprocess.CalledProcessError – if the command returns a non-zero exit code