XavierGr wrote:
Sean, do you know if it is possible to get the idx for a task button that is under the mouse?
Yes using
TB_HITTEST. I think lexicos uses it in his mouse-hover script:
http://www.autohotkey.com/forum/viewtopic.php?t=22763
BTW, if
TB_GETHOTITEM is enough in your test, you may use it instead as it's simpler to use.
Code:
MsgBox, % GetHotItem() . " | " . HitTest()
Return
GetHotItem()
{
idxTB := GetTaskSwBar()
SendMessage, 0x447, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETHOTITEM
Return ErrorLevel << 32 >> 32
}
HitTest()
{
idxTB:= GetTaskSwBar()
ControlGet, hWnd, hWnd,, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd
WinGet, pid, PID, ahk_id %hWnd%
hProc:= DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pid)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 8, "Uint", 0x1000, "Uint", 0x4)
DllCall("GetCursorPos", "int64P", pt)
DllCall("ScreenToClient", "Uint", hWnd, "int64P", pt)
DllCall("WriteProcessMemory", "Uint", hProc, "Uint", pRB, "int64P", pt, "Uint", 8, "Uint", 0)
idx := DllCall("SendMessage", "Uint", hWnd, "Uint", 0x445, "Uint", 0, "Uint", pRB) ; TB_HITTEST
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle" , "Uint", hProc)
Return idx
}