x=0
while x==0:
target = pyautogui.locateOnScreen(os.path.expanduser(r'~\Desktop\ bot\references\target.png'),region=(0,0,1024,768),confidence=.7)
time.sleep(0.5)
target2 = pyautogui.locateOnScreen(os.path.expanduser(r'~\Desktop\ bot\references\target2.png'),region=(0,0,1024,768),confidence=.7)
print(target,target2)
if target and target2 is None:
pyautogui.keyDown('W')
elif target or target2 != None:
pyautogui.keyUp("W")
print(target or target2)
target_point = pyautogui.center(target or target2)
targetx, targety = target_point
pyautogui.click(targetx, targety)
x=1
(代码应该用导入的模块重新创建)大家好!我试图为游戏创建一个简单的机器人,它在未检测到目标时向前移动,但在检测到目标时停止移动。为什么这不能让 W 键被按下?奇怪的是,当检测到 target 或 target2.png 时,它会按 W,否则不会?
墨色风雨
相关分类