; AutoHotkey Version: 1.x ; Language: English ; Platform: Win9x/NT ; ; Script Function: Automation script for grid clicking games #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Include, Gdip.ahk #SingleInstance, Ignore #Persistent SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. DetectHiddenWindows, On SetBatchLines, -1 ; build the systray menu Menu, Tray, NoStandard Menu, Tray, Add, Start script, SetGrid Menu, Tray, Add, Reset script, Reset Menu, Tray, Add, Clear graphics overlay, ClearOverlay Menu, Tray, Add Menu, Tray, Add, About, About Menu, Tray, Add, Exit, Exit Menu, Tray, Default, Start script Menu, Tray, Icon, gridclicker.exe Menu, Tray, Tip, Grid clicker ; Start gdi+ ; initialize the overlay If !pToken := Gdip_Startup() { MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system ExitApp } OnExit, Exit PWidth := A_ScreenWidth, PHeight := A_ScreenHeight Gui, 5: -Caption +E0x80000 +LastFound +OwnDialogs +Owner +AlwaysOnTop Gui, 5: Show, NA hwnd1 := WinExist() hbm := CreateDIBSection(PWidth, PHeight) hdc := CreateCompatibleDC() obm := SelectObject(hdc, hbm) G := Gdip_GraphicsFromHDC(hdc) Gdip_SetSmoothingMode(G, 4) ; vars we will need xfields := 1 yfields := 1 xxgrid := 1 xygrid := 1 yxgrid := 1 yygrid := 1 dotcolor := 0xffff0000 dotsize := 8 configure = 0 xcoord := 1 ycoord := 1 live := 0 SetMouseDelay, 50 SendMode Event return SetGrid: dotcolor := 0xffff0000 SplashTextOn , 300, 24, Config, Configuration WinSet, Transparent, 220, Config WinGetPos,,, CWidth, CHeight, Config WinMove, Config,, (A_ScreenWidth/4*3)-(CWidth/2), (A_ScreenHeight/2)-(CHeight/2) gosub ClickBlock ; left ControlSetText, Static1, Click in the left most field (9 O'clock), Config gosub GetMouse xLeft := xcoord yLeft := ycoord DrawPoint() ; top ControlSetText, Static1, Click in the top most field (12 O'clock), Config gosub GetMouse xTop := xcoord yTop := ycoord DrawPoint() ; bottom ControlSetText, Static1, Click in the bottom most field (6 O'clock), Config gosub GetMouse xBottom := xcoord yBottom := ycoord DrawPoint() ; right xRight := xBottom + xTop - xLeft + dotsize / 2 yRight := yTop + yBottom - yLeft - dotsize / 2 xcoord := xRight ycoord := yRight dotcolor := 0xffffff00 DrawPoint() SplashTextOff gosub ClearOverlay ; Bottom Line dotcolor := 0xffff0000 pPen := Gdip_CreatePen(dotcolor, 4) Gdip_DrawLine(G, pPen, xLeft, yLeft, xBottom, yBottom) Gdip_DeleteBrush(pPeen) ; Top Line dotcolor := 0xff0000ff pPen := Gdip_CreatePen(dotcolor, 4) Gdip_DrawLine(G, pPen, xLeft, yLeft, xTop, yTop) Gdip_DeleteBrush(pPen) UpdateLayeredWindow(hwnd1, hdc, 0, 0, PWidth, PHeight) Inputbox, xfields, Fields, How many fields are there along the RED line?,,300,150,,,,, if ErrorLevel gosub Reset Inputbox, yfields, Fields, How many fields are there along the BLUE line?,,300,150,,,,, if ErrorLevel gosub Reset if ( xfields > 1 ) { xxgrid := ( xBottom - xLeft ) / ( xfields - 1 ) xygrid := ( yBottom - yLeft ) / ( xfields - 1 ) } else { xxgrid := 0 xygrid := 0 } if ( yfields > 1 ) { yxgrid := ( xTop - xLeft ) / ( yfields - 1 ) yygrid := ( yLeft - yTop ) / ( yfields - 1 ) } else { yxgrid := 0 yygrid := 0 } gosub ClearOverlay dotcolor := 0x22ffff00 DrawRectangle() dotcolor := 0xffff0000 gosub WorkFields MsgBox, 4097,"Gridclicker" - press "OK" to continue, If everything looks good, press OK to start clicking. Otherwise press CANCEL to abort.`n`nWARNING: Script will immediatly start clicking, last chance `nto change any game settings "what should happen when clicked" IfMsgBox Cancel gosub Reset gosub ClearOverlay dotcolor := 0xffff0000 live := 1 gosub WorkFields gosub ClearOverlay live := 0 return WorkFields: loop, %xfields% { xcoord := xLeft + ( xxgrid * ( A_Index - 1 ) ) ycoord := yLeft + ( xygrid * ( A_Index - 1 ) ) loop, %yfields% { if ( A_Index == 1 ) { gosub DoFieldAction } if ( A_Index != yfields ) { xcoord := xcoord + yxgrid ycoord := ycoord - yygrid gosub DoFieldAction } } } return GetMouse: KeyWait, LButton, D KeyWait, LButton MouseGetPos, xcoord, ycoord return ClearOverlay: Gdip_GraphicsClear(G, 0x00000000) UpdateLayeredWindow(hwnd1, hdc, 0, 0, PWidth, PHeight) return ClickBlock: Gdip_GraphicsClear(G, 0x01010101) UpdateLayeredWindow(hwnd1, hdc, 0, 0, PWidth, PHeight) return DrawPoint() { global xdraw := xcoord - dotsize / 2 ydraw := ycoord - dotsize / 2 pBrush := Gdip_BrushCreateSolid(dotcolor) Gdip_FillEllipse(G, pBrush, xdraw, ydraw, dotsize, dotsize) Gdip_DeleteBrush(pBrush) UpdateLayeredWindow(hwnd1, hdc, 0, 0, PWidth, PHeight) } DrawRectangle() { global pBrush := Gdip_BrushCreateSolid(dotcolor) Points := xLeft "," yLeft "|" xTop "," yTop "|" xRight "," yRight "|" xBottom "," yBottom Gdip_FillPolygon(G, pBrush, Points,1) Gdip_DeleteBrush(pBrush) UpdateLayeredWindow(hwnd1, hdc, 0, 0, PWidth, PHeight) } DoFieldAction: if ( live == 1 ) { MouseMove %xcoord%,%ycoord%,2 Click Left } DrawPoint() return closegdi: Gdip_DeletePen(pPen) SelectObject(hdc, obm) DeleteObject(hbm) DeleteDC(hdc) Gdip_DeleteGraphics(G) Gdip_Shutdown(pToken) Gui, 5:Destroy Return About: MsgBox, 4096,"Gridclicker" script, This is a simple script indended for simplifying automation tests of typical `n"grid" games (plant,harvest, anything that requires clicking in a grid pattern).`n`nUsage is simple, either double click the tray icon, or select "Start script" from `nthe tray menu and follow the onscreen instructions.`n`nScript was written entirely from scratch in the Autohotkey language and makes use`nof the gdiplus interface helper from "tic" for graphics.`n`nThe sourcecode can be requested from the author @ http://dopefish.de Return Reset: reload exit return Exit: Gosub closegdi ExitApp Return