Jump to content

Help for "IF" condition


Recommended Posts

Hi,

I wrote a script for a silent-install an CyberLink PowerProducer update .

Sometimes it ask to RESTART Windows sometimes NOT. Then I added a second "IF" condition, when the first "IF" condition is used for language select.

My problem is sometimes the installation never ends. It wait for the very last command ControlClick

("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")

Here bellow the entire script. Do anyone can check and correct it?

$Restart = "Redémarrage de Windows"
$Lang = RegRead("HKEY_CURRENT_USER\Control Panel\International", "sLanguage")
If $Lang = "FRA" Then

;CyberLink PowerProducer 3.0 DVD Update Installation 
Run("PowerProducer30Patch.exe")
WinWaitActive("Sélection de la langue d'installation")
sleep(1000)
Send("{ENTER}")

;Bienvenue 
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Bienvenue dans l'InstallShield Wizard de PowerProducer")
Send("!s")

;Licence
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Contrat de licence")
Send("!o")

;Installation
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation de")
Send("!s")

;Restart Windows;Button2=No;Button3=OK
    sleep(1000)
    If WinWaitActive($Restart) Then
    sleep(1000)
    ControlClick("Redémarrage de Windows", "", "Button2")
    ControlClick("Redémarrage de Windows", "", "Button3")
    
    Else
    EndIf
;Installation Finished;Button4=Finish
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée")
sleep(1000)
ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")

EndIf

Regards

coucou

Link to comment
Share on other sites

I sugest that you create a loop around your code while the PID provided by Run exists. Add winwait timeouts such that your code will continue to run checks agains diffrent windows.

Something like this:

$Restart = "Redémarrage de Windows"
$Lang = RegRead("HKEY_CURRENT_USER\Control Panel\International", "sLanguage")
If $Lang = "FRA" Then

;CyberLink PowerProducer 3.0 DVD Update Installation
$pid = Run("PowerProducer30Patch.exe")
WinWaitActive("Sélection de la langue d'installation")
sleep(1000)
Send("{ENTER}")

;Bienvenue
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Bienvenue dans l'InstallShield Wizard de PowerProducer")
Send("!s")

;Licence
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Contrat de licence")
Send("!o")

Do 
  ;Installation
   WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation de",1)
   Send("!s")

  ;Restart Windows;Button2=No;Button3=OK
       sleep(1000)
       If WinWaitActive($Restart) Then
          sleep(1000)
          ControlClick("Redémarrage de Windows", "", "Button2")
          ControlClick("Redémarrage de Windows", "", "Button3")
       
       Else
       EndIf
  ;Installation Finished;Button4=Finish
   WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée",1)
;   sleep(1000)
   ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")

Until (ProcessExists($pid) = 0) 
EndIf
Link to comment
Share on other sites

i only found 1 Else that was not needed

$Restart = "Redémarrage de Windows"
$Lang = RegRead("HKEY_CURRENT_USER\Control Panel\International", "sLanguage")
If $Lang = "FRA" Then
    
   ;CyberLink PowerProducer 3.0 DVD Update Installation
    $pid = Run("PowerProducer30Patch.exe")
    WinWaitActive("Sélection de la langue d'installation")
    Sleep(1000)
    Send("{ENTER}")
    
   ;Bienvenue
    WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Bienvenue dans l'InstallShield Wizard de PowerProducer")
    Send("!s")
    
   ;Licence
    WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Contrat de licence")
    Send("!o")
    
    Do
       ;Installation
        WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation de", 1)
        Send("!s")
        
       ;Restart Windows;Button2=No;Button3=OK
        Sleep(1000)
        If WinWaitActive($Restart) Then
            Sleep(1000)
            ControlClick("Redémarrage de Windows", "", "Button2")
            ControlClick("Redémarrage de Windows", "", "Button3")
        EndIf
       ;Installation Finished;Button4=Finish
        WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", 1)
       ;   sleep(1000)
        ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")
        
    Until (ProcessExists($pid) = 0)
EndIf

8)

NEWHeader1.png

Link to comment
Share on other sites

TNX for the loop advise.

BTW, does the "IF" conditions (overlap each other) are correctly set?

coucou

Yes, it's OK to have IF inside another IF ('nested' is the term for it). You do have an empty ELSE statement there that isn't required, but probably doesn't cause errors.

If $Color = "Red" Then
     If $Symbol = "Pointy" Then
          $Suit = "Diamonds"
     Else
          $Suit = "Hearts"
     EndIf
Else
     If $Symbol = "PuppyFeet" Then
          $Suit = "Clubs"
     Else
          $Suit = "Spades"
     EndIf
EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 2 weeks later...

Sorry for the delay i was in vacation.

I tested today the script... same problem :D

The installation never ends. It wait for the very last command ControlClick

("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")

BTW, by using "Windows Task Manager" to see what process handle this installation,

right click on the application "PowerProducer30Patch.exe" and select "Go to Proceess"... the process is "ikernel.exe"... strange

Anyone can help?

Regards

coucou

Edited by coucou
Link to comment
Share on other sites

It's a timout on

WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", 1)
       ;   sleep(1000)
        ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")oÝ÷ Ù8^Z)Öj+@r¸¯yƧ«Þ}¨¥yÒØZ³*.v÷öضØ^rX«­¢+Ù%]¥¹]¥ÑÑ¥Ù ÅÕ½Ðí%¹Íѱ±Ñ¥½¸
åÉ1¥¹¬A½ÝÉAɽÕÈ̸ÀYAÑ ÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±Ñ¥½¸Ñɵ¥»¥ÅÕ½Ðì°Ä¤Q¡¸(ìͱÀ ÄÀÀÀ¤(
½¹Ñɽ±
±¥¬ ÅÕ½Ðí%¹Íѱ±Ñ¥½¸
åÉ1¥¹¬A½ÝÉAɽÕÈ̸ÀYAÑ ÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±Ñ¥½¸Ñɵ¥»¥ÅÕ½Ðì°ÅÕ½Ðí   ÕÑѽ¸ÐÅÕ½Ðì¤)¹%
Link to comment
Share on other sites

So what happens?

Do you ever get to the line?

ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")oÝ÷ Øò¢çhjwm«ew¡ë'¢Ü(®Kaz{az·¢²èm¦åÊÊ&¶§
è"¶­"{Þ²Ø j×­ì"Ú0Â+aíÈúÛz'íç(ÚèZ®¢Ðn¶Ú'⫨¶·(¬¶«xƲm쨺ÈhºWn±ëaz{¦z¸
í®Hêæk&ÞÊ¡j÷­¢Ç­~.²Ú-ç(Úè©Ý¶§ë-ºÇ¬zwS+!jÈZ¦§vÚ&y·¢·*.v÷ö×hʽêàzÖ°whíױµ©Ý¶+ezX¤zØb±«­¢+Ù]¥¹á¥ÍÑÌ ÅÕ½Ðí%¹Íѱ±Ñ¥½¸
åÉ1¥¹¬A½ÝÉAɽÕÈ̸ÀYAÑ ÅÕ½Ðì°ÅÕ½Ðí%¹Íѱ±Ñ¥½¸Ñɵ¥»¥ÅÕ½Ðì

Appart from this I'm all out of ideas :D

Link to comment
Share on other sites

Ok,

Here my last test.

As in this time the installation NOT ask for the restart, I put a comma in front of all the second "IF" sequence (see here bellow)... It works just fine

$Restart = "Redémarrage de Windows"
$Lang = RegRead("HKEY_CURRENT_USER\Control Panel\International", "sLanguage")
If $Lang = "FRA" Then

;Installation de CyberLink PowerProducer 3.0 DVD Patch
Run("PowerProducer30Patch.exe")
WinWaitActive("Sélection de la langue d'installation")
sleep(1000)
Send("{ENTER}")

;Bienvenue 
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Bienvenue dans l'InstallShield Wizard de PowerProducer")
Send("!s")

;Licence
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Contrat de licence")
Send("!o")

;Installation
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation de")
Send("!s")

;;Redémarrage de Windows;Button2=Non, je redémarrerai mon ordinateur plus tard;Button3=OK
;   sleep(1000)
;   If WinWaitActive($Restart) Then
;;WinWaitActive("Redémarrage de Windows", "L'assistant d'installation a terminé la copie")
;   sleep(1000)
;   ControlClick("Redémarrage de Windows", "", "Button2")
;   ControlClick("Redémarrage de Windows", "", "Button3")
;   
;   Else
;   EndIf

;Installation terminée;Button4=Terminée
WinWaitActive("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée")
sleep(1000)
ControlClick("Installation de CyberLink PowerProducer 3.0 DVD Patch", "Installation terminée", "Button4")

EndIf

I stay puzzeled, don't know what to do if the installation ask for the restart :D:D:P

Regards

coucou

Link to comment
Share on other sites

If you are asked for a restart and the installation will continue with dialogs after the restart your script should place itself in [HKCU|HKCM]\Software\Microsoft\Windows\CurrentVersion\RunOnce in the registry and continue to run after the restart. You might want to add some logic and commandline switches to skip the part that is already covered.

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...