问题
I am trying to figure out how to detect which Taskbar button was clicked. Specifically, I want to write a script that makes it possible to maximize a window by double-clicking its Taskbar button. That requires knowing which Taskbar button was clicked, which I am having a difficult time finding any leads on.
Does anyone know how this can be accomplished?
回答1:
That's a though one I have to admit. I can't offer you a best practice solution, but here is a little work around, maybe that enough for your purposes:
CoordMode, Mouse, Screen
~LButton::
If (A_TimeSincePriorHotkey<400) and (A_PriorHotkey="~LButton") {
WinGetPos, taskBarX, taskBarY, taskBarW, taskBarH, ahk_class Shell_TrayWnd
MouseGetPos, mouseX, mouseY
If (mouseX >= taskBarX && mouseY >= taskBarY && mouseX <= taskBarX+taskBarW && mouseY <= taskBarY+taskBarH)
OnDoubleClickTaskbar()
}
Return
OnDoubleClickTaskbar() {
;WinWaitNotActive, ahk_class Shell_TrayWnd
Sleep, 200
WinMaximize, A
}
Tested on Windows 8.1.
来源:https://stackoverflow.com/questions/31375455/detect-which-taskbar-button-was-clicked-identify-target-window