Guest User

Untitled

a guest
Dec 16th, 2019
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.75 KB | None | 0 0
  1. /*
  2.  
  3. WHAT THIS DOES:
  4.  
  5. Scans your phone's screen that's being mirrored to your computer to look for images of buttons you have saved, then clicks them.
  6. This makes it more reliable than autoclickers as you pretty much never have to worry about tapping the wrong button, overheating,
  7. placing tap spots in pixel perfect positions so as not to get stuck by changing targets/selecting battle rewards, or accidentally minimizing the game and tapping to call your boss at four in the morning over and over again. The timings and positions of the taps are also randomized as a slight protection against macro detection.
  8.  
  9. This works by hijacking your mouse for a split second to make a click and then returning it to where it was, so it's best to use on a computer you're not using at that time, like a backup notebook, or if you're doing something not very mouse-intensive.
  10.  
  11. This method also works for iPhones, but you'll need a Windows PC to run Autohotkey.
  12.  
  13.  
  14. HOW TO USE IT:
  15.  
  16. 0. Have a windows PC, make a folder dedicated to this script somewhere
  17. 1. Download scrcpy https://github.com/Genymobile/scrcpy
  18. (scrcpy only works on Android, for iPhones you'll have to find another way to mirror your phone's screen to a PC)
  19. 2. Mirror your phone's screen to your PC (for scrcpy, follow the instructions on their page)
  20. 3. Take screenshots of buttons you want to press, save them as little cutouts to your dedicated folder
  21. make sure they are as unique as possible and .png, not .jpg
  22. 4. Download AutoHotkey, if you don't have it already https://www.autohotkey.com/
  23. 5. Paste this script into notepad, and edit it according to your buttons and their filenames. SEE LINES HIGHLIGHTED WITH ███
  24. 6. Save the script to your dedicated folder as a file with the .ahk extension (Save as > select All files under the name box, name it <whatever>.AHK, save). Run it. You should now see the autohotkey icon in your system tray
  25. 7. Have your scrcpy/phone screen window highlighted and press F12, you should see a popup informing you of your active window, press OK and enjoy
  26. (F12 pauses the script as well)
  27. 8. Farm and laugh at scriptlets in /3vpmg/
  28.  
  29.  
  30.  
  31. OTHER TIPS:
  32.  
  33. -If you resize your mirrored window, your images will no longer match. Make sure you don't do that.
  34. -If you're using scrcpy, you can press Ctrl+O to turn off your phone's screen but keep mirroring (relevant for OLED screens to avoid burn-in).
  35. -If you're sure your images match and aren't getting detected anyway, increase the sensitivity in the code by a bit (default 50).
  36. Don't overdo it or you might start getting false positives. If you're having the opposite problem and get a lot of FPs, decrease it.
  37. -The ImageSearch function in autohotkey works by comparing your image and the window from the top left corner line by line.
  38. If, for instance, you have an image that starts with bunch of white pixels, and the whole screen is white, searching is gonna take a while because the function is gonna stop at every single pixel to see if there's a match, so if you're having issues with speed,
  39. try to have your button images have colors unique to the screen they're on in their top left corners
  40.  
  41. */
  42.  
  43. #Warn
  44. #NoEnv
  45. #SingleInstance, On
  46.  
  47. CoordMode, Pixel, Screen
  48. CoordMode, Mouse, Screen
  49. CoordMode, ToolTip, Screen
  50. SetWorkingDir %A_ScriptDir%
  51.  
  52. Image = m2.png|go.png|cont.png|ok.png ; ███ Button list, edit according to what you have, take note of the last one in the list (ok.png in this case)
  53.  
  54. Pause
  55. WinGetTitle, WindowName, A
  56. MsgBox, The active window is %WindowName%.
  57.  
  58. ParseButton:
  59. Loop, Parse, Image, |,
  60. {
  61. WinGetPos, XOff, YOff, Width, Height, %WindowName%
  62. XMax := XOff + Width
  63. YMax := YOff + Height
  64. Tooltip, Searching for %a_loopfield%, XOff, YOff, 1
  65. ImageSearch, ImageX1, ImageY1, XOff, YOff, XMax, YMax, *50 %a_loopfield% ; Adjust the number after the asterisk to increase/decrease sensitivity 0-255 (the higher the # the less strict the image search is)
  66. Random, ImageX, ImageX1, ImageX1+25 ; numbers after ImageX1: Variance in position of the clicks in the X direction (in pixels). Should be no bigger than the width/height of your smallest button
  67. Random, ImageY, ImageY1, ImageY1+25 ; numbers after ImageY1: Variance in position of where it will click relative to the upper left corner in the Y direction.
  68. Random, Delay, 0.04, 0.08
  69. if ErrorLevel = 2
  70. {
  71. MsgBox Error searching for %a_loopfield%.
  72. }
  73. else if Errorlevel = 1
  74. {
  75. if a_loopfield = ok.png ; ███ The last image from your list must go here
  76. {
  77. Goto ParseButton
  78. }
  79. else
  80. {
  81. Continue
  82. }
  83. }
  84. else
  85. {
  86. Tooltip, %a_loopfield% pressed., XOff, YOff+23, 2
  87. if a_loopfield = ok.png ; ███ The last image from your list must go here
  88. {
  89. ClickRandom(ImageX,ImageY,1,Delay)
  90. TimedSleep(Delay)
  91. Goto ParseButton
  92. }
  93. else
  94. {
  95. ClickRandom(ImageX,ImageY,1,Delay)
  96. TimedSleep(Delay)
  97. Continue
  98. }
  99. }
  100. }
  101.  
  102. f10::ExitApp ;Force close the script hotkey
  103. f11::Reload ;Reload the macro hotkey
  104. f12::Pause ;Start the macro/pause the macro hotkey
  105.  
  106. Randomize(Rmin,Rmax) {
  107. Random, OutputR, %Rmin%, %Rmax%
  108. Return OutputR
  109. }
  110.  
  111. TimedSleep(S) {
  112. SleepMultiple := Randomize(800, 1000)
  113. Sleep, SleepMultiple * S
  114. return
  115. }
  116.  
  117. ClickRandom(ImageX, ImageY, ClickCount, Pause) {
  118. MouseGetPos MouseX, MouseY
  119. Loop %ClickCount%{
  120. MouseClick, Left, %ImageX%, %ImageY%, 1, 0, D
  121. TimedSleep(Pause/2)
  122. MouseClick, Left, %ImageX%, %ImageY%, 1, 0, U
  123. TimedSleep(Pause/2)
  124. }
  125. MouseMove %MouseX%, %MouseY%, 0
  126. }
Advertisement
Add Comment
Please, Sign In to add comment