Reputation: 9
I'm very new to programing so please forgive me if this has an obvious answer and just so you know I tried to write a program that performs a fishing glitch in the game Terraria. In the last bit of my code [Main Program] I used the function gui.rightClick(). The function itself works but not in the game. I also tried it with the mouse library where I used the function mouse.right_click() and came to the same result so I figured that it has to do something with the game. Can someone tell me why that is and if there is a way around that? It would really help me so thanks in advance!!! :D Oh and if you know how to improve my code please go right ahead and tell me. Thanks again.
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)
More Info: I can't simulate any kind of mouse click with these two libraries in Terraria but with the program SpeedAutoClicker it does (but that's no really helpful)
Upvotes: 0
Views: 713
Reputation: 9
Okey I found out. The right click is just to fast for the game to recognize. I have to use something like mouseUp() and mouseDown().... Well it was a simple solution after all! :D
Upvotes: 1