所以,我有一个问题,它经常忽略w已经被压制?不管怎么样,我可以让它100%,我假设它的循环,而不听输入?
我试过在整个代码中添加侦听器,但没有添加joy。
t=0
而True:
if(keyboard.is_pressed("q")):
t=0
while t==0 :
if(keyboard.is_pressed("w")):
t=0
break
pyautogui.moveTo(798,717)
pyautogui.moveTo(778,775)
if(keyboard.is_pressed("w")):
t=0
break
pyautogui.click()
pyautogui.moveTo(599,883)
if(keyboard.is_pressed("w")):
t=0
break
pyautogui.click(interval=0.76)
if(keyboard.is_pressed("w")):
print("OK")
t=1
pyautogui.moveTo(900,715)
pyautogui.moveTo(891,776)
if(keyboard.is_pressed("w")):
print("OK")
t=1
pyautogui.moveTo(900,715)
pyautogui.moveTo(891,776)发布于 2022-01-24 00:01:23
问题是鼠标移动阻止代码执行,而is_pressed没有处理。
看起来您正在使用键盘模块,所以您应该使用add_hotkey方法而不是is_pressed。
import time
import keyboard
import pyautogui
def press_ctrl_c():
pyautogui.hotkey('ctrl', 'c')
keyboard.add_hotkey('q', press_ctrl_c)
while True:
try:
# Your code with mouse moves
print('moving mouse')
time.sleep(5)
except KetboardInterrupt:
breakhttps://stackoverflow.com/questions/70827537
复制相似问题