【发布时间】:2016-09-19 07:09:02
【问题描述】:
我有一个简单的程序,它执行以下操作: 1)用户将鼠标指向某处, 2)然后用户按空格键, 3) 并且计算机在该点执行一定数量的鼠标左键点击。
该程序运行良好,只有一个问题 - 它占用了 4 核处理器上 30-50% 的处理器时间。问题出在哪里?
import pyautogui
import ctypes
pyautogui.FAILSAFE = True
def get_space_state():
hllDll = ctypes.WinDLL ("User32.dll")
VK_SPACE = 0x20
return hllDll.GetKeyState(VK_SPACE)
while True:
if get_space_state() == -127 or get_space_state() == -128:
print ("yes")
pyautogui.click(clicks=40 , interval=0.01)
非常感谢。
【问题讨论】:
标签: python python-3.x ctypes pyautogui