Apr-21-2023, 04:12 PM
I am writing a game bot as part of my learning process. The code I am writing requires a single mouse click to be performed at the start of the code block and then move on to the other actions that need to be performed. While I can get the mouse click to occur, the program is continuously sending mouse clicks and will not move on to the next set of instructions.
I have looked at different code segments and designs, including bringing this section outside the loop, but none of it is working. Any help would be appreciated
I have looked at different code segments and designs, including bringing this section outside the loop, but none of it is working. Any help would be appreciated
time.sleep(5)
#DEFINITIONS
def click(x,y):
win32api.SetCursorPos((x,y))
time.sleep(0.9)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,0,0)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0,0)
def debuff(key):
pyautogui.keyDown("4")
time.sleep(0.1)
pyautogui.keyUp("4")
time.sleep(0.1)
def attack1(key):
pyautogui.keyDown("8")
time.sleep(0.1)
pyautogui.keyUp("8")
time.sleep(0.9)
def attack2(key):
pyautogui.keyDown("2")
time.sleep(0.1)
pyautogui.keyUp("2")
time.sleep(0.9)
#Used to stop the program
while keyboard.is_pressed('g') == False:
#TARGET ENEMY <<< THIS IS WHAT I NEED TO ONLY RUN ONE TIME>>>>
if pyautogui.pixel (1096,127) [0] == 16:
click(1096,127)
#DEBUFF ATTACK
if pyautogui.pixel (1452, 1271) [0] == 158:
debuff("2")
#ATTACK 1
if pyautogui.pixel (1351, 1267) [0] == 251:
attack1("6")
time.sleep(0.9)
#ATTACK 2
if pyautogui.pixel (1351, 1267) [0] == 251:
attack2("4")
time.sleep(23)
