为什么我不能在这里模拟右键单击?(使用Python)
我对编程非常陌生,所以如果这有一个明显的答案,请原谅我,让你知道我试图编写一个程序,在游戏Terraria中执行钓鱼故障。 在我的代码[主程序]的最后一部分中,我使用了gui.right click函数。函数本身起作用,但在游戏中不起作用。我还尝试了鼠标库,在那里我使用了mouse.right_单击功能,得到了相同的结果,所以我认为它与游戏有关。有人能告诉我为什么会这样吗?如果有办法的话?这对我真的很有帮助,所以提前谢谢!!!:D哦,如果你知道如何改进我的代码,请直接告诉我。再次感谢为什么我不能在这里模拟右键单击?(使用Python),python,python-3.x,mouseevent,right-click,Python,Python 3.x,Mouseevent,Right Click,我对编程非常陌生,所以如果这有一个明显的答案,请原谅我,让你知道我试图编写一个程序,在游戏Terraria中执行钓鱼故障。 在我的代码[主程序]的最后一部分中,我使用了gui.right click函数。函数本身起作用,但在游戏中不起作用。我还尝试了鼠标库,在那里我使用了mouse.right_单击功能,得到了相同的结果,所以我认为它与游戏有关。有人能告诉我为什么会这样吗?如果有办法的话?这对我真的很有帮助,所以提前谢谢!!!:D哦,如果你知道如何改进我的代码,请直接告诉我。再次感谢 impor
import pyautogui as gui
import keyboard, _thread, sys, time
# Global variable for shutting down the program
shutDown = False
# Position of disposable stuff in the inventory
item_x, item_y = 279, 233
# Function that tells the main thread to shut down
def pClose():
global shutDown
while True:
try:
if keyboard.is_pressed("alt+c"):
shutDown = True
sys.exit()
except:
continue
# Function that checks if it's supposed to shut down the main thread
def pQuit(sD):
if sD == True:
sys.exit()
# Initializing thread with pClose()
_thread.start_new_thread(pClose,())
# Start Position of the Cursor
while True:
try:
if keyboard.is_pressed("alt+p"):
start_x, start_y = gui.position()
break
except:
continue
time.sleep(2)
# Main Program
for i in range(10):
pQuit(shutDown)
gui.press("e")
pQuit(shutDown)
gui.moveTo(item_x, item_y, duration= 0.25)
pQuit(shutDown)
gui.rightClick()
pQuit(shutDown)
gui.moveTo(start_x, start_y, duration= 0.25)
pQuit(shutDown)
gui.rightClick()
pQuit(shutDown)
gui.press("e")
pQuit(shutDown)
time.sleep(0.5)
更多信息:
我无法用Terria中的这两个库模拟任何类型的鼠标点击,但使用SpeedAutoClicker程序确实可以,但这并没有真正的帮助。右击只是为了让游戏快速识别。 我得用鼠标和鼠标镇之类的东西。。。。这毕竟是一个简单的解决方案!:D