It's actually the Caret that blinks, rather than the cursor. The difference made me think to try this:
Code: Select all
#SingleInstance
#Requires AutoHotkey v2+
#+q::
{ CaretGetPos(&cX, &cY)
msgbox 'x ' cX '`ny ' cY
}
The idea was that if no caret pos was returned, it meant no blinking caret
But the blasted thing doesn't seem to work in web edit fields!
Here also is a chunk of code that I was using with my above-mentioned boilerplate tool..
Code: Select all
;Check for active edit field.
ThisSec := SubStr(A_Sec, -1)
Send ThisSec "+{Left}" ; Type the single digit, then select it.
Send '^x' ; Cut to clipboard.
Sleep 500
If (Trim(A_Clipboard,"`n`r ") != ThisSec) ; Compare, to see if item was typed/copied.
It types a "random" digit, then selects, and cuts the digit to the clipboard and checks to see if the clipboard contains the digit. If there's no active edit box, then for digit doesn't get typed, and so doesn't appear on the clipboard.
It's a really kludgy and awkward thing thing though. So bad that I stopped using it.
If a person was an HTML wizard they might have some ideas too. I don't know anything about HTML though. Also, as I think, Boiler pointed out, different website might have different code, so relying on HTML stuff might be unreliable too.
EDIT: Actually... Here are better testable versions of the above things. The "compare to clipboard" one actually does work really well in webforms. I don't know that it will be a good solution for you though, since your hotkeys (1 and 2) are also things that would get typed. You wouldn't want this whole bit of code running every time you typed a 1 or 2.
Code: Select all
#SingleInstance
#Requires AutoHotkey v2+
#+w::
{
;Check for active edit field.
ThisSec := SubStr(A_Sec, -1)
Send "{Right} " ThisSec "+{Left}" ; Type the single digit, then select it.
Send '^x' ; Cut to clipboard.
Sleep 200
If (Trim(A_Clipboard,"`n`r ") != ThisSec) ; Compare, to see if item was typed/copied.
Msgbox 'No active edit box'
Else
Msgbox 'Yes active edit box'
}
#+q::msgbox 'car? ' CaretGetPos()
My advice is to use a modifier with your hotkeys. For example
^1:: and
^2::.