Jump to content

Advise for a Loop Statement


coucou
 Share

Recommended Posts

Hi,

I buid the here bellow a small AutoInstall file. It shoulld work, but time to time one of the window or both doesn't close (WinClose).

May someone advise how to use a Loop Statement. Something like

Do (the Winclose)

Until (the window is closed)

Run("exeicosetup.exe /S")
sleep(2000)

If WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer") Then
WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
EndIf

sleep(1000)
If WinExists("C:\Program Files\ExeIco\Readme.txt - Notepad") Then
WinClose("C:\Program Files\ExeIco\Readme.txt - Notepad")
EndIf
Regards

coucou

Link to comment
Share on other sites

  • Moderators

If the windows always open then you could use this:

Run("exeicosetup.exe /S")
WinWait("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
WinWait("C:\Program Files\ExeIco\Readme.txt - Notepad")
WinClose("C:\Program Files\ExeIco\Readme.txt - Notepad")
Link to comment
Share on other sites

Hi,

I buid the here bellow a small AutoInstall file. It shoulld work, but time to time one of the window or both doesn't close (WinClose).

May someone advise how to use a Loop Statement. Something like

Do (the Winclose)

Until (the window is closed)

Run("exeicosetup.exe /S")
sleep(2000)

If WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer") Then
WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
EndIf

sleep(1000)
If WinExists("C:\Program Files\ExeIco\Readme.txt - Notepad") Then
WinClose("C:\Program Files\ExeIco\Readme.txt - Notepad")
EndIf
Regards

coucou

try something like this

While WinExists("windowname")
 WinClose("windowname")
Wend

that will close that window, until no windows with that name exist.

Link to comment
Share on other sites

Opt('WinTitleMatchMode', 2)
$pid = Run("exeicosetup.exe /S")
sleep(2000)
While ProcessExists($pid)
    If WinExists("Executable File Icons Changer") Then
        WinClose("Executable File Icons Changer")
    EndIf
    sleep(1000)
    If WinExists("Readme.txt - Notepad") Then
        WinClose("Readme.txt - Notepad")
    EndIf
WEnd
Sleep(2000)

This will cover the duration of the installation. SubString setting for window titles may make it easier also.

Link to comment
Share on other sites

TNX all,

Yr advises certainly works, I received them after solving the problem.

Here my file

Run("exeicosetup.exe /S")
sleep(2000)

$1 = WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
$2 = ProcessExists("notepad.exe")

Do
   If $1 = 1 OR $2 = 1 Then
    WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
    sleep(2000)
    ProcessClose("notepad2.exe")

   EndIf

Until $1 = 0 AND $2 = 0

Regards

coucou

Link to comment
Share on other sites

TNX all,

Yr advises certainly works, I received them after solving the problem.

Here my file

Run("exeicosetup.exe /S")
sleep(2000)

$1 = WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
$2 = ProcessExists("notepad.exe")

Do
   If $1 = 1 OR $2 = 1 Then
    WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
    sleep(2000)
    ProcessClose("notepad2.exe")

   EndIf

Until $1 = 0 AND $2 = 0

Regards

coucou

wouldnt you need to put in a check to see if the process or window still exist after you have done the close otherwise $1 and $2 would still be 1 ???

for example putting in the winexists and process exists after your endif ? or do i have the whole thing messed up ?

Link to comment
Share on other sites

  • Moderators

wouldnt you need to put in a check to see if the process or window still exist after you have done the close otherwise $1 and $2 would still be 1 ???

for example putting in the winexists and process exists after your endif ? or do i have the whole thing messed up ?

Until $1 = 0 AND $2 = 0
Won't leave the loop until the statement is true.

Edit:

Do
   If WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer") OR ProcessExists("notepad.exe") Then
    WinClose("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer")
    Sleep(2000)
    ProcessClose("notepad2.exe")
   EndIf
Until Not WinExists("C:\Documents and Settings\Administrator\Start Menu\Programs\Executable File Icons Changer") AND Not ProcessExists("notepad.exe")
Is basically what they are trying to do. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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