Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; SwagBot
- ; Automated Swagbucks TV watching script
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- #Persistent ; Makes this script stay opened
- CoordMode, Mouse, Screen ; Makes mouse use absolute coordantes
- CoordMode, Pixel, Screen ; Makes pixel stuff use absolute coordantes
- SetKeyDelay 250 ; Set the key delay to 500 ms
- Main()
- {
- loop
- {
- ; First set of videos
- x = 0 ; Set count
- loop
- {
- if x = 4 ; If videos have run out
- break ; End loop
- PixelGetColor, color, (x*94)+752, 288 ; Checks to see if white of nothingness is there
- Sleep, -1 ; Wait
- if color != 0x000000 ; If a video is there
- {
- MouseClick, left, (x*94)+797, 318 ; Click mouse in middle of video
- LoadWait() ; Waits for new page to load
- Watch() ; Watch the video, claim swagbucks if needed
- }
- else
- x = 3 ; Informs that the videos are exausted
- x += 1 ; Next video
- }
- ; Second set of videos
- x = 0 ; Reset count
- loop
- {
- if x = 4 ; If videos have run out
- break ; End loop
- PixelGetColor, color, (x*94)+752, 388 ; Checks to see if white of nothingness is there
- Sleep, -1 ; Wait
- if color != 0x000000 ; If a video is there
- {
- MouseClick, left, (x*94)+797, 418 ; Click mouse in middle of video
- LoadWait() ; Waits for new page to load
- Watch() ; Watch the video, claim swagbucks if needed
- }
- else
- x = 3 ; Informs that the videos are exausted
- x += 1 ; Next video
- }
- ; Next Page of videos
- PixelGetColor, color, 1130, 362 ; Checks to see if white of nothingness is there
- Sleep, -1 ; Wait
- if color != 0x000000 ; If arrow is there
- MouseClick, left, 1133, 376 ; Click mouse in middle of arrow
- else
- Pause ;Navigate() ; Navigates to a new section of videos
- Sleep, 750 ; Waits for new videos to be moved in
- }
- }
- Watch()
- {
- PixelGetColor, color, 1014, 142 ; Makes sure that this is the first time playing the video
- Sleep, -1 ; Wait
- if color = 0xA6A4F8 ; If the red warning is there (BGR?)
- return ; Go to next video
- current := CheckSM()
- loop ; This loop waits till the video has give a percentage to the Swagbucks Meter
- {
- temp := CheckSM() ; Checks the Swagbucks Meter
- if current != %temp% ; Checks to see if the Swagbucks Meter has changed
- break ; Ends loop
- }
- if current = 9 ; If the previous level was 90% then the Swagbucks Meter is full and needs to claimed
- Claim() ; Claim the Swagbucks
- Sleep, 500 ; Small delay
- return ; Go to next video
- }
- CheckSM()
- {
- x = 9 ; Starts at 90% mark in the Swagbucks Meter
- loop ; The loop that will check each possible % location
- {
- if x = 0 ; If no green mark was found then Swagbucks Meter is at 0%
- break ; Ends loop
- PixelGetColor, color, (x*24)+849, 141 ; Checks pixel color for the green of percentage bar
- Sleep, -1 ; Wait
- if color = 0x49B696 ; If green mark is found then Swagbucks Meter is at x% (BGR?)
- break ; End loop
- x -= 1 ; Checks the next possible percentage in the Swagbucks Meter
- }
- return x ; Returns the value position of the Swagbucks Meter
- }
- LoadWait()
- {
- Sleep, 5000 ; Some insurance
- loop
- {
- PixelGetColor, color, 22, 10 ; Checks pixel color for the green of webpage icon
- Sleep, -1 ; Wait
- if color = 0x46C5A2 ; If green mark is found then web page is loaded
- break ; End loop
- }
- Sleep, 1500 ; Some insurance
- }
- number = 0
- Claim()
- {
- ;Check to see if there is a captcha
- Sleep, 750 ; Small delay
- PixelGetColor, color, 965, 220 ; Checks pixel color for the white of the lack of enter captcha text
- Sleep, -1 ; Wait
- if color = 0xFFFFFF ; If there is no captcha
- {
- MouseClick, left, 1138, 102 ; Close the swagbucks claim popup
- Sleep, -1 ; Wait
- return ; Go back to watching videos
- }
- number += 1 ; Record the number of captchas run into
- ;Copy the captcha
- MouseClick, right, 737, 229 ; Open up the right-click menu on the captcha
- Sleep, 750 ; Wait
- MouseClick, left, 805, 283 ; Copy the captcha image
- Sleep, 750 ; Wait
- ;Open Paint.NET
- MouseCLick, left, 215, 749 ; Switch to the Paint.NET tab
- ;Create new canvas
- Send, {Ctrl Down}{n}{Ctrl Up} ; Open create new image menu
- Sleep, 500 ; Wait for menu to pop up
- Send, {Enter} ; Create new image
- Sleep, 500 ; Wait for menu to dissappear
- Send, {Ctrl Down}{v}{Ctrl Up} ; Paste the captcha image into the canvas
- Send, {Ctrl Down}{d}{Ctrl Up} ; Deselect the canvas
- ;Filter the captcha
- Send, {Ctrl Down}{Shift Down}{d}{Shift Up}{Ctrl Up} ; Duplicate the layer that the captcha is on
- Send, {Ctrl Down}{Shift Down}{l}{Shift Up}{Ctrl Up} ; Use Auto Level on the new layer
- Sleep, 1500 ; Wait for menu to pop up
- Send, {F4} ; Open up layer properties menu
- Sleep, 1500 ; Wait for menu to dissapear
- Send, {TAB 2} ; Navagate to blend options
- Send, {Down 2} ; Select Additive
- Send, {TAB 3} ; Navagate to OK
- Send, {Enter} ; Exit the layer properties menu
- Send, {Ctrl Down}{m}{Ctrl up} ; Merge the Auto Leveled layer and the ogrinal layer together
- Send, {f} ; Switch to Fill tool
- MouseClick, left, 514, 94 ; Change tolerance to 66%
- MouseClick, right, 593, 386 ; Fill canvas with white to help remove anti-alias
- Send, {Ctrl Down}{Shift Down}{l}{Shift Up}{Ctrl Up} ; Use Auto Level to turn letters pure black
- ;Move the letters
- x = 30 ; Starting position to search for
- y = 0
- loop 3 ; For each letter
- {
- start = 0 ; The location of the right most black pixel in a letter
- finish = 0 ; The location of the left most black pixel in a letter
- bottom = 0 ; The location of the bottom most black pixel in a letter
- move = 0 ; The distance that the letter must be moved to sit flush with the image bottom
- ;Find the start
- loop
- {
- if start > 0 ; If start has been found
- break ; End loop
- if x = 180 ; If at the end of the image
- break ; End loop
- loop
- {
- if y = 37 ; If at the end of the column
- break ; End loop
- PixelGetColor, color, x+593, y+386 ; Checks pixel for black
- if color = 0x000000 ; If pixel is black
- {
- start := x+593 ; Store location of the black pixel
- break ; End loop
- }
- y += 1 ; Go to next pixel
- }
- x += 1 ; Go to next column
- y = 0 ; Reset
- }
- ;Find the finish
- loop
- {
- if finish > 0 ; If finish has been found
- break ; End loop
- if x = 180 ; If at the end of the image
- break ; End loop
- loop
- {
- if y = 37 ; If there are no black pixels in the column
- {
- finish := x+592 ; Store finish location
- break ; Break loop
- }
- PixelGetColor, color, x+593, y+386 ; Check for black pixel
- if color = 0x000000 ; If there is a black pixel
- break ; Break loop
- y += 1 ; Go to next pixel
- }
- x += 1 ; Go to next column
- y = 0 ; Reset
- }
- ;Find the bottom
- x = %start% ; Set to beginning of letter
- y = 37 ; Set to bottom of image
- loop
- {
- if x = %finish% ; If done searching image
- break ; End loop
- loop
- {
- if y = 0 ; If at top of image
- break ; End loop
- PixelGetColor, color, x, y+386 ; Check for a black pixel
- if color = 0x000000 ; If pixel is black
- {
- if bottom < %y% ; If location of pixel is lower than previous location
- bottom = %y% ; Set location to bottom
- break ; End loop
- }
- y -= 1 ; Next pixel
- }
- x += 1 ; Next column
- y = 37 ; Reset
- }
- ;Actually move the letter
- move := (bottom-36)*-1 ; Calculate how far the letter needs to be moved down
- bottom += 386 ; Make bottom refelect onscreen location not just captcha location
- Send, {s} ; Change to the rectangle select tool
- Sleep, 500 ; Wait
- SendEvent {Click %start%, 386, down}{click %finish%, %bottom%, up} ; Select the letter with the rectangle select tool
- Sleep, 500 ; Wait
- Send, {m} ; Change to move tool
- Sleep, 500 ; Wait
- Send, {Down %move%} ; Move the letter down as far as it needs to go to be flush with the image botom
- Sleep, 500 ; Wait
- Send, {Ctrl Down}{d}{Ctrl up} ; Deselect
- Sleep, 500 ; Wait
- Send, {f} ; Change to fill tool
- Sleep, 500 ; Wait
- MouseClick, right, %start%, 386 ; Fill the area that the letter use to be in
- Sleep, 500 ; Wait
- x := finish-592 ; Make x reflect the location on the image not the screen
- y = 0 ; Reset
- MouseMove, 0,0 ; Move mouse out of the way
- }
- ;Save the image
- clipboard = C:\sc%number%.png ; Set save location
- Sleep, 500
- Send, {Ctrl Down}{s}{Ctrl up} ; Save image
- Sleep, 500 ; Wait
- Send, {Ctrl Down}{v}{Ctrl up} ; Paste in save location
- Sleep, 1500 ; Wait
- Send, {Enter} ; Confirm
- Sleep, 1500 ; Wait
- Send, {Enter} ; Confrim yet again
- Sleep, 1500 ; Wait
- Send, {Ctrl Down}{w}{Ctrl up} ; Close image
- ;Extract the text
- clipboard = http://www.ocr-extract.com/ ; Set url
- MouseClick, left, 90, 748 ; Open up chrome again
- Sleep, 1500 ; Wait
- Send, {Ctrl Down}{t}{Ctrl up} ; Create new tab
- Sleep, 1500 ; Wait
- Send, {Ctrl Down}l{Ctrl Up} ; Select URL bar
- Sleep, 1500 ; Wait
- Send, {Ctrl Down}{v}{Ctrl up} ; Paste in new url
- Sleep, 1500 ; Wait
- Send, {Enter} ; Navigate to url
- Sleep, 1500 ; Wait
- Send, {End} ; Scroll down page
- Sleep, 1500 ; Wait
- clipboard = C:\sc%number%.png ; Set image location
- Sleep, 500 ; Wait
- MouseClick, left, 367,462 ; Choose image
- Sleep, 1500 ; Wait
- Send, {Ctrl Down}{v}{Ctrl up} ; Paste in image location
- Sleep, 500 ; Wait
- Send, {Enter} ; Confirm
- Sleep, 1500 ; Wait
- MouseClick, left, 368, 506 ; Click on the extract button
- Sleep, 1500 ; Wait
- MouseClick, left, 306, 314, 2 ; Double click on output
- Sleep, 500 ; Wait
- Send, {Ctrl Down}{c}{Ctrl up} ; Copy output
- Sleep, 500 ; Wait
- Send, {Ctrl Down}{w}{Ctrl up} ; Close the tab
- ;Enter the captcha
- Sleep, 1500 ; Wait
- MouseClick, left, 898, 243, 2 ; Select the captcha imput box
- Sleep, 500 ; Wait
- Send, {Ctrl Down}{v}{Ctrl up} ; Paste in the extracted captcha text
- Sleep, 750 ; Wait
- MouseClick, left, 970, 272 ; Click the captcha check button
- Sleep, 500 ; Wait
- MouseClick, left, 1138, 102 ; Close the swagbucks claim popup
- }
- Sleep, 5000
- Main()
- F11::Pause ; Push F11 key to pause this bot script
- F12::ExitApp ; Push F12 key to exit this bot script
- Return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement