Saturday, September 19, 2009

Youtube's New Comment System, September 2009, Simple Macro

Ok, here is simple macro I wrote using autoit. In simple terms it automates hitting pagedown and clicking on Show More Comments. Note you will probably have to modify the mouseclick x and y values for your setup. Here is the sourcecode, so to speak. It is autoit v3. Enjoy



; Script Start - Add your code below here
#Include
#include
#include
#include
$sType=4
Opt("WinWaitDelay", 100)
; This needs to be 2 so it will target the window no matter where it is on your screen."Opt("WinTitleMatchMode", 2)"
;This way it doesnt have to be in top left corner.
Opt("WinTitleMatchMode", 2)
Opt("WinDetectHiddenText", 1)
Opt("PixelCoordMode", 2)
Opt("MouseCoordMode", 2)


HotKeySet("{END}", "KillBot");hitting the endkey calls the killbot function

$Windows="YouTube";note be careful nothing else you have opened is named youtube
;note be careful nothing else you have opened is named youtube
;note be careful nothing else you have opened is named youtube
; Sleep(1000)
$x=0
Call ("WindowsTab")
MouseClick ("left", 10, 410, 1, 0); to make sure pagedown works properly
Sleep(100)
Send ("{PGDN}")
Sleep(500)
Send ("{PGDN}")
Sleep(500)


While $x<1000 ;while loop, although stop at given value, the actually effect is proportional and much closer than this.
;100 loops = +650 comments if you start at beginning, but the rate slowed down over time, because loading the comments slowed down
;1000 loops = +1990 comments if you start at beginning (ie 10 comments), takes forever
Call ("WindowsTab"); call function "windowstab"
SLeep(10);wait 10 milliseconds
Send ("{PGDN}");simulates pagedown key being pressed
Sleep(10)
Send ("{PGDN}")
Sleep(10)
Send ("{PGDN}")
;{PGDN}
;MouseMove(600, 610, 0)
;MouseClick ("left", 600, 610, 2, 0)
;MouseClick ("left", 600, 580, 2, 0)
MouseClick ("left", 600, 430, 2, 0); instanting moves mouse to location x=600, y = 610, clicks twice(2)
;location of Show More Comments, note depending on your screen resolution and browser text size, you will probably need to change this.
;MouseClick ( "button" [, x, y [, clicks [, speed ]]] )
Sleep(20)
Send ("{PGDN}")
Sleep(20)
Send ("{PGDN}")

;MouseClick ("left", 930, 732, 1, 10)
$x=$x+1
WEnd




Func WindowsTab()

WinWait($Windows, "")
If Not WinActive($Windows, "") Then WinActivate($Windows, "")
WinWaitActive($Windows, "")
EndFunc

Func KillBot()
$MB_MsgBoxButtons = 5 ;What buttons that show in messagebox 5 = Retry and Cancel
$MB_Cancel = 2 ;What button is pressed to exit the script 2 = Cancel, If Cancel button is pushed the script stops.
If MsgBox($MB_MsgBoxButtons, "You Stopped the Bot!", "Retry or Cancel the bot?") == $MB_Cancel Then
Exit
EndIf
EndFunc ;==>KillBot

;Script End

No comments:

Post a Comment