Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Non repetitive mouse click
#1
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

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)
Reply


Messages In This Thread
Non repetitive mouse click - by Sartre - Apr-21-2023, 04:12 PM
RE: Non repetitive mouse click - by deanhystad - Apr-21-2023, 04:19 PM
RE: Non repetitive mouse click - by Sartre - Apr-21-2023, 04:27 PM
RE: Non repetitive mouse click - by Sartre - Apr-21-2023, 04:32 PM
RE: Non repetitive mouse click - by Sartre - Apr-22-2023, 03:05 PM
RE: Non repetitive mouse click - by deanhystad - Apr-22-2023, 06:46 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how to mouse click a specific item in pygame? Frankduc 5 3,057 May-03-2022, 06:22 PM
Last Post: Frankduc
  How to script repetitive tasks in dynaform using python BenneGrus 0 2,057 Dec-22-2021, 08:36 AM
Last Post: BenneGrus
  Move mouse and click in particular position biprabu 3 3,491 Sep-01-2020, 08:23 PM
Last Post: deanhystad
  Slide show with mouse click pausing aantono 1 2,927 Jan-28-2020, 04:25 AM
Last Post: Larz60+
  mouse 0.7.0 - mouse polling hate 125-1000hz penahuse 1 3,378 Dec-06-2019, 09:51 PM
Last Post: Larz60+
  Why is left mouse click not working? yeto 3 7,906 Jul-15-2019, 05:23 AM
Last Post: Yoriz
  How to get mouse coordinates on click and release OhNoSegFaultAgain 1 4,489 May-17-2019, 06:56 PM
Last Post: buran
  Python catch mouse click in pure text, no graphics samtal 7 11,818 Sep-10-2018, 03:02 PM
Last Post: samtal
  Mouse click movements? [UPDATED] minnaadel 3 4,666 Mar-31-2018, 05:15 PM
Last Post: woooee
  How to trigger a function by clicking the left mouse click? HelloBoyz 1 12,574 Jun-29-2017, 09:43 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020