(I finally got round to a solution for the question I posted last year at https://autohotkey.com/boards/viewtopic ... 17&t=38867)
When you press NumKeyEnter, this script builds then displays a 26*26 grid of buttons (actually AHK edit controls), labelled AA-ZZ, overlaying the whole screen.
You can then emulate a mouse-click (or a touchscreen 'touch') at any of those 676 locations by entering the coordinates, as displayed on each button, as keyboard shortcuts.
Pressing NumKeyEnter thereafter toggles the grid (it displays much faster after the first time, as it has already been built)
Inspired by the cVim chrome plugin, which provides shortcut keys to most links / buttons on web pages.
Includes code around timing of key presses which 'scriptor' (thanks!) posted here:
https://autohotkey.com/board/topic/1165 ... -question/
This is quite a blunt instrument:
- you won't always be able to click on everything you need to
- on any given screen, most buttons will probably not be useful
But as somebody who likes to avoid using the mouse, I already find it useful - I hope others will too.
You could even look at it as an accessibility tool.
There are a few things I'd like to improve:
- There's a trade-off between minimizing the size of the buttons so as not to obscure what's behind them, and keeping them big enough to read. This may take more tweaking
- I chose 'Edit' controls as buttons as their white background made them easy to read.
But this means they can be typed over.
- I might add coordinates 0-9 for screens with more pixels
- As most clicking activity tends to happen round the edges of the screen and not in the middle, I might look at reducing the row / column spacing round the edges only
- I've only tried this on 2 monitors. I might need to tweak the small values added and subtracted from the coordinates to ensure that the click is sent as close to the centre of each button as possible, and also the colSpacing constant.
I've attached a screenshot showing the grid overlaying a Notepad++ window, part of a Chrome window, and part of my desktop.
Code: Select all
#SingleInstance
DetectHiddenWindows, On
VerticalScale := 1
numberOfRows := 26
numberOfCols := 26
GridHeight := VerticalScale * A_ScreenHeight
GridWidth := A_ScreenWidth
rowSpacing := GridHeight / numberOfRows
colSpacing := 1.025 * GridWidth / numberOfCols
AscA := 97
KeyArray := ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
#IfWinNotActive CoordGrid
#IfWinNotExist CoordGrid
global VerticalScale, numberOfRows, numberOfCols, GridHeight, GridWidth, rowSpacing, colSpacing, KeyArray
NumpadEnter::
; Display Coordinates
rowCounter := 0
Loop {
rowYCoord := (numberOfRows - 1 - rowCounter) * rowSpacing ;
rowYCoordAlpha := KeyArray[rowCounter+1]
StringUpper, rowYCoordAlpha, rowYCoordAlpha
colCounter := 0
Loop {
colXCoord := colCounter * colSpacing
colXCoordAlpha := KeyArray[colCounter+1]
StringUpper, colXCoordAlpha, colXCoordAlpha
; gui, add, edit, x%colXCoord% y%rowYCoord% ReadOnly cRed, %colXCoordAlpha%%rowYCoordAlpha%
gui, add, edit, x%colXCoord% y%rowYCoord%, %colXCoordAlpha%%rowYCoordAlpha%
colCounter := colCounter + 1
}
Until colCounter = numberOfcols
rowCounter := rowCounter + 1
}
Until rowCounter = numberOfRows
Gui, Color, 000115
Gui, Show, W%GridWidth% H%GridHeight%, CoordGrid
Gui -Caption +AlwaysOnTop
Gui, maximize
WinSet, Transcolor, 000115, CoordGrid
Return
#IfWinNotExist
#IfWinNotActive
#IfWinExist CoordGrid
#IfWinNotActive CoordGrid
NumpadEnter::
Gui Show
Return
#IfWinNotActive
#IfWinExist
#IfWinActive CoordGrid
NumpadEnter::
Gui Hide
Return
~a:: gosub, RunKey
~b:: gosub, RunKey
~c:: gosub, RunKey
~d:: gosub, RunKey
~e:: gosub, RunKey
~f:: gosub, RunKey
~g:: gosub, RunKey
~h:: gosub, RunKey
~i:: gosub, RunKey
~j:: gosub, RunKey
~k:: gosub, RunKey
~l:: gosub, RunKey
~m:: gosub, RunKey
~n:: gosub, RunKey
~o:: gosub, RunKey
~p:: gosub, RunKey
~q:: gosub, RunKey
~r:: gosub, RunKey
~s:: gosub, RunKey
~t:: gosub, RunKey
~u:: gosub, RunKey
~v:: gosub, RunKey
~w:: gosub, RunKey
~x:: gosub, RunKey
~y:: gosub, RunKey
~z:: gosub, RunKey
Runkey:
if winc_presses > 0
{
winc_presses += 1
Return
}
winc_presses = 1
SetTimer, TheKey, 1000
Return
TheKey:
SetTimer, TheKey, off
if winc_presses = 2
{
NavigateToCoord()
}
winc_presses = 0
Return
NavigateToCoord()
{
CoordMode, Mouse, Window
global VerticalScale, numberOfRows, numberOfCols, GridHeight, GridWidth, rowSpacing, colSpacing
XCoordInput := SubStr(A_PriorHotkey,2,1)
YCoordInput := SubStr(A_ThisHotkey,2,1)
XCoordToUse := ConvertInputCoord(XcoordInput, "X")
YCoordToUse := ConvertInputCoord(YcoordInput, "Y")
XCoord := (XCoordToUse+0.2) * colSpacing
YCoord := (YCoordToUse-0.7) * rowSpacing
MouseMove, %XCoord%, %YCoord%
sleep, 100
Gui Hide
Click
Return
}
ConvertInputCoord(coordInput, XorY)
{
global AscA
coordAsc := Asc(coordInput)
if (XorY = "X") {
coordToUse := coordAsc - AscA
}
else {
coordToUse := numberOfRows - (coordAsc - AscA)
}
coordToUse := floor(coordToUse)
Return coordToUse
}
#IfWinActive