7

同時に可能かどうか知りたいですWinWaitActive。コマンドを実行していますが、接続に失敗したことを通知するウィンドウが表示されるか、ユーザー/パスダイアログが表示される可能性があります。WindowWithThisTitleWindowWithThatTitle

このようにそれを行う別の方法はありますか?

WinWaitActive("Title1", "", 5)
If(WinExists("Title1")) Then
 MsgBox(0, "", "Do something")
Else
 If(WinExists("Title2")) Then
  MsgBox(0, "", "Do something else")
 EndIf
EndIf

15秒を超える可能性のあるタイムアウトを設定したくないためです。

4

5 に答える 5

5

このようなものはどうですか。

$stillLooking = True
While $stillLooking
    $activeWindowTitle = WinGetTitle(WinActive(""))
    If $activeWindowTitle == "Title1" Then
        MsgBox(0, "", "Do something")
        $stillLooking = False
    ElseIf $activeWindowTitle == "Title2" Then
        MsgBox(0, "", "Do something else")
        $stillLooking = False
    EndIf
    sleep(5)
WEnd

15秒を超える可能性のあるタイムアウトを持ちたくないからです。

WinWaitActive()指定しない限り、タイムアウトはありません。5 秒のタイムアウトを指定しましたが、それをオフのままにしておくと、永遠に待機することになります。

于 2010-08-14T00:49:41.437 に答える
2

この関数は 2 つのウィンドウで使用できます。

; #FUNCTION# ====================================================================================================================
; Name...........: _2WinWait
; Description ...: Wait For Tow Windows .
; Syntax.........: _2WinWait ($FirstTitle,$SecondTitle,[$FirstText = "" ,[$SecondText = ""]] )
; Parameters ....: $FirstTitle  - Title Of First  Wondow 
;                  $SecondTitle - Title Of Second Wondow 
;                  $FirstText   - Text  Of First  Wondow 
;                  $SecondText  - Text  Of Second Wondow 
; Return values .: Success - None
;                  Failure - Returns a 0 => If Your Titles Is Wrong
; Author ........: Ashalshaikh : Ahmad Alshaikh
; Remarks .......: 
; Related .......:
; Link ..........;
; Example .......; No
; ===============================================================================================================================
Func _2WinWait ($FirstTitle,$SecondTitle,$FirstText = "" ,$SecondText = "" )
    If $FirstTitle = "" Or $SecondTitle = "" Then
        Return 0 
    Else
        Do 
        Until WinExists ($FirstTitle,$FirstText) Or WinExists ($SecondTitle,$SecondText)
    EndIf
EndFunc


; #FUNCTION# ====================================================================================================================
; Name...........: _2WinWait_Any 
; Description ...: Wait For Tow Windows And Return Any Window Id Exists .
; Syntax.........: _2WinWait_Any ($FirstTitle,$SecondTitle,[$FirstText = "" ,[$SecondText = ""]] )
; Parameters ....: $FirstTitle  - Title Of First  Wondow 
;                  $SecondTitle - Title Of Second Wondow 
;                  $FirstText   - Text  Of First  Wondow 
;                  $SecondText  - Text  Of Second Wondow 
; Return values .: Success - Number Of Window ==> 1= First Window , 2= Second Window
;                  Failure - Returns a 0 => If Your Titles Is Wrong
; Author ........: Ashalshaikh : Ahmad Alshaikh
; Remarks .......: 
; Related .......:
; Link ..........;
; Example .......; No
; ===============================================================================================================================
Func _2WinWait_Any ($FirstTitle,$SecondTitle,$FirstText = "" ,$SecondText = "" )
    If $FirstTitle = "" Or $SecondTitle = "" Then
        Return 0 
    Else
        Do 
        Until WinExists ($FirstTitle,$FirstText) Or WinExists ($SecondTitle,$SecondText)
        If WinExists ($FirstTitle,$FirstTexit) Then 
            Return 1 
        Else
            Return 2 
        EndIf
    EndIf
EndFunc

詳細については、例を参照してください

于 2010-10-03T18:55:19.583 に答える
1

私はautoitとプログラミングの世界全般にかなり慣れていないので、これと同じジレンマを抱えていました。幸いなことに、私はそれを行うためのまっすぐな方法を見つけました:

Do
$var1 = 0
If  WinGetState("Document Reference","")    Then
    $var1 = 1
ElseIf  WinGetState("Customer Search","")   Then
    $var1 = 1
EndIf
Until $var1 = 1

$var1そのため、ウィンドウが検出されて に設定されるまで、ループにとどまります1。おそらくもっと簡単な方法があります (開発者はこれに息を呑んでいると思います) が、これは私にとっては正攻法で十分です。

于 2012-02-27T18:16:25.303 に答える
0

そこに if ステートメントを使用して、無限の while ループを作成できます。

#include <MsgBoxConstants.au3>

Example()

Func Example()
    While 1
        ; Test if the window exists and display the results.
        If WinExists("Windows Security") Then
            Local $hWnd = WinWaitActive("Windows Security", "", 2000)
            ControlSetText($hWnd, "", "[CLASS:Edit; INSTANCE:1]", "hel233")
            ControlClick("Windows Security","","[CLASS:Button; INSTANCE:2]")
            Sleep(5000)
        EndIf

        ; Test if the window exists and display the results.
        If WinExists("Spread the Word") Then
            'The line below will wait until the window is active, but we don't need that
            'Local $hWnd = WinWaitActive("Spread the Word", "", 2000)
            WinClose("Spread the Word")
            Sleep(5000)
        EndIf



    wend
EndFunc
于 2015-12-14T18:00:55.857 に答える