Hey AHK Community I need help creating a script, i have tried writing myself also have tried finding previously made scripts for individual necessary functions and putting them together myself but i am at a loss. So any help pointing me in the right directions would be IMMENSLY appreciated.
So heres my outline for what i was trying to do.
I wanted to have a hotkey "mark" the mouse's position, the be able to click and drag to select a rectangular area of the screen, and artificially segment the rectangle into boxes of a particular pixel size then have the mouse click and drag every predetermined "Box" within the rectangle, to the previously marked mouse position.
In short what im looking to write here is a click and drag system to select multiple items where there is not click and drag system in place.
Mark screen coords then Click and drag select
Re: Mark screen coords then Click and drag select
Code: Select all
#Requires AutoHotkey v1.1.33.10
#NoEnv
#SingleInstance Force
SetBatchLines -1
SendMode Event
SetWinDelay -1
CoordMode Mouse, Screen
global g_hGui, g_hCoordsEdit, g_hHorizontalCellsSlider, g_hVerticalCellsSlider
global g_hGrid, g_CellHwnds, g_leftGrid, g_topGrid, g_cellsPerRow, g_cellsPerColumn
global g_xTarget, g_yTarget
Gui New, +AlwaysOnTop +ToolWindow +Hwndg_hGui, Grid Dragger
Gui Add, Button, Section w80, Draw Grid
Gui Add, Button, xs w80, Set Target
Gui Add, Edit, xs+1 ReadOnly Center w78 Hwndg_hCoordsEdit, (N/A,N/A)
Gui Add, Slider, xs-7 Range1-5 ToolTip Hwndg_hHorizontalCellsSlider
Gui Add, Slider, x+-34 ys h90 Range1-5 ToolTip Vertical Left Hwndg_hVerticalCellsSlider
Gui Show, xCenter yCenter NoActivate
ButtonSetTarget(CtrlHwnd, GuiEvent, EventInfo, ErrLevel:="") {
WinSet ExStyle, +0x20, ahk_id %g_hGui%
WinSet Transparent, 128, ahk_id %g_hGui%
Hotkey *LButton Up, setTargetCoords, On
SetTimer updateTargetCoords, 10
}
setTargetCoords() {
SetTimer updateTargetCoords, Off
updateTargetCoords()
WinSet ExStyle, -0x20, ahk_id %g_hGui%
WinSet Transparent, 255, ahk_id %g_hGui%
Hotkey *LButton Up, , Off
}
updateTargetCoords() {
MouseGetPos g_xTarget, g_yTarget
GuiControl, , % g_hCoordsEdit, % Format("({},{})", g_xTarget, g_yTarget)
}
ButtonDrawGrid(CtrlHwnd, GuiEvent, EventInfo, ErrLevel:="") {
Gui %g_hGui%: Hide
Gui New, +AlwaysOnTop +ToolWindow -Caption +Hwndg_hGrid +E0x20
Gui Color, Green
g_CellHwnds := []
GuiControlGet g_cellsPerRow, , % g_hVerticalCellsSlider
GuiControlGet g_cellsPerColumn, , % g_hHorizontalCellsSlider
Loop % g_cellsPerRow
{
Row := []
Loop % g_cellsPerColumn
{
Gui Add, Progress, % ((A_Index = 1) ? "xm" : "x+m yp") " BackgroundRed HwndhCell"
Row.Push(hCell)
}
g_CellHwnds.Push(Row)
}
Hotkey *LButton, drawGrid, On
}
drawGrid() {
MouseGetPos g_leftGrid, g_topGrid
SetTimer updateGrid, 10
Hotkey *LButton, drawGrid, Off
Hotkey *LButton Up, performClick, On
}
performClick() {
SetTimer updateGrid, Off
Hotkey *LButton Up, , Off
CoordsToClick := []
for each, Row in g_CellHwnds
{
for each, hCell in Row
{
GuiControlGet cell, Pos, % hCell
CoordsToClick.Push({x: g_leftGrid + cellX + (cellW // 2), y: g_topGrid + cellY + (cellH // 2)})
}
}
Gui %g_hGrid%: Destroy
for each, CoordPair in CoordsToClick
MouseClickDrag Left, % CoordPair.x, % CoordPair.y, % g_xTarget, % g_yTarget, 2
Gui %g_hGui%: Show, NoActivate
}
updateGrid() {
MouseGetPos rightGrid, bottomGrid
widthGrid := rightGrid - g_leftGrid
heightGrid := bottomGrid - g_topGrid
static gap := 2
widthCell := (widthGrid - ((g_cellsPerColumn+1) * gap)) // g_cellsPerColumn
heightCell := (heightGrid - ((g_cellsPerRow+1) * gap)) // g_cellsPerRow
for j, Row in g_CellHwnds
for i, hCell in Row
GuiControl Move, % hCell, % Format("x{} y{} w{} h{}", (gap * i) + (widthCell * (i-1)), (gap * j) + (heightCell * (j-1)), widthCell, heightCell)
Gui %g_hGrid%: Show, % Format("x{} y{} w{} h{} NoActivate", g_leftGrid, g_topGrid, widthGrid, heightGrid)
WinSet Transparent, 80, ahk_id %g_hGrid%
}
GuiClose(GuiHwnd) {
ExitApp
}
Re: Mark screen coords then Click and drag select
@swagfag wow well done