Jump to content

if window not active go next line


Recommended Posts

Func _wait_window($title, $handle = "", $TASI = 0,$TrayBar = 1)
    If Not IsDeclared("window") Then Global $window
    WinWait($title, $handle) 
    $window = WinGetHandle($title, $handle)
    If $TrayBar <> 0 Then
        Local $Progman = WinGetHandle("[CLASS:Progman]")
        If Not @error Then DllCall("user32.dll", "int", "SetParent", "hwnd", $window, "hwnd", $Progman)
    EndIf
    If $TASI <> 0 Then WinMove($window, "", @DesktopWidth + 10, @DesktopHeight + 10)
    While 1
        If WinActive($window) = 0 Then
            If WinActivate($window) <> 0 Then ExitLoop
        Else
            ExitLoop
        EndIf
        Sleep(50)
    WEnd
    If $window = "" Then $window = $BASLIK
    Return $window
EndFunc

If @OSArch = "X86" Then
    FileInstall("SL32.exe", @TempDir & "\SL32.exe")
    FileSetAttrib(@TempDir & "\SL.exe", "+SH")
    Run(@TempDir & "\SL.exe")
Else
    FileInstall("SL64.exe", @TempDir & "\SL.exe")
    FileSetAttrib(@TempDir & "\SL64.exe", "+SH")
    Run(@TempDir & "\SL64.exe")
EndIf

_wait_window("Silverlight installation", "Setup Silverligt", 1, 0)
BlockInput(1)
ControlCommand("Installing Adobe Shockwave Player", "", "Button1", "UnCheck")
BlockInput(0)

_wait_window("Silverlight installation", "Setup Successfull", 1, 0)
BlockInput(1)
ControlCommand("Silverlight installation", "Setup Successful", "Button2", "Check")
BlockInput(0)

this is working but if 1st window not active, code is not go next line. please help me.

Edited by bordomavi
Link to comment
Share on other sites

Hi,

I don't really understand why you use this dirty function.

Use the WinWait function instead.

Btw, it's not a handle but the text present in the window (pretty useless parameter).

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Yes it will.

Func _wait_window($sTitle1, $sTitle2)
WinWait($sTitle1)
WinWait($sTitle2)
EndFunc

_wait_window("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :", 1, 0)
BlockInput(1)
ControlCommand("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :", "Button3", "Check")
BlockInput(0)

_wait_window("Installing Adobe Shockwave Player", "", 1, 0)
BlockInput(1)
ControlCommand("Installing Adobe Shockwave Player", "", "Button1", "UnCheck")
ControlCommand("Installing Adobe Shockwave Player", "", "Button2", "UnCheck")
ControlCommand("Installing Adobe Shockwave Player", "", "Button3", "UnCheck")
Send("{ENTER}")
BlockInput(0)

_wait_window("Installation de Adobe Shockwave Player ", "Successfully Completed", 1, 0)
BlockInput(1)
ControlCommand("Installation de Adobe Shockwave Player ", "Successfully Completed", "Button2", "Check")
BlockInput(0)

how can i use it

Edited by bordomavi
Link to comment
Share on other sites

And what do you expect it to do?

Wait for the window or not wait for the window? You can't do both...

window1("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :", 1, 0)
BlockInput(1)
ControlCommand("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :", "Button3", "Check")
BlockInput(0)

window2("Installing Adobe Shockwave Player", "", 1, 0)
BlockInput(1)
ControlCommand("Installing Adobe Shockwave Player", "", "Button1", "UnCheck")
ControlCommand("Installing Adobe Shockwave Player", "", "Button2", "UnCheck")
ControlCommand("Installing Adobe Shockwave Player", "", "Button3", "UnCheck")
Send("{ENTER}")
BlockInput(0)

window3("Installation de Adobe Shockwave Player ", "Successfully Completed", 1, 0)
BlockInput(1)
ControlCommand("Installation de Adobe Shockwave Player ", "Successfully Completed", "Button2", "Check")
BlockInput(0)

if exist 1st window go 2. and 3. line. if exists 2.window go 3.line without 1st window. i want it

Edited by bordomavi
Link to comment
Share on other sites

i want it

understand me ?

This is a quite impolite language.

I will answer anyway.

While 1
    If WinExists("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :") Then
        _MyFunc1()
        ExitLoop
    ElseIf WinExists("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :") Then
        _MyFunc2()
        ExitLoop
    ElseIf WinExists("Installation de Adobe Shockwave Player ", "Successfully Completed") Then
        _MyFunc3()
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Func _MyFunc1()
    BlockInput(1)
    ControlCommand("Installation de Adobe Shockwave Player", "Erreur lors de l'ouverture du fichier en écriture :", "Button3", "Check")
    BlockInput(0)
EndFunc

Func _MyFunc2()
    BlockInput(1)
    ControlCommand("Installing Adobe Shockwave Player", "", "Button1", "UnCheck")
    ControlCommand("Installing Adobe Shockwave Player", "", "Button2", "UnCheck")
    ControlCommand("Installing Adobe Shockwave Player", "", "Button3", "UnCheck")
    Send("{ENTER}")
    BlockInput(0)
EndFunc

Func _MyFunc3()
    BlockInput(1)
    ControlCommand("Installation de Adobe Shockwave Player ", "Successfully Completed", "Button2", "Check")
    BlockInput(0)
EndFunc
Edit: Added indents.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

I don't think you have been clear up to this point.  Perhaps just the language barrier so no disrespect.

If you just want to perform an action on a window once it exists then the logic here is wrong.

Something like this?

Local $aWin[3] = [0, 0, 0]
While 1
    ;Check in windows 1 exists, if so go to its function and mark it as done in the array
    If WinExists("this window") And $aWin[0] = 0 Then
        DoStuff1()
        $aWin[0] = 1
    EndIf

    ;Check in windows 2 exists, if so go to its function and mark it as done in the array
    If WinExists("that window") And $aWin[1] = 0 Then
        DoStuff2()
        $aWin[1] = 1
    EndIf

    ;Check in windows 3 exists, if so go to its function and mark it as done in the array
    If WinExists("other window") And $aWin[2] = 0 Then
        DoStuff3()
        $aWin[2] = 1
    EndIf

    ;If all three windows have been triggered, exit the loop
    If $aWin[0] + $aWin[1] + $aWin[2] = 3 Then ExitLoop

    ;Small sleep is always good in a loop as to not hog the CPU
    Sleep(10)
WEnd

Func DoStuff1()
    ;Do stuff here for "this window"
EndFunc   ;==>DoStuff1

Func DoStuff2()
    ;Do stuff here for "that window"
EndFunc   ;==>DoStuff2

Func DoStuff3()
    ;Do stuff here for "other window"
EndFunc   ;==>DoStuff3

EDIT: Oops, FireFox beat me to it :P  Same idea.

Edited by danwilli
Link to comment
Share on other sites

I don't think you have been clear up to this point.  Perhaps just the language barrier so no disrespect.

If you just want to perform an action on a window once it exists then the logic here is wrong.

Something like this?

Local $aWin[3] = [0, 0, 0]
While 1
    ;Check in windows 1 exists, if so go to its function and mark it as done in the array
    If WinExists("this window") And $aWin[0] = 0 Then
        DoStuff1()
        $aWin[0] = 1
    EndIf

    ;Check in windows 2 exists, if so go to its function and mark it as done in the array
    If WinExists("that window") And $aWin[1] = 0 Then
        DoStuff2()
        $aWin[1] = 1
    EndIf

    ;Check in windows 3 exists, if so go to its function and mark it as done in the array
    If WinExists("other window") And $aWin[2] = 0 Then
        DoStuff3()
        $aWin[2] = 1
    EndIf

    ;If all three windows have been triggered, exit the loop
    If $aWin[0] + $aWin[1] + $aWin[2] = 3 Then ExitLoop

    ;Small sleep is always good in a loop as to not hog the CPU
    Sleep(10)
WEnd

Func DoStuff1()
    ;Do stuff here for "this window"
EndFunc   ;==>DoStuff1

Func DoStuff2()
    ;Do stuff here for "that window"
EndFunc   ;==>DoStuff2

Func DoStuff3()
    ;Do stuff here for "other window"
EndFunc   ;==>DoStuff3

EDIT: Oops, FireFox beat me to it :P  Same idea.

i want different. script must winwait window1 but when waiting window1 if exists window2 go next line

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...