【问题标题】:pyautogui "move" and "press" function does not run for some unknown reasonpyautogui“移动”和“按下”功能由于某种未知原因无法运行
【发布时间】:2021-12-31 16:33:31
【问题描述】:

我正在构建一个从服务器接收命令的客户端。 (一个“TeamViewer”类型的程序) 服务器发送按键事件和鼠标坐标,客户端运行它们。 尽管当前调试正在同一台计算机上运行,​​但我希望在使用 pyautogui.move(x,y)pyautogui.press(char) 时看到一些鼠标移动。没有看到任何移动,也没有发生键盘按下。 exe() 函数在线程上运行并且工作正常(打印坐标工作正常)。

为什么pyautogui.move(x,y)pyautogui.press(char) 工作是这个代码?


def exe():        
        while True:
            if executeQ:
                command = executeQ.get()               
                commandlist = command.split('\n')

                char = commandlist[0]
                x = commandlist[1]           #getting command
                y = commandlist[2]
            
                    
                try:
                    print(f'Typing - {char}')
                    pyautogui.press(char)
                except:
                    pass

                try:
                    print(f'Moving to - {x},{y}')
                    pyautogui.move(x,y)
                except:
                    print("OUT OF BOUNDS / SAME POSOTION")

【问题讨论】:

    标签: python python-3.x pyautogui


    【解决方案1】:

    尝试将xy 转换为整数。

    x = int(commandlist[1])
    y = int(commandlist[2])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多