Advertisement
Guest User

Untitled

a guest
Feb 20th, 2013
2,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.44 KB | None | 0 0
  1. ; SwagBot
  2. ; Automated Swagbucks TV watching script
  3.  
  4. #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
  5. SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
  6. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
  7. #Persistent ; Makes this script stay opened
  8. CoordMode, Mouse, Screen ; Makes mouse use absolute coordantes
  9. CoordMode, Pixel, Screen ; Makes pixel stuff use absolute coordantes
  10. SetKeyDelay 250 ; Set the key delay to 500 ms
  11.  
  12. Main()
  13. {
  14. loop
  15. {
  16. ; First set of videos
  17. x = 0 ; Set count
  18. loop
  19. {
  20. if x = 4 ; If videos have run out
  21. break ; End loop
  22. PixelGetColor, color, (x*94)+752, 288 ; Checks to see if white of nothingness is there
  23. Sleep, -1 ; Wait
  24. if color != 0x000000 ; If a video is there
  25. {
  26. MouseClick, left, (x*94)+797, 318 ; Click mouse in middle of video
  27. LoadWait() ; Waits for new page to load
  28. Watch() ; Watch the video, claim swagbucks if needed
  29. }
  30. else
  31. x = 3 ; Informs that the videos are exausted
  32. x += 1 ; Next video
  33. }
  34. ; Second set of videos
  35. x = 0 ; Reset count
  36. loop
  37. {
  38. if x = 4 ; If videos have run out
  39. break ; End loop
  40. PixelGetColor, color, (x*94)+752, 388 ; Checks to see if white of nothingness is there
  41. Sleep, -1 ; Wait
  42. if color != 0x000000 ; If a video is there
  43. {
  44. MouseClick, left, (x*94)+797, 418 ; Click mouse in middle of video
  45. LoadWait() ; Waits for new page to load
  46. Watch() ; Watch the video, claim swagbucks if needed
  47. }
  48. else
  49. x = 3 ; Informs that the videos are exausted
  50. x += 1 ; Next video
  51. }
  52. ; Next Page of videos
  53. PixelGetColor, color, 1130, 362 ; Checks to see if white of nothingness is there
  54. Sleep, -1 ; Wait
  55. if color != 0x000000 ; If arrow is there
  56. MouseClick, left, 1133, 376 ; Click mouse in middle of arrow
  57. else
  58. Pause ;Navigate() ; Navigates to a new section of videos
  59. Sleep, 750 ; Waits for new videos to be moved in
  60. }
  61. }
  62. Watch()
  63. {
  64. PixelGetColor, color, 1014, 142 ; Makes sure that this is the first time playing the video
  65. Sleep, -1 ; Wait
  66. if color = 0xA6A4F8 ; If the red warning is there (BGR?)
  67. return ; Go to next video
  68. current := CheckSM()
  69. loop ; This loop waits till the video has give a percentage to the Swagbucks Meter
  70. {
  71. temp := CheckSM() ; Checks the Swagbucks Meter
  72. if current != %temp% ; Checks to see if the Swagbucks Meter has changed
  73. break ; Ends loop
  74. }
  75. if current = 9 ; If the previous level was 90% then the Swagbucks Meter is full and needs to claimed
  76. Claim() ; Claim the Swagbucks
  77. Sleep, 500 ; Small delay
  78. return ; Go to next video
  79. }
  80. CheckSM()
  81. {
  82. x = 9 ; Starts at 90% mark in the Swagbucks Meter
  83. loop ; The loop that will check each possible % location
  84. {
  85. if x = 0 ; If no green mark was found then Swagbucks Meter is at 0%
  86. break ; Ends loop
  87. PixelGetColor, color, (x*24)+849, 141 ; Checks pixel color for the green of percentage bar
  88. Sleep, -1 ; Wait
  89. if color = 0x49B696 ; If green mark is found then Swagbucks Meter is at x% (BGR?)
  90. break ; End loop
  91. x -= 1 ; Checks the next possible percentage in the Swagbucks Meter
  92. }
  93. return x ; Returns the value position of the Swagbucks Meter
  94. }
  95. LoadWait()
  96. {
  97. Sleep, 5000 ; Some insurance
  98. loop
  99. {
  100. PixelGetColor, color, 22, 10 ; Checks pixel color for the green of webpage icon
  101. Sleep, -1 ; Wait
  102. if color = 0x46C5A2 ; If green mark is found then web page is loaded
  103. break ; End loop
  104. }
  105. Sleep, 1500 ; Some insurance
  106. }
  107. number = 0
  108. Claim()
  109. {
  110. ;Check to see if there is a captcha
  111. Sleep, 750 ; Small delay
  112. PixelGetColor, color, 965, 220 ; Checks pixel color for the white of the lack of enter captcha text
  113. Sleep, -1 ; Wait
  114. if color = 0xFFFFFF ; If there is no captcha
  115. {
  116. MouseClick, left, 1138, 102 ; Close the swagbucks claim popup
  117. Sleep, -1 ; Wait
  118. return ; Go back to watching videos
  119. }
  120. number += 1 ; Record the number of captchas run into
  121. ;Copy the captcha
  122. MouseClick, right, 737, 229 ; Open up the right-click menu on the captcha
  123. Sleep, 750 ; Wait
  124. MouseClick, left, 805, 283 ; Copy the captcha image
  125. Sleep, 750 ; Wait
  126. ;Open Paint.NET
  127. MouseCLick, left, 215, 749 ; Switch to the Paint.NET tab
  128. ;Create new canvas
  129. Send, {Ctrl Down}{n}{Ctrl Up} ; Open create new image menu
  130. Sleep, 500 ; Wait for menu to pop up
  131. Send, {Enter} ; Create new image
  132. Sleep, 500 ; Wait for menu to dissappear
  133. Send, {Ctrl Down}{v}{Ctrl Up} ; Paste the captcha image into the canvas
  134. Send, {Ctrl Down}{d}{Ctrl Up} ; Deselect the canvas
  135. ;Filter the captcha
  136. Send, {Ctrl Down}{Shift Down}{d}{Shift Up}{Ctrl Up} ; Duplicate the layer that the captcha is on
  137. Send, {Ctrl Down}{Shift Down}{l}{Shift Up}{Ctrl Up} ; Use Auto Level on the new layer
  138. Sleep, 1500 ; Wait for menu to pop up
  139. Send, {F4} ; Open up layer properties menu
  140. Sleep, 1500 ; Wait for menu to dissapear
  141. Send, {TAB 2} ; Navagate to blend options
  142. Send, {Down 2} ; Select Additive
  143. Send, {TAB 3} ; Navagate to OK
  144. Send, {Enter} ; Exit the layer properties menu
  145. Send, {Ctrl Down}{m}{Ctrl up} ; Merge the Auto Leveled layer and the ogrinal layer together
  146. Send, {f} ; Switch to Fill tool
  147. MouseClick, left, 514, 94 ; Change tolerance to 66%
  148. MouseClick, right, 593, 386 ; Fill canvas with white to help remove anti-alias
  149. Send, {Ctrl Down}{Shift Down}{l}{Shift Up}{Ctrl Up} ; Use Auto Level to turn letters pure black
  150. ;Move the letters
  151. x = 30 ; Starting position to search for
  152. y = 0
  153. loop 3 ; For each letter
  154. {
  155. start = 0 ; The location of the right most black pixel in a letter
  156. finish = 0 ; The location of the left most black pixel in a letter
  157. bottom = 0 ; The location of the bottom most black pixel in a letter
  158. move = 0 ; The distance that the letter must be moved to sit flush with the image bottom
  159. ;Find the start
  160. loop
  161. {
  162. if start > 0 ; If start has been found
  163. break ; End loop
  164. if x = 180 ; If at the end of the image
  165. break ; End loop
  166. loop
  167. {
  168. if y = 37 ; If at the end of the column
  169. break ; End loop
  170. PixelGetColor, color, x+593, y+386 ; Checks pixel for black
  171. if color = 0x000000 ; If pixel is black
  172. {
  173. start := x+593 ; Store location of the black pixel
  174. break ; End loop
  175. }
  176. y += 1 ; Go to next pixel
  177. }
  178. x += 1 ; Go to next column
  179. y = 0 ; Reset
  180. }
  181. ;Find the finish
  182. loop
  183. {
  184. if finish > 0 ; If finish has been found
  185. break ; End loop
  186. if x = 180 ; If at the end of the image
  187. break ; End loop
  188. loop
  189. {
  190. if y = 37 ; If there are no black pixels in the column
  191. {
  192. finish := x+592 ; Store finish location
  193. break ; Break loop
  194. }
  195. PixelGetColor, color, x+593, y+386 ; Check for black pixel
  196. if color = 0x000000 ; If there is a black pixel
  197. break ; Break loop
  198. y += 1 ; Go to next pixel
  199. }
  200. x += 1 ; Go to next column
  201. y = 0 ; Reset
  202. }
  203. ;Find the bottom
  204. x = %start% ; Set to beginning of letter
  205. y = 37 ; Set to bottom of image
  206. loop
  207. {
  208. if x = %finish% ; If done searching image
  209. break ; End loop
  210. loop
  211. {
  212. if y = 0 ; If at top of image
  213. break ; End loop
  214. PixelGetColor, color, x, y+386 ; Check for a black pixel
  215. if color = 0x000000 ; If pixel is black
  216. {
  217. if bottom < %y% ; If location of pixel is lower than previous location
  218. bottom = %y% ; Set location to bottom
  219. break ; End loop
  220. }
  221. y -= 1 ; Next pixel
  222. }
  223. x += 1 ; Next column
  224. y = 37 ; Reset
  225. }
  226. ;Actually move the letter
  227. move := (bottom-36)*-1 ; Calculate how far the letter needs to be moved down
  228. bottom += 386 ; Make bottom refelect onscreen location not just captcha location
  229. Send, {s} ; Change to the rectangle select tool
  230. Sleep, 500 ; Wait
  231. SendEvent {Click %start%, 386, down}{click %finish%, %bottom%, up} ; Select the letter with the rectangle select tool
  232. Sleep, 500 ; Wait
  233. Send, {m} ; Change to move tool
  234. Sleep, 500 ; Wait
  235. Send, {Down %move%} ; Move the letter down as far as it needs to go to be flush with the image botom
  236. Sleep, 500 ; Wait
  237. Send, {Ctrl Down}{d}{Ctrl up} ; Deselect
  238. Sleep, 500 ; Wait
  239. Send, {f} ; Change to fill tool
  240. Sleep, 500 ; Wait
  241. MouseClick, right, %start%, 386 ; Fill the area that the letter use to be in
  242. Sleep, 500 ; Wait
  243. x := finish-592 ; Make x reflect the location on the image not the screen
  244. y = 0 ; Reset
  245. MouseMove, 0,0 ; Move mouse out of the way
  246. }
  247. ;Save the image
  248. clipboard = C:\sc%number%.png ; Set save location
  249. Sleep, 500
  250. Send, {Ctrl Down}{s}{Ctrl up} ; Save image
  251. Sleep, 500 ; Wait
  252. Send, {Ctrl Down}{v}{Ctrl up} ; Paste in save location
  253. Sleep, 1500 ; Wait
  254. Send, {Enter} ; Confirm
  255. Sleep, 1500 ; Wait
  256. Send, {Enter} ; Confrim yet again
  257. Sleep, 1500 ; Wait
  258. Send, {Ctrl Down}{w}{Ctrl up} ; Close image
  259. ;Extract the text
  260. clipboard = http://www.ocr-extract.com/ ; Set url
  261. MouseClick, left, 90, 748 ; Open up chrome again
  262. Sleep, 1500 ; Wait
  263. Send, {Ctrl Down}{t}{Ctrl up} ; Create new tab
  264. Sleep, 1500 ; Wait
  265. Send, {Ctrl Down}l{Ctrl Up} ; Select URL bar
  266. Sleep, 1500 ; Wait
  267. Send, {Ctrl Down}{v}{Ctrl up} ; Paste in new url
  268. Sleep, 1500 ; Wait
  269. Send, {Enter} ; Navigate to url
  270. Sleep, 1500 ; Wait
  271. Send, {End} ; Scroll down page
  272. Sleep, 1500 ; Wait
  273. clipboard = C:\sc%number%.png ; Set image location
  274. Sleep, 500 ; Wait
  275. MouseClick, left, 367,462 ; Choose image
  276. Sleep, 1500 ; Wait
  277. Send, {Ctrl Down}{v}{Ctrl up} ; Paste in image location
  278. Sleep, 500 ; Wait
  279. Send, {Enter} ; Confirm
  280. Sleep, 1500 ; Wait
  281. MouseClick, left, 368, 506 ; Click on the extract button
  282. Sleep, 1500 ; Wait
  283. MouseClick, left, 306, 314, 2 ; Double click on output
  284. Sleep, 500 ; Wait
  285. Send, {Ctrl Down}{c}{Ctrl up} ; Copy output
  286. Sleep, 500 ; Wait
  287. Send, {Ctrl Down}{w}{Ctrl up} ; Close the tab
  288. ;Enter the captcha
  289. Sleep, 1500 ; Wait
  290. MouseClick, left, 898, 243, 2 ; Select the captcha imput box
  291. Sleep, 500 ; Wait
  292. Send, {Ctrl Down}{v}{Ctrl up} ; Paste in the extracted captcha text
  293. Sleep, 750 ; Wait
  294. MouseClick, left, 970, 272 ; Click the captcha check button
  295. Sleep, 500 ; Wait
  296. MouseClick, left, 1138, 102 ; Close the swagbucks claim popup
  297. }
  298.  
  299. Sleep, 5000
  300. Main()
  301.  
  302. F11::Pause ; Push F11 key to pause this bot script
  303. F12::ExitApp ; Push F12 key to exit this bot script
  304.  
  305. Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement