• Stars
    star
    576
  • Rank 74,855 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created about 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Desktop Automation Framework. Drive your mouse and keyboard with an easy to use language.

self-driving-desktop

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

pip3 install self-driving-desktop

Running

Playing a playlist:

sdd playlist.txt

Recording a playlist:

sdd --record recording.txt

Playlists

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

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

# 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 screen size
screen "1080p";

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

Install from local repository:

git clone https://github.com/hofstadter-io/self-driving-desktop
pip3 install ./self-driving-desktop/

More Repositories

1

hof

Framework that joins data models, schemas, code generation, and a task engine. Language and technology agnostic.
Go
482
star
2

frisby

API testing framework inspired by frisby-js
Go
277
star
3

cuetorials.com

Learn you some CUE for a great good!
CUE
113
star
4

cuetils

CLI and library for diff, patch, and ETL operations on CUE, JSON, and Yaml
Go
78
star
5

jumpfiles

get more done with fewer keystrokes
CUE
57
star
6

cuelm

Experiments with CUE on the quest to reimagine devops-ops.
CUE
32
star
7

hofmod-cli

Hofstadter generator for Golang CLIs
Go
25
star
8

cue-examples

Random examples demonstrating cuelang
20
star
9

harmony

Easily test downstream projects before releasing new code
CUE
14
star
10

harmony-cue

Harmony setup for testing CUE based projects
CUE
12
star
11

ghacue

GitHub Actions schema in CUE
CUE
10
star
12

c8s

Cuelang powered Kubernetes package manager
Go
8
star
13

hofmod-server

A hof generator for Golang servers
Go
7
star
14

mvs

A flexible Minimum Version Selection tool and library based on Go mods (MERGED into HOF, please see that project, all commands are the same)
Go
6
star
15

structural

Moved into hof, see this link ->
Go
4
star
16

flow-examples

Examples for hof/flow CUE powered DAG engine
CUE
4
star
17

cinful

Detect if your code is running in CI
Go
3
star
18

hofmod-struct

DSL for generating structs in various languages
Go
3
star
19

_awesome

Awesome List for and by Hofstadter
3
star
20

demos

demos of the hof cli
Go
2
star
21

data-utils

Common utilities for data (json,yaml,xml,toml) handling (io,type-inference,merge,patch,diff)
Go
2
star
22

homebrew-tap

Homebrew Tap for Hofstadter installables
Ruby
1
star
23

connector-js

JavaScript implementation of the 'connectors' concept. Dynamically merge, filter, and connect your project modules at build, init, or runtime.
JavaScript
1
star
24

kubeplex-server

Backend Go server for Kubeplex
Go
1
star
25

_mrtk

Docs, Tutorials, and Code Samples for the Mixed Reality Toolkit
1
star
26

hofmod-x

Experimental, reusable schemas, datamodels, generators, and flows
1
star
27

hofmod-cuefig

Application configuration using Cue
Go
1
star
28

_saas

An open source toolset for SaaS operations.
Makefile
1
star
29

flows

A collection of reusable and example `hof/flows` by and for the community
1
star
30

hof-starter-app

Starter application for Hofstadter Studios
TypeScript
1
star
31

cue.vim

Vim syntax plugin for Cuelang
Vim Script
1
star
32

old-hof

Replacement coming soon, stay tuned!
Go
1
star
33

hof-docs

Moved to the hof repo
CUE
1
star
34

supacode

Hof generator for a full-stack app, built on NextJS
CUE
1
star