如何处理最近打开的窗口自动?

时间:2014-02-12 09:09:45

标签: autoit

我正在尝试自动化应用程序的测试。打开应用程序时,它可能会打开一个弹出窗口或安全警报,我想处理它。那么有没有办法在AutoIt中获取最近打开的窗口的句柄或标题?

2 个答案:

答案 0 :(得分:3)

也许您需要添加一些选项。 WinSearchChildren ......

包括

Example()

Func Example()
    ; Retrieve the window title of the active window.
    Local $sText = WinGetTitle("[ACTIVE]")

    ; Display the window title.
    MsgBox($MB_SYSTEMMODAL, "", $sText)
EndFunc   ;==>Example

答案 1 :(得分:0)

当我需要看到一个窗口时,我遇到了这个问题" flash"每隔60秒就会抓住焦点,然后再回到原来的窗口。我能够写下以下内容并捕获高中山。

    ;what is the current active window

$Win1 = ""
$Win2 = ""
$Win3 = ""
$Win4 = ""
$Win5 = ""
$Win6 = ""


HotKeySet("{F1}","myExit")

while(1)
   $blah = WinGetTitle("[ACTIVE]")
   if $blah <> $Win1 Then
      $Win6 = $Win5
      $Win5 = $Win4
      $Win4 = $Win3
      $Win3 = $Win2
      $Win2 = $Win1
      $Win1 = $blah
   EndIf
   ToolTip("Last Active Windows: [press F1 to quit]" & @CRLF & "-" & $Win1 & @CRLF & "-" & $Win2 & @CRLF & "-" & $Win3 & @CRLF & "-" & $Win4 & @CRLF & "-" & $Win5 & @CRLF & "-" & $Win6)
   sleep(100)
WEnd

Func myExit()
   msgbox(0,"closing","closing program")
   Exit
EndFunc