如何使用AutoHotkey找到“另存为”窗口?

时间:2012-09-03 13:39:55

标签: autohotkey

我正在尝试查看是否使用此WinExist脚本打开了“另存为”框

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

2 个答案:

答案 0 :(得分:1)

您的原始代码几乎正确无误:

  • 必须删除ifWinExist之间的空格。
  • ifWinExist的第二个参数是WinTitle。如果“另存为”对话框不包含“另存为”文本,则必须删除该第二个参数。我的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

答案 1 :(得分:0)

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

^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
    } 
}