3

我试图找出是否有一个“另存为”框打开这个WinExist脚本

if WinExist,Save As,Save As
MsgBox, is there
else
MsgBox, is not there
4

2 回答 2

4

您的原始代码几乎是正确的:

  • if和之间的空格WinExist必须去掉。
  • 的第二个参数ifWinExistWinTitle。如果“另存为”对话框不包含文本“另存为”,则必须删除第二个参数。在我的具有英语(澳大利亚)区域设置的 Windows 7 系统上就是这种情况。

工作示例:

; ifWinExist command
ifWinExist, Save As
    MsgBox, is there
else
    MsgBox, is not there

; if(expression) and WinExist() function
if WinExist("Save As")
    MsgBox, is there
else
    MsgBox, is not there

您还可以组合条件:

ifWinExist, Save As ahk_class #32770
于 2012-11-04T01:41:53.190 回答
2

假设它是一个操作系统的窗口,我会做类似的事情,

^F1::       ;press Control + F1 to serch the window.
    if FindWindow()
        msgbox Found
    else
        msgbox Not Found
Return

FindWindow(strPartOfTitle="Save", strClass="#32770") {

    if (hWnd := WinExist("ahk_class " . strClass)) 
    {
        WinGetTitle, strWinTitle, ahk_id %hWnd%
        if InStr(strWinTitle, strPartOfTitle) 
            return true
        else
            return false
    } 
}
于 2012-09-04T20:09:18.030 回答