python开发安卓app优缺点
2005
2022-10-26
一个电脑桌面自动化操作框架
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 filesimport "test/main.txt";# Create Coordinatescoords { "center": { "1080p": [960, 540], "720p": [640, 360] }};# Create a playlistplaylist "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 squareplaylist "repeatTest" { mm 100 100 1; mm 1000 100 1; mm 1000 500 1; mm 100 500 1;};# Our main playlistplaylist "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 sizescreen "1080p";# Set the global delay between stepsdelay 0.025;# Finally, play our main playlistplay "main";
Grammar
Top-level:
file has steps and playlistssteps are the only thing runplay runs a playlist
# relative imports from fileimport "relative/path.txt";# named coordinatescoords { # coord name "center": { # screen identifier "1080p": [960, 540], "720p": [640, 360] }};# define playlistsplaylist "my-playlist" { steps...;};playlist "main" { steps...; # run playlists from playlists play "my-playlist"}# set the screen identifierscreen "1080p";# run a playlistplay "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 secondssleep x.y;: sleep for x.y secondsscreen "screen";: set the screen resolution identifiershell "quoted strings"+;: exec a command from the program
windows:
active "someName";: name the active windowfocus "someName";: focus a named window
mouse:
mouse x y s;: move the mouse to x,y in s secondscoord "name" s;: move the mouse to a named coordinate in s secondscoord "name" x y s;: move to a named coordinate with offset in s secondsclick;: click the left mouse buttonbtnclick [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 secondsscroll n;: scroll n lines, negative is uphscroll n;: horizontal scroll n "clicks", negative is left
keyboard:
keypress "key";keydown "key";keyup "key";hotkeys "quoted" "keys" ...;: press some keys togetherwrite "quoted string\n";: type a string, "\n" is enter
clipboard:
copy;, just ctrl-cpaste;, just ctrl-vsave_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 penvsource penv/bin/activatepip install -r requirements.txtexport PYTHONPATH=.python self_driving_desktop/__main__.py ...
Install from local repository:
git clone https://github.com/hofstadter-io/self-driving-desktoppip3 install ./self-driving-desktop/
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。