Sign in to follow this  
Followers 0
zxzxzx

While but only do once ?

14 posts in this topic

This is my script

While 1

If WinExists('Untitled') Then
    MsgBox(0, '1', 'Once')
EndIf

WEnd

I want it in loop but i want when Untitled appear, it will do MsgBox once.

I can't

Can you help me or give script?

Thanks

Share this post


Link to post
Share on other sites



While 1

If WinExists('Untitled') Then
    MsgBox(0, '1', 'Once')
    ExitLoop
EndIf

WEnd


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites

This is my script

While 1

If WinExists('Untitled') Then
    MsgBox(0, '1', 'Once')
EndIf

WEndoÝ÷ ØØ­yh¢î¶,Ü!zu'¶+eyÖ©¥æ«Ü"Wh2È£'qâj}ý´&§Ê¡zZfzà÷¬r¸©µ8ZK?ªê-y'ûaÌ(®K¢¼¨¹«­¢+Ù]¡¥±Ä()%]¥¹á¥ÍÑÌ ÌäíU¹Ñ¥Ñ±Ìäì¤Q¡¸(5Í   ½à À°ÌäìÄÌäì°Ìäí=¹Ìäì¤(á¥Ñ1½½À)¹%()]¹

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

AdlibEnable("ceck")

Func ceck()

If WinExists('Untitled') Then

MsgBox(0, '1', 'Once')

adlibdisable()

endif

endfunc

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

When MsgBox do once. Script exit!

I don't want it exit. How to?

Thanks

Then you need to have whatever else the script is doing in side the While 1 loop or out side of it if there are other commands. Since there is nothing else to process, it will of course exit the script. It would be more helpful it you either posted more code or explained more of what you are trying to accomplish.

Edit: Actually I am mistaken, it should continue the loop until you close the script. However it will continue to keep prompting a msg box when that window is open as you have it now.

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

Test this, then :

$notepad_handle = 0

While 1
    If $notepad_handle <> WinGetHandle ('Untitled') AND WinGetHandle ('Untitled') <> 0 Then
        MsgBox(0, '1', 'Once')
        $notepad_handle = WinGetHandle ('Untitled')
    EndIf
WEnd

It gets confused when 2 notepads are opened, when the second closes it finds the first again, but I'm trying to keep it simple :P

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Test this, then :

$notepad_handle = 0

While 1
    If $notepad_handle <> WinGetHandle ('Untitled') AND WinGetHandle ('Untitled') <> 0 Then
        MsgBox(0, '1', 'Once')
        $notepad_handle = WinGetHandle ('Untitled')
    EndIf
WEndoÝ÷ Ø`zÛ¢wî±çpéö^¥§lj·¨¥éÞw^Ø^±ç(×%¢Ç¬×âÛ-çâ®ËZ¨§nëHßÙ­¯(§Ú$yêb¶È¦¦Wþ«¨µê!¶§*.½êòç!"Ýý²÷«Êë~éCJ.Ö®¶­sbb33c¶æ÷FWEöæFÆRÒ ¥vÆR bb33c¶æ÷FWEöæFÆRfÇC²fwC²väW7Bb33µVçFFÆVBb33²äBväW7Bb33µVçFFÆVBb33²fÇC²fwC²FVà ×6t&÷Âb33³b33²Âb33´öæ6Rb33² b33c¶æ÷FWEöæFÆRÒväW7Bb33µVçFFÆVBb33² VæD`¥tVæ@
Edited by zxzxzx

Share this post


Link to post
Share on other sites

Wow, all these replies and nobody suggested WinWait?

WinWait('Untitled')
MsgBox(0, '1', 'Once')

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Wow, all these replies and nobody suggested WinWait?

WinWait('Untitled')
MsgBox(0, '1', 'Once')
Wow, all these replies and you still didn't use an infinite loop like we did ?

Share this post


Link to post
Share on other sites

Wow, all these replies and nobody suggested WinWait?

WinWait('Untitled')
MsgBox(0, '1', 'Once')

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I thought maybe the title was important for the original poster, that's why I used it.

But your adaptation is cool also.

And it would be a good optimization to replace the 3 ProcessExists with 1 and just save as an extra variable. To ease up on CPU usage I guess. It's in a loop after all :P

Edited by Inverted

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