Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # autoclick.py
- # Intended for Chrono Download Manager VIA Chrome --
- from Tkinter import *
- from ctypes import windll, Structure, c_ulong, byref
- import PIL.ImageGrab
- import time
- root = Tk()
- root.title("AutoClicker")
- root.resizable(width=FALSE, height=FALSE)
- mouse = windll.user32
- state = False
- clicked = 0
- amount = StringVar()
- speed = StringVar()
- amount.set(0)
- speed.set(20)
- mainframe = Frame(root)
- mainframe.grid(padx=5, pady=5)
- def StateFalse():
- global state
- state = False
- def StateTrue():
- global state, clicked, wait, Amount
- if not state:
- clicked = 0
- wait = int(speed.get())
- state = time.time()-wait
- Amount = int(amount.get())
- 0
- amountLabel = Label(mainframe, text="Number of Clicks\n(Set to 0 for *infinite)").grid(column=1, row=1, sticky=W)
- speedLabel = Label(mainframe, text="Click interval\n(in seconds)").grid(column=1, row=2, sticky=W)
- amountEntry = Entry(mainframe, textvariable=amount, width=5).grid(column=2, row=1)
- speedEntry = Entry(mainframe, textvariable=speed, width=5).grid(column=2, row=2)
- startButton = Button(mainframe, text="Start", width=10, command=StateTrue).grid(column=1, row=3,columnspan=2,sticky=W)
- stopButton = Button(mainframe, text="Stop", width=10, command=StateFalse).grid(column=2, row=3, columnspan=2,sticky=E)
- root.bind("<F7>",StateTrue())
- root.bind("<F8>",StateFalse())
- """It simulates the mouse"""
- MOUSEEVENTF_MOVE = 0x0001 # mouse move
- MOUSEEVENTF_LEFTDOWN = 0x0002 # left button down
- MOUSEEVENTF_LEFTUP = 0x0004 # left button up
- MOUSEEVENTF_RIGHTDOWN = 0x0008 # right button down
- MOUSEEVENTF_RIGHTUP = 0x0010 # right button up
- MOUSEEVENTF_MIDDLEDOWN = 0x0020 # middle button down
- MOUSEEVENTF_MIDDLEUP = 0x0040 # middle button up
- MOUSEEVENTF_WHEEL = 0x0800 # wheel button rolled
- MOUSEEVENTF_ABSOLUTE = 0x8000 # absolute move
- SM_CXSCREEN = 0
- SM_CYSCREEN = 1
- class POINT(Structure):
- _fields_ = [("x", c_ulong), ("y", c_ulong)]
- def MouseClick(x=None,y=None):
- try:
- windll.user32.SetCursorPos(x,y)
- except:
- 0
- mouse.mouse_event(2, 0, 0, 0, 0) # left mouse button down
- mouse.mouse_event(4, 0, 0, 0, 0) # left mouse button up
- def MouseEvent():
- pt = POINT()
- windll.user32.GetCursorPos(byref(pt))
- MouseClick(850,200) # if unable to resume: cancel
- MouseClick(420,120)
- windll.user32.SetCursorPos(pt.x,pt.y)
- print "Clicked:", clicked
- print "Mouse Position:", pt.x,pt.y
- while True:
- if state:
- if not clicked:
- print ">>> Auto Clicker -- Activated..."
- clicked = 1
- rgb = PIL.ImageGrab.grab().load()[420, 120]
- if rgb == (173, 206, 61):
- if time.time() > state+wait:
- state = time.time()+wait
- MouseEvent()
- clicked += 1
- if clicked == Amount:
- state = False
- else:
- if clicked:
- print ">>> Auto Clicker -- Stopped"
- clicked = 0
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement