我正在尝试使用以下脚本来显示/隐藏Windows的Slack桌面应用程序:
DetectHiddenWindows, Off
Process, Exist, slack.exe
slackPid = %ErrorLevel%
IfWinNotExist, ahk_pid %slackPid%
{
WinShow, ahk_pid %slackPid%
}
Else
{
WinHide, ahk_pid %slackPid%
}
WinHide
部分正常运行,但WinShow
未显示应用程序,但正确检索了%slackPid
。
我尝试了WinShow
,WinActivate
和WinRestore
的每个组合都没有成功。
这个脚本通常有效,但它失败了,类ahk_class Chrome_WidgetWin_1
的窗口:我用VS代码和Rocket.Chat +尝试了它们,它们也是构建在Electron上的应用程序,它也失败了。
答案 0 :(得分:1)
使用进程标识符(PID)可以识别多个窗口。 要找到它,请尝试以下AHK代码:
F1::
list := ""
numberOfwindows := ""
wins := ""
Index := ""
wins2 := ""
Process, Exist, slack.exe
slackPid = %ErrorLevel%
IfWinExist, ahk_pid %slackPid%
WinHide, ahk_pid %slackPid%
Else
{
DetectHiddenWindows, On
WinGet, id, list, ahk_pid %slackPid%
Loop, %id%
{
numberOfwindows := A_Index
this_ID := id%A_Index%
WinGetTitle, title, ahk_id %this_ID%
WinGetClass, class, ahk_id %this_ID%
wins .= A_Index . ")`ntitle = " title "`n" "ahk_class =" " " class ? A_Index . ")`ntitle = " title "`n" "ahk_class =" " " class "`n`n" : ""
If (title = "")
continue
WinGet, exStyle, exStyle, ahk_id %this_ID%
If !(exStyle & 0x100)
continue
Index++
wins2 .= Index . ")`ntitle = " title "`n" "ahk_class =" " " class ? Index . ")`ntitle = " title "`n" "ahk_class =" " " class "`n`n" : ""
WinShow, ahk_id %this_ID%
}
MsgBox, number of slack windows = %numberOfwindows%`n`n%wins%`n`nnumber of slack windows with title = %Index%`n`n %wins2%
}
return
在代码中将“slack”替换为“chrome”以将其用于Chrome。