vncdotool - VNC bot

最後更新: 2019-06-25

HomePage

https://github.com/sibson/vncdotool/

 


Install

 

# 在 virtualenv 安裝 vncdotool

pip install virtualenv

virtualenv venv-vncdotool

source venv-vncdotool/bin/activate

# download requirements.txt from vncdotool source tree

requirements-2.6.txt

# requirements known to work with python2.6
Pillow==2.6.1
Twisted==14.0.2
wsgiref==0.1.2
zope.interface==4.1.1

pip install -r requirements-2.6.txt

pip install vncdotool

# 測試

vncdo --version

vncdo 0.12.1

 


Basic Usage

 

# -s SERVER              # Format ADDRESS[:DISPLAY|::PORT]

# -p PASSWORD

i.e.

vncdo -s 192.168.88.150::5921  capture screen.png

vncdo key enter

vncdo -s vncserveraddress type "hello world"

一 cmd 多 action

move 500 100 click 1 type "ping 192.168.88.1" key enter

特別 key

enter, esc, shift-a, ctrl-c, ctrl-alt-del, super-r

 


Capture screen

 

# capture full screen

vncdo -s $server::$port capture tmp.png

# capture a region of the screen

vncdo -s $server::$port rcapture FILE X Y W H

Example

compare_full_screen.sh

function compare_full_screen(){
while true
    do
        vncdo -s $server::$port capture tmp.png
        r=`compare -metric PSNR $1 tmp.png /dev/null 2>&1`
        i=${r%.*}
        echo $i
        if (( $i > 20 )); then
            echo "SAME"
            break
        fi
        sleep 5
    done
}

compare_full_screen myscreen.png

 


delay 與 pause

 

--delay=MILLISECONDS  # delay MILLISECONDS between action [Default: 10ms]

 

vncdo --delay=2000 -s $server::$port type c type m type d

pause SECONDS              #wait SECONDS before sending next command

vncdo -s $server::$port key super-r pause 2
vncdo -s $server::$port key delete

 


Macro

 

Win7 set network zone

# start cmd.exe
vncdo -s $server::$port key super-r type cmd key enter

# set zone
vncdo -s $server::$port type "control.exe /name Microsoft.NetworkAndSharingCenter" key enter pause 2
vncdo -s $server::$port key tab key tab key tab key tab key tab key tab key enter pause 2
vncdo -s $server::$port key up key space key enter

 


Doc

 

https://vncdotool.readthedocs.io/