; ClickWhen ; Author: Adam Pash ; A timed mouse-click application ; Script Function: ; ClickWhen lets you pick a place on your screen ; you'd like to click after a defined period of time. ; #SingleInstance,Off #NoEnv SendMode Input SetWorkingDir, "%A_ScriptDir%" disable := 0 transparency := 50 CoordMode,Mouse,Screen Gosub,RESOURCES Gosub,TRAYMENU Gosub,READINI if update = 1 Gosub,UpdateCheck Goto,Start START: Gui,1: Destroy Gui,1: Add, Tab, x16 y10 w330 h130 , ClickWhen|Preferences Gui,1: Add, Button, x246 y150 w100 h30 gOverlay Default, Next Gui,1: Add, Button, x136 y150 w100 h30 gCancel, Cancel Gui,1: Tab, ClickWhen Gui,1: Add, Text, x36 y50 w290 h30 , ClickWhen lets you pick any place on your screen you'd like to click`, then lets you define when you'd like it to click there. Gui,1: Add, Text, x36 y90 w290 h30, To get started`, click Next. You'll see a light overlay on your screen. Pick the spot you want to click and... click it! Gui,1: Tab, Preferences Gui,1: Add, CheckBox, x36 y50 w300 h30 Checked%update% gCheck, Automatically check for updates when ClickWhen starts ; Generated using SmartGUI Creator 4.0 Gui,1: Show, h188 w354, ClickWhen Return GuiClose: ExitApp CHECK: update := 1 - update ;Msgbox,%update% IniWrite,%update%,clickwhen.ini,Preferences,UpdateCheck return OVERLAY: Gui,1:Submit Gui,1:Destroy SysGet,monitorcount,MonitorCount l=0 t=0 r=0 b=0 Loop,%monitorcount% { SysGet,monitor,Monitor,%A_Index% If (monitorLeftr) r:=monitorRight If (monitorBottom>b) b:=monitorBottom } resolutionRight:=r+Abs(l) resolutionBottom:=b+Abs(t) Goto,ShowWindow return ShowWindow: Gui,1: Destroy Gui,2: Destroy Gui,2: +LastFound -Caption +ToolWindow Gui,2: Color,#fff Gui,2: Show,w%resolutionRight% h%resolutionBottom% x%width%,ClickWhen Overlay WinGet,windowID,ID Gosub,SetTransparency visible = 1 #IfWinActive ClickWhen Overlay LButton:: Gui,2: Destroy MouseGetPos,x,y,window WinGetPos,pos_x, pos_y, width, height, ahk_id %window% Goto,SetTime return SetTransparency: Gui,2: +ToolWindow WinSet, Transparent, %transparency%, ahk_id %windowID% return SetTime: Gui,3: Destroy ;MsgBox, %x%, %y%, %window% Gui, Add, GroupBox, x26 y10 w310 h110 , Time until click: Gui,3: Add, Button, x126 y180 w100 h30 gCancel, Cancel Gui,3: Add, Button, x236 y180 w100 h30 gFinish Default, Finish Gui,3: Font, S12 CDefault, Verdana Gui,3: Add, Edit,r1 x26 y20 w50 h30 vTime, Gui,3: Add, Text, x76 y25 w70 h30 , minutes Gui,3: Font, S8 CDefault, Verdana Gui,3: Add, Checkbox, x50 y65 vDoubleClick, Double-click Gui,3: Font, S12 CDefault, Verdana Gui,3: Add, Edit,r1 x26 y90 w50 h30 vRepeat, 1 Gui,3: Add, Text, x76 y95 w230 h30 , time(s) Gui,3: Font, S8 CDefault, Verdana Gui,3: Add, Text, x140 y100 w230 h30 , (INF For Infinite) Gui,3: Add, Text, x26 y130 w290 h40 , When you hit Finish`, the timer will start. When time runs out`, ClickWhen will click where you told it to. ; Generated using SmartGUI Creator 4.0 Gui,3: Show,h221 w346, ClickWhen Return FINISH: Gui,3:Submit Gui,3:Destroy EnvMult,Time,60000 SetTimer,Click,%Time% return CLICK: WinActivate,ahk_id %window% WinGetPos,cpos_x, cpos_y, cwidth, cheight, ahk_id %window% if cpos_x != %pos_x% WinMove,ahk_id %window%,,%pos_x%,%pos_y%,%width%,%height% Sleep,1000 BlockInput,on if DoubleClick { MouseMove,%x%,%y% Click 2 } else Click %x%, %y% BlockInput,off if(Repeat <> "INF") Repeat -= 1 if (Repeat <> "INF") and (Repeat<=0) ExitApp else SetTimer,Click,%Time% return CANCEL: Gui,Destroy Gui,1:Destroy Gui,2:Destroy Gui,3:Destroy ExitApp return READINI: IfNotExist clickwhen.ini { MsgBox,4,Check for Updates?,Would you like ClickWhen to automatically check for updates when it's run? IfMsgBox,Yes updatereply = 1 else updatereply = 0 } update := GetValFromIni("Preferences","UpdateCheck",updatereply) IniWrite,0.1,clickwhen.ini,Preferences,Version return GetValFromIni(section, key, default) { IniRead,IniVal,clickwhen.ini,%section%,%key% if IniVal = ERROR { IniWrite,%default%,clickwhen.ini,%section%,%key% IniVal := default } return IniVal } UpdateCheck: SetTimer, UpdateCheck, Off UrlDownloadToFile,http://svn.adampash.com/clickwhen/CurrentVersion.txt,%A_WorkingDir%\VersionCheck.txt if ErrorLevel = 0 { FileReadLine, Latest, %A_WorkingDir%\VersionCheck.txt,1 IniRead,Current,clickwhen.ini,Preferences,Version if Latest != %Current% { MsgBox,4,A new version of ClickWhen is available!,Would you like to visit the ClickWhen homepage and download the latest version? IfMsgBox,Yes Goto,Homepage } FileDelete,%A_WorkingDir%\VersionCheck.txt ;; delete version check } return HOMEPAGE: Run,http://lifehacker.com/software/lifehacker-code/automate-timed-mouse-clicks-with-clickwhen-260445.php return RESOURCES: IfNotExist,resources { FileCreateDir,resources FileInstall,resources\clickwhen.png,%A_ScriptDir%\resources\clickwhen.png,0 FileInstall,resources\clickwhen.ico,%A_ScriptDir%\resources\clickwhen.ico,0 } return TRAYMENU: Menu,TRAY,NoStandard Menu,TRAY,DeleteAll Menu,TRAY,Add,&Help,HOMEPAGE Menu,TRAY,Add Menu,TRAY,Add,E&xit,EXIT Menu,TRAY,Default,&Help Menu,Tray,Tip,ClickWhen Menu, Tray, Icon, resources/clickwhen.ico, , 1 return EXIT: ExitApp return