检测单击了哪个任务栏按钮(标识目标窗口) [英] Detect which Taskbar button was clicked (identify target window)
问题描述
我试图弄清楚如何检测单击了哪个任务栏按钮.具体来说,我想编写一个脚本,通过双击其任务栏按钮可以最大化窗口.这需要知道单击了哪个任务栏按钮,而我很难找到任何线索.
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?
推荐答案
我不得不承认这是一个事实.我无法为您提供最佳实践的解决方案,但是这里有一些解决方法,也许足以满足您的目的:
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
}
在Windows 8.1上测试.
Tested on Windows 8.1.
这篇关于检测单击了哪个任务栏按钮(标识目标窗口)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!