Sean,
I had found your post and was knee-deep through the code at the time of your reply. I'd just like to say that I was pretty doubtful as to how this one would work out this morning, but after wasting plenty of hours at work I've figured out the solution, thanks in no small part to Sean's heavy-lifting. I owe you a big one. I made some modifications, but the credit is all yours--thanks a lot friend!
Script to Scroll Sequentially Across Taskbar
Code:
#Persistent
#NoEnv
#NoTrayIcon
DetectHiddenWindows, On
^9:: ;forward scroll--map to any key/button
{
i = 0
WinGet, active_id, ID, A
WinGet, pid, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pid)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
SendMessage, 0x418, 0, 0, ToolbarWindow322, ahk_class Shell_TrayWnd
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow322, ahk_class Shell_TrayWnd
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
dwData := DecodeInteger(&btn +12)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := DecodeInteger(&nfo + 0)
if hWnd = 0
Continue
i++
active_hWnd%i% := hWnd
SetFormat, integer, h
active_hWnd%i% += 0
test_Handle := active_hWnd%i%
SetFormat, integer, d
%i% += 0
if test_Handle = %active_id%
{
currentHandleIndex := i
}
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
desiredHandleIndex := currentHandleIndex + 1
if desiredHandleIndex > %i%
{
desiredHandleIndex := 1
}
next_hWnd := active_hWnd%desiredHandleIndex%
WinActivate ahk_id %next_hWnd%
return
}
^8:: ;backward scroll--map to any key/button
{
i = 0
WinGet, active_id, ID, A
WinGet, pid, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pid)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
SendMessage, 0x418, 0, 0, ToolbarWindow322, ahk_class Shell_TrayWnd
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index - 1, pRB, ToolbarWindow322, ahk_class Shell_TrayWnd
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
dwData := DecodeInteger(&btn +12)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := DecodeInteger(&nfo + 0)
if hWnd = 0
Continue
i++
active_hWnd%i% := hWnd
SetFormat, integer, h
active_hWnd%i% += 0
test_Handle := active_hWnd%i%
SetFormat, integer, d
%i% += 0
if test_Handle = %active_id%
{
currentHandleIndex := i
}
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
desiredHandleIndex := currentHandleIndex - 1
if desiredHandleIndex < 1
{
desiredHandleIndex = %i%
}
next_hWnd := active_hWnd%desiredHandleIndex%
WinActivate ahk_id %next_hWnd%
return
}
DecodeInteger(ptr)
{
Return *ptr | *++ptr << 8 | *++ptr << 16 | *++ptr << 24
}
Comments are welcome--it could be more elegant, and there might be some extraneous bits still intact from Sean's f(x) calls, but I think it's pretty clean at getting the job done.
Thanks everyone!
Lac