Advertisement
here2share

# autoclick.py

Mar 11th, 2019
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.78 KB | None | 0 0
  1. # autoclick.py
  2. # Intended for Chrono Download Manager VIA Chrome --
  3.  
  4. from Tkinter import *
  5. from ctypes import windll, Structure, c_ulong, byref
  6. import PIL.ImageGrab
  7. import time
  8.  
  9. root = Tk()
  10. root.title("AutoClicker")
  11. root.resizable(width=FALSE, height=FALSE)
  12.  
  13. mouse = windll.user32
  14. state = False
  15. clicked = 0
  16.  
  17. amount = StringVar()
  18. speed = StringVar()
  19.  
  20. amount.set(0)
  21. speed.set(20)
  22. mainframe = Frame(root)
  23. mainframe.grid(padx=5, pady=5)
  24.  
  25. def StateFalse():
  26.     global state
  27.     state = False
  28.  
  29. def StateTrue():
  30.     global state, clicked, wait, Amount
  31.     if not state:
  32.         clicked = 0
  33.     wait = int(speed.get())
  34.     state = time.time()-wait
  35.     Amount = int(amount.get())
  36. 0
  37.  
  38. amountLabel = Label(mainframe, text="Number of Clicks\n(Set to 0 for *infinite)").grid(column=1, row=1, sticky=W)
  39. speedLabel = Label(mainframe, text="Click interval\n(in seconds)").grid(column=1, row=2, sticky=W)
  40. amountEntry = Entry(mainframe, textvariable=amount, width=5).grid(column=2, row=1)
  41. speedEntry = Entry(mainframe, textvariable=speed, width=5).grid(column=2, row=2)
  42. startButton = Button(mainframe, text="Start", width=10, command=StateTrue).grid(column=1, row=3,columnspan=2,sticky=W)
  43. stopButton = Button(mainframe, text="Stop", width=10, command=StateFalse).grid(column=2, row=3, columnspan=2,sticky=E)
  44.  
  45. root.bind("<F7>",StateTrue())
  46. root.bind("<F8>",StateFalse())
  47.  
  48. """It simulates the mouse"""
  49. MOUSEEVENTF_MOVE = 0x0001 # mouse move
  50. MOUSEEVENTF_LEFTDOWN = 0x0002 # left button down
  51. MOUSEEVENTF_LEFTUP = 0x0004 # left button up
  52. MOUSEEVENTF_RIGHTDOWN = 0x0008 # right button down
  53. MOUSEEVENTF_RIGHTUP = 0x0010 # right button up
  54. MOUSEEVENTF_MIDDLEDOWN = 0x0020 # middle button down
  55. MOUSEEVENTF_MIDDLEUP = 0x0040 # middle button up
  56. MOUSEEVENTF_WHEEL = 0x0800 # wheel button rolled
  57. MOUSEEVENTF_ABSOLUTE = 0x8000 # absolute move
  58. SM_CXSCREEN = 0
  59. SM_CYSCREEN = 1
  60.  
  61. class POINT(Structure):
  62.     _fields_ = [("x", c_ulong), ("y", c_ulong)]
  63.  
  64. def MouseClick(x=None,y=None):
  65.     try:
  66.         windll.user32.SetCursorPos(x,y)
  67.     except:
  68.         0
  69.     mouse.mouse_event(2, 0, 0, 0, 0)  # left mouse button down
  70.     mouse.mouse_event(4, 0, 0, 0, 0)  # left mouse button up
  71.  
  72. def MouseEvent():
  73.     pt = POINT()
  74.     windll.user32.GetCursorPos(byref(pt))
  75.     MouseClick(850,200) # if unable to resume: cancel
  76.     MouseClick(420,120)
  77.     windll.user32.SetCursorPos(pt.x,pt.y)
  78.     print "Clicked:", clicked
  79.     print "Mouse Position:", pt.x,pt.y
  80.  
  81. while True:
  82.     if state:
  83.         if not clicked:
  84.             print ">>> Auto Clicker -- Activated..."
  85.             clicked = 1
  86.         rgb = PIL.ImageGrab.grab().load()[420, 120]
  87.         if rgb == (173, 206, 61):
  88.             if time.time() > state+wait:
  89.                 state = time.time()+wait
  90.                 MouseEvent()
  91.                 clicked += 1
  92.                 if clicked == Amount:
  93.                     state = False
  94.     else:
  95.         if clicked:
  96.             print ">>> Auto Clicker -- Stopped"
  97.         clicked = 0
  98.     root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement