Advertisement
Peaser

Screenclicker

Jul 2nd, 2014
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.00 KB | None | 0 0
  1. import win32gui, win32api, win32con, random, pythoncom
  2. from win32api import GetSystemMetrics
  3. from time import sleep as s
  4. from os import system as cmd
  5.  
  6. def ps():
  7.     cmd("pause")
  8. def clear():
  9.     cmd("cls")
  10.  
  11. window = win32gui.GetForegroundWindow()
  12.  
  13. def minimize():
  14.     win32gui.ShowWindow(window, win32con.SW_MINIMIZE)
  15. def maximize():
  16.     win32gui.ShowWindow(window, win32con.SW_MAXIMIZE)
  17. def restore():
  18.     win32gui.ShowWindow(window, win32con.SW_RESTORE)
  19.  
  20. def click(x,y):
  21.     win32api.SetCursorPos((x,y))
  22.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
  23.     win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
  24.  
  25. def randomScreenClick(amount=50,time=0.5):
  26.     for i in range(amount):
  27.         x = random.randint(1, GetSystemMetrics (0))
  28.         y = random.randint(1, GetSystemMetrics (1))
  29.         click(x,y)
  30.         s(time)
  31.         #This clicks mouse randomly throughout entire screen.
  32.         #Makes a good prank if you compile it to an executable and put in your victim's startup folder
  33.  
  34. def randomZoneClick(x1,y1,x2,y2,amount=100,time=0.02):
  35.     for i in range(amount):
  36.         x = random.randint(x1,x2)
  37.         y = random.randint(y1,y2)
  38.         click(x,y)
  39.         s(time)
  40.         #USAGE:
  41.             #randomZoneClick(x1,y1,x2,y2,amount,time)
  42.  
  43.         #EXAMPLE:
  44.             #randomZoneClick(483, 353, 628, 504, 100, 0.2)
  45.             #where:
  46.                 #483, 353 = first coordinate
  47.                 #628, 504 = second coordinate
  48.                 #100 = amount of times it clicks
  49.                 #0.2 = time between clicks (in seconds)
  50.  
  51.                 #TO DO:
  52.                     #If amount is 0, do indefinitely (this could be bad)
  53.                     #Actually now that I think about it, This could be really bad
  54.                     #Unstoppable clicking for ever.
  55.                     #As a matter of fact, Just forget about this, I don't want to break stuff
  56.  
  57.         #use pointergetter.py to get cursor location. Source code below.
  58.  
  59.         '''
  60.        import win32gui,pyperclip
  61.        from time import sleep as s
  62.        from os import system as p
  63.  
  64.        print ("You have5 seconds to move mouse to position\n")
  65.        s(5)
  66.        POSITION = win32gui.GetCursorPos()
  67.        print POSITION
  68.        pyperclip.copy(POSITION)
  69.        p("pause")
  70.        '''
  71.         #^^^ Save that as it's own .py file and run it.
  72.         #Once run, You will have 5 seconds to move mouse to desired location,
  73.         #it will print the cursor's coordinates and copy it to your clipboard.
  74.         #Run it a second time for coordinate #2
  75.  
  76. def start(timew8=1):
  77.     print "Resolution: "+ str(GetSystemMetrics (0))+", "+ str(GetSystemMetrics (1))
  78.     print "\n\nGET POSITION 1\n\nOnce you continue, you will have "+str(timew8)+" second(s) to move cursor to desired position."
  79.     ps()
  80.     minimize()
  81.     s(timew8)
  82.     POSITION1 = win32gui.GetCursorPos()
  83.     restore()
  84.     print "\n\n\nPosition 1: "+str(POSITION1)
  85.     print "\n\nGET POSITION 2\n\nOnce you continue, you will have "+str(timew8)+" second(s) to move cursor to desired position."
  86.     ps()
  87.     minimize()
  88.     s(timew8)
  89.     POSITION2 = win32gui.GetCursorPos()
  90.     restore()
  91.     print "\n\nPosition 2: "+str(POSITION2)
  92.     coordinates = POSITION1+POSITION2
  93.     print "\nCoodinates: "+str(coordinates)
  94.     amounts = raw_input("\n\nPlease enter desired amount and time with a space like this:\n'100 0.02' (<-- these are defaults. Don't type anything and these will be used.)\n\n>")
  95.     if amounts != "":
  96.         amt = amounts.split(' ')
  97.         a5 = int(amt[0])
  98.         if '.' in amt[1]:
  99.             a6 = float(amt[1])
  100.         else:
  101.             a6 = int(amt[1]) #allowing floats and ints
  102.     else:
  103.         a5 = 100
  104.         a6 = 0.02
  105.     print("\nWill now randomize mouse clicks.\n")
  106.     ps()
  107.     a1,a2,a3,a4 = coordinates[0],coordinates[1],coordinates[2],coordinates[3]
  108.     minimize()
  109.  
  110.     randomZoneClick(a1,a2,a3,a4,a5,a6)
  111.  
  112.     restore()
  113.     print "\n\nRandomizing complete.\n"
  114.     ps()
  115.     clear()
  116.     start()
  117.  
  118. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement