首页 > 解决方案 > Pyautogui.moveTo() 在某些情况下不起作用

问题描述

这是我的代码:

#This program will set the Throttlestop mode to Game, Performance or Cooling as specified.
#It uses the pyautogui and sys module.

import sys
import pyautogui

mode_name = sys.argv[1]

#All necessary postions
taskbar_icon = 1769, 1049
throttlestop = 1770, 900
game = 1800, 785
performance = 1800, 760
cooling = 1800, 910

modes = {'performance':performance, 'game':game, 'cooling':cooling}

if mode_name in modes.keys():
    pyautogui.moveTo(taskbar_icon) #1
    pyautogui.click()

    pyautogui.moveTo(throttlestop) #2
    pyautogui.click(button='right')

    pyautogui.moveTo(modes[mode_name]) #3
    pyautogui.click()

最后两行代码似乎不起作用。其他一切正常。我想从 Win+R 运行它(在创建一个 .bat 文件之后),并且发生与 IDE 中相同的事情。我不明白为什么相同的功能会是情境性的。

标签: pythonpyautogui

解决方案


推荐阅读