Sign in to follow this  
Followers 0
JohnS

Two While-WEnd in the same script

5 posts in this topic

#1 ·  Posted (edited)

Hi all.

I know nothing about scripting in Autoit, so I searched in the forum here and there and joined two pieces of code that work isolated but when I put them together don't.

My friend likes and uses a file sharing program called Piolet, that opens a publicity popup in IE every 20 seconds or so.

So I want:

1-That the script closes the popups;

2-That the script ends when Piolet closes.

But only 1 is executing, although I have tested 1 and 2 separatly with sucess.

Can someone help, please?

Thank you,

John

Opt("WinTitleMatchMode", 4)

Run("C:\Programas\Piolet\Piolet.exe", "")
WinWait("Piolet")

; Close Internet Explorer popups
While 1
    Sleep(20000)
    If WinExists("classname=IEFrame") Then
        WinKill("classname=IEFrame")
    EndIf
WEnd
; Wait until Piolet closes
$_ProcessName = 'Piolet.exe'
While 1
    If Not ProcessExists ( $_ProcessName ) Then Exit
    Sleep ( 750 )
WEnd
Edited by JohnS

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I haven't tested this, but I think it should work ok..

Opt("WinTitleMatchMode", 4)

Run("C:\Programas\Piolet\Piolet.exe", "")
WinWait("Piolet")

$_ProcessName = 'Piolet.exe'

While 1
    If Not ProcessExists ( $_ProcessName ) Then Exit
    If WinExists("classname=IEFrame") Then WinKill("classname=IEFrame")
    Sleep(100)
WEnd
Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

; Close Internet Explorer popups
While 1
    Sleep(20000)
    If WinExists("classname=IEFrame") Then
        WinKill("classname=IEFrame")
    EndIf
WEnd

The "while" always is true without any condition to exit. In the script of somdcomputerguy there is a condition to exit the while. And one While is good enough :-)

Just to give you some hints where you start to search the help file for some more details:

While, Exitloop

Edited by Tankbuster

Share this post


Link to post
Share on other sites

Thank you somdcomputerguy.

Your script works.

Tankbuster:

I tried to learn and what you say makes sense: there is no need for the if-then.

So I tried this, but it doesn't work:

While 1
    WinExists("classname=IEFrame")
    WinKill("classname=IEFrame")
    Sleep(1000)
WEnd

Share this post


Link to post
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
Sign in to follow this  
Followers 0