Determine which button on the taskbar was clicked (specify the target window)

I am trying to figure out how to determine which button on the taskbar was pressed. Specifically, I want to write a script that allows you to maximize a window by double clicking its button on the taskbar. This requires knowing which taskbar button was clicked and I am having a hard time finding any conclusions.

Does anyone know how this can be done?

+3


source to share


1 answer


It is though I must admit. I can't offer you a better solution, but here's a bit of work, maybe that's 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.

+1


source







All Articles