我是非常新的编程,所以请原谅我,如果这有一个明显的答案,只是让你知道我试图写一个程序,执行钓鱼故障在游戏Terraria。 在我代码的最后一段[主程序]中,我使用了函数gui.右键单击(). 函数本身起作用,但在游戏中不起作用。我还尝试了用鼠标库函数鼠标右键单击()结果是一样的,所以我想这和比赛有关。有人能告诉我为什么会这样吗?如果有办法的话?它真的会帮助我,所以提前谢谢!!!:D哦,如果您知道如何改进我的代码,请直接告诉我。再次感谢。在
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)
更多信息: 我不能用Terraria中的这两个库来模拟任何类型的鼠标点击,但用SpeedAutoClicker程序可以做到(但这并没有真正的帮助)
好吧,我发现了。右键单击只是为了让游戏快速识别。 我必须使用mouseUp()和mouseDown()之类的东西。。。。好吧,这毕竟是一个简单的解决方案!:天
相关问题 更多 >
编程相关推荐