Skip to main content

Desktop Automation Framework. Drive your keyboard and mouse with text files.

Project description

self-driving-desktop

Desktop Automation Framework. Drive your keyboard and mouse with text files.

pip install self-driving-desktop

sdd playlist.txt [--record]

Playlists

# Set screen size
screen "1080p";

# Create Coordinates
coords {
  "center": {
    "1080p": [960, 540],
    "720p":  [640, 360]
  }
};

# Import playlist files
import "test/main.txt";

# Create a playlist
playlist "openChrome" {
  # Run programs in the shell
  shell "google-chrome";
  sleep 2.0;

  # Name the new window
  active "hofChrome";
  sleep 0.5;

  # Use hotkeys to arrange
  hotkeys "winleft" "right";
  sleep 1;
};

playlist "closeChrome" {
  # Focus a named window
  focus "hofChrome";
  hotkeys "alt" "f4";
  sleep 1;
};

playlist "readTheDocs" {
  # Go to a webpage
  focus "hofChrome";
  sleep 0.2;

  # Type the URL
  write "https://docs.hofstadter.io\n" 0.05;

  # Goto an imported coordinate
  coord "getting-started" 0.5;
};

# Move the mouse in a square
playlist "repeatTest" {
  mm 100 100 1;
  mm 1000 100 1;
  mm 1000 500 1;
  mm 100 500 1;
};

# Our main playlist
playlist "main" {
  # Goto a named coordinate, also with offset
  coord "center" 1;
  coord "center" 250 -250 1;

  # Operate the browser
  play "openChrome";
  play "readTheDocs";
  play "closeChrome";

  # Play a playlist multiple times
  play "repeatTest" 4;

};

# Set the global delay between steps
delay 0.025;

# Finally, play our main playlist
play "main";

Grammar

Top-level:

  • file has steps and playlists
  • steps are the only thing run
  • play runs a playlist
# relative imports from file
import "relative/path.txt";

# named coordinates
coords {
  # coord name
  "center": {
    # screen identifier
    "1080p": [960, 540],
    "720p":  [640, 360]
  }
};

# define playlists
playlist "my-playlist" {
  steps...;
};

playlist "main" {
  steps...;
  # run playlists from playlists
  play "my-playlist"
}

# set the screen identifier
screen "1080p";

# run a playlist
play "my-playlist" "main";

Steps:

  • play "name" "nameB" ... [N];: run one or more playlists, optionally repeat N times.
  • delay x.y;: set delay between steps to x.y seconds
  • sleep x.y;: sleep for x.y seconds
  • screen "screen";: set the screen resolution identifier
  • shell "quoted strings"+;: exec a command from the program

windows:

  • active "someName";: name the active window
  • focus "someName";: focus a named window

mouse:

  • mouse x y s;: move the mouse to x,y in s seconds
  • coord "name" s;: move the mouse to a named coordinate in s seconds
  • coord "name" x y s;: move to a named coordinate with offset in s seconds
  • click;: click the left mouse button
  • btnclick [left,middle,right];
  • btndown [left,middle,right];
  • btnup [left,middle,right];
  • drag [left,middle,right] x y s;: drag the mouse to x,y in s seconds
  • scroll n;: scroll n lines, negative is up
  • hscroll n;: horizontal scroll n "clicks", negative is left

keyboard:

  • keypress "key";
  • keydown "key";
  • keyup "key";
  • hotkeys "quoted" "keys" ...;: press some keys together
  • write "quoted string\n";: type a string, "\n" is enter

clipboard:

  • copy;, just ctrl-c
  • paste;, just ctrl-v
  • save_clipboard "name"; save the clipboard contents to "name"
  • load_clipboard "name"; load the clipboard contents from "name"
  • copy_clipboard "name"; copy && save the clipboard contents to "name"
  • paste_clipboard "name"; load the clipboard contents from "name" && paste

all keys are from pyautogui

Grammer Definition

Recording

You can record your mouse and keyboard to a playlist file by:

sdd record.txt --record

Note, not all keys are working yet.

A keymap to fix some is here.

Development Setup

virtualenv --python python3 penv
source penv/bin/activate
pip install -r requirements.txt
export PYTHONPATH=.
python self_driving_desktop/__main__.py ...

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

self-driving-desktop-0.0.7.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

self_driving_desktop-0.0.7-py3.6.egg (15.7 kB view details)

Uploaded Source

File details

Details for the file self-driving-desktop-0.0.7.tar.gz.

File metadata

  • Download URL: self-driving-desktop-0.0.7.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3

File hashes

Hashes for self-driving-desktop-0.0.7.tar.gz
Algorithm Hash digest
SHA256 e493106fadb0911a781a8f57081bd404f64b15a45e2912b83936467abeba6cac
MD5 8a38997b103d8bd6dbe3282bbbd62658
BLAKE2b-256 1eb815bbd5c554ee54b4f0c8c2daaeef715aed7cbdc37ada2483dab81fa938b8

See more details on using hashes here.

File details

Details for the file self_driving_desktop-0.0.7-py3.6.egg.

File metadata

  • Download URL: self_driving_desktop-0.0.7-py3.6.egg
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15rc1

File hashes

Hashes for self_driving_desktop-0.0.7-py3.6.egg
Algorithm Hash digest
SHA256 346f797a388a852a4991a48620f7152ad4630db1d00eae3db016d50e528ffd26
MD5 3c6a37f8d38452b8c700a72205a41bb2
BLAKE2b-256 26cfd37fee9e17a37433dbc75d08dce997619c200d10fec13b44976369eb510d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page