1111- Clicks fast
1212- Stops clicking when mouse is outside of a boundary
1313- Automatically moves mouse to image location
14+ - Can auto find and click on many images
1415"""
1516
1617# ================================================================================================
1718# SETTINGS
18-
1919delay = 0.001 # Set delay
2020button = Button .left # Set button to press
2121startStopKey = KeyCode (char = 'z' ) # Set key to start/stop
22+ frenzyKey = KeyCode (char = 'x' ) # Set key to frenzy
2223
2324boundaryToggle = True # Change to False to disable boundary auto turn off
2425autoSnapToggle = True # Change to False to disable auto snap to image
25-
26+ frenzyToggle = True # Change to False to disable frenzy click
2627
2728# ================================================================================================
2829# Advanced settings
3334# Set the location of the images
3435# By default the images need to be in the same directory as this program
3536cookiepath = os .path .join (programDirectory , 'cookie.png' )
37+ frenzyPath = os .path .join (programDirectory , 'frenzyCookie.png' )
3638
3739# ================================================================================================
3840print ("Auto Clicker Starting\n "
3941 f"Delay: { delay : 0.001} \n "
4042 f"Auto click button: { button } \n "
41- f"Start/Stop button: { startStopKey } " )
43+ f"Start/Stop button: { startStopKey } \n "
44+ f"Frenzy button: { frenzyKey } \n " )
4245
4346
4447mouse = Controller () # Create mouse object
4548clicking = False # Set clicking to false
4649
4750def active (delay , button ): # Function to click
48- while clicking == True : # While truez
51+ while clicking == True : # While true
4952 mouse .click (button ) # Click the button
5053 time .sleep (delay ) # Sleep for the delay
5154 return
@@ -73,12 +76,12 @@ def boundary(): # Function to check if the mouse is in the boundary+
7376
7477
7578def keyLogger (key ): # Function for tracking key presses
76- global clicking , imageLocation
79+ global clicking
7780 if key == startStopKey : # If the key pressed is the start/stop key
7881 try :
7982 if autoSnapToggle == True :
8083 imageLocation = pyautogui .locateOnScreen (cookiepath , grayscale = True , confidence = 0.70 ) # Locate the image on the screen
81- imageLocation = (imageLo cation [0 ], imageLocation [1 ] - 100 , imageLocation [2 ], imageLocation [3 ]) # modify y to raise the mouse to middle
84+ imageLocation = (imageLocation [0 ], imageLocation [1 ] - 100 , imageLocation [2 ], imageLocation [3 ]) # modify y to raise the mouse to middle
8285 pyautogui .moveTo (imageLocation ) # Move the mouse to the location
8386 clicking = not clicking # Set clicking to the opposite of what it is
8487 print (f"Auto clicker: { clicking } " ) # Print the key pressed
@@ -87,6 +90,7 @@ def keyLogger(key): # Function for tracking key presses
8790 clicking = not clicking # Set clicking to the opposite of what it is
8891 print (f"Auto clicker: { clicking } " ) # Print the key pressed
8992
93+
9094 if clicking == True : # if clicking is true
9195 # Create thread for active function
9296 clickingThread = threading .Thread (target = active , args = (delay , button ))
@@ -95,12 +99,26 @@ def keyLogger(key): # Function for tracking key presses
9599 if boundaryToggle == True :
96100 boundaryThread = threading .Thread (target = boundary )
97101 boundaryThread .start ()
98-
102+
99103 except Exception as e :
100104 print (f"Error: { e } " )
101105 print ("No cookie found" )
102106 clicking = False
103-
104- # Create listener for key logging
107+
108+ if key == frenzyKey and frenzyToggle == True : # If the key pressed is the frenzy key
109+ clicking = False # Set clicking to false to disable if auto clicker is currently running
110+
111+ while True : # While true
112+ try :
113+ for pos in pyautogui .locateAllOnScreen (frenzyPath , grayscale = True , confidence = 0.7 ): # Locate all the images on the screen
114+ pyautogui .moveTo (pos ) # Move the mouse to the location
115+ mouse .click (Button .left ) # Click the button
116+
117+ except Exception as e : # Exit on no frenzy cookie found
118+ print (f"Error: { e } " )
119+ print ("No frenzy cookie found" ) # Print if no cookie is found
120+ break # Break the loop
121+
122+ # Create listener for key logging and start keyLogger function
105123with Listener (on_press = keyLogger ) as listener :
106124 listener .join ()
0 commit comments