美文网首页
vncdotool简单开发指南

vncdotool简单开发指南

作者: Dakini_Wind | 来源:发表于2020-08-15 17:54 被阅读0次

    题外话:
    本来吧,这么个小东西实在是没必要写一篇指南,但官方文档实在是写的烂...啥都没有,尤其在鼠标这...只好自行摸索...

    安装

    重要的话说三遍:
    不要通过pip官方源直接安装!
    不要通过pip官方源直接安装!
    不要通过pip官方源直接安装!

    安装使用如下命令源码编译安装:

    pip install git+https://github.com/sibson/vncdotool.git
    

    使用Demo

    from vncdotool import api
    from .config_handler import config
    from enum import Enum
    import time
    
    button_left = 1
    button_mid = 2
    button_right = 3
    
    
    global client
    
    
    def connect():
        global client
        #注意下面配置改成自己的
        client = api.connect('{}::{}'
                             .format(config.vnc.connect.ip, config.vnc.connect.port),
                             password=str(config.vnc.connect.password))
    
    
    def get_screenshot(path=None):
        client.refreshScreen()
        if path is None:
            path = config.default.states.path + "screen"
        client.captureScreen(path + ".png")
    
    
    def click(click_x, click_y):
        client.mouseMove(click_x, click_y)
        client.mousePress(button_left)
    
    
    def double_click(click_x, click_y):
        client.mouseMove(click_x, click_y)
        client.mousePress(button_left)
        time.sleep(0.1)
        client.mousePress(button_left)
    
    
    def right_click(click_x, click_y):
        client.mouseMove(click_x, click_y)
        client.mousePress(button_right)
    
    
    def input(text):
        for k in text:
            client.keyPress(k)
        client.keyPress('enter')
    
    
    def scroll():
        client.keyPress('pgdn')
        # 用下一页来代替滚动
    
    

    其他注意事项

    相关文章

      网友评论

          本文标题:vncdotool简单开发指南

          本文链接:https://www.haomeiwen.com/subject/ofiadktx.html