Originally I made this because I was tired of clicking so much in Minecraft when clearing out caves and stuff. I press the left LEFT CTRL key in a Windows system, and as long as that key is held down, your mouse will click ….really fast!

Capturing non-blocking mouse and keyboard events in Python 2.7 hs been a challenge. What a pain in the butt! You would think, of all things, there would already be an open source Auto Clicker out there written for Python, but alas, it must be buried.

So you run this program, it will check for an update and let you know
if I’ve posted any updates. Then you press LEFT CTRL to go click-crazy. Press Right CTRL to close the program. I’ve also taken the liberty of compiling the script down to an exe for windows users with py2exe.

Please, let me know if this works for you, and request some features if you would like!

Note: The program will crash if there isn’t an active internet connection or can’t reach my website for any reason. I’ll fix this in future releases.

 

Download from Github

https://github.com/cjohnweb/py-auto-clicker

[sourcecode language=”python” wraplines=”false” collapse=”false”]
#!/usr/bin/python

import win32api, win32con
import time, sys
import httplib, urllib

def checkforupdates():
params = urllib.urlencode({‘p’: ‘autoclicker’, ‘v’: 1})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
http = httplib.HTTPConnection("pythonjohn.com", 80, timeout=5 )
http.request( "POST", "/checkforupdates.php", params, headers )
response = http.getresponse()
data = response.read()
http.close()
return data

def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

def headers():
print ‘\n\n\n\n’
print ‘Simple AutoClicker By John Minton cjohnweb@gmail.com\n\n’
print ‘Get more cool Python Scripts from http://pythonjohn.com/\n\n’
print ‘***********************************************************\n’
sys.stdout.write(‘Checking for updates: ‘)
data = checkforupdates()
print data + ‘\n\n***********************************************************’
print ‘\n\n’
print ‘Press left CTRL to rapid left-click mouse button\n\n’
print ‘Press right CTRL to close program\n\n’

def autoclicker():
while True:

while win32api.GetAsyncKeyState(win32con.VK_LCONTROL):
print ‘Left CTRL’
a, b = win32api.GetCursorPos()
click(a, b)
time.sleep(0.01)

if win32api.GetAsyncKeyState(win32con.VK_RCONTROL):
exit()

def main():
headers()
autoclicker()

main()

exit()
[/sourcecode]