WinShow 不适用于 ahk_class Chrome_WidgetWin_1
WinShow not working for ahk_class Chrome_WidgetWin_1
我正在尝试使用以下脚本 show/hide 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
的所有组合,但都没有成功。
此脚本通常有效,但它因 class ahk_class Chrome_WidgetWin_1
的 windows 而失败:我用 VS 代码和 Rocket.Chat+ 尝试过,它们也是应用程序构建在 Electron 上,它也失败了。
可能不止一个windows可以使用进程标识符(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。
我正在尝试使用以下脚本 show/hide 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
的所有组合,但都没有成功。
此脚本通常有效,但它因 class ahk_class Chrome_WidgetWin_1
的 windows 而失败:我用 VS 代码和 Rocket.Chat+ 尝试过,它们也是应用程序构建在 Electron 上,它也失败了。
可能不止一个windows可以使用进程标识符(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。