46

Self Driving Desktop

 4 years ago
source link: https://www.tuicool.com/articles/hit/MRvymuv
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

self-driving-desktop

Desktop Automation framework

tested on linux/gnome3

python main.py --playlist path/to/file.txt

Development Setup

virtualenv --python python3 penv
source penv/bin/activate
pip install -r requirements.txt

Playlists

playlist openTerm {
  hotkeys "ctrl" "alt" "t";
  sleep 1.0;

  name_active hofTerm;
  sleep 0.5;

  hotkeys "winleft" "left";
  sleep 1;
};

playlist openChrome {
  shell "google-chrome";
  sleep 2.0;

  name_active hofChrome;
  sleep 0.5;

  hotkeys "winleft" "right";
  sleep 1;
};

playlist focusTest {
  wspace_down;
  sleep 0.2;

  play openTerm openChrome;

  focus hofTerm;
  sleep 0.2;
  write "hof config test\n" 0.05;

  sleep 2;

  focus hofChrome;
  sleep 0.2;
  write "https://docs.hofstadter.io\n" 0.05;

  sleep 2;
  wspace_up;
};

play focusTest;

Grammer

Top-level:

  • file has steps and playlists
  • steps are the only thing run
  • play runs a playlist

Steps:

play name+;
sleep x.y;
mv x y s;
click;
wspace_down;
wspace_up;
hotkeys "quoted" "keys" ...;
write "quoted string\n";
shell "quoted strings"+;
name_active someName;
focus someName;
start: item+

item: step ";" | playlist ";"

playlist : "playlist" WORD playlist_body
playlist_body : "{" (step ";")* "}"

step : play
  | sleep
  | mv
  | wspace_down
  | wspace_up
  | hotkeys
  | write
  | shell
  | name_active
  | focus

play: "play" WORD+

name_active: "name_active" WORD
focus: "focus" WORD

sleep: "sleep" number
mv: "mv" number number number

wspace_down: "wspace_down"
wspace_up: "wspace_up"

hotkeys: "hotkeys" string+
write: "write" string number?
shell: "shell" string+


number: SIGNED_NUMBER
string: ESCAPED_STRING

COMMENT: /#[^\n]*/
WORD: LETTER+

%import common.LETTER
%import common.ESCAPED_STRING
%import common.INT
%import common.SIGNED_NUMBER
%import common.WS

%ignore COMMENT
%ignore WS

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK