Jump to content

While but only do once ?


zxzxzx
 Share

Recommended Posts

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]

Link to comment
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.
Link to comment
Share on other sites

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.
Link to comment
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

Link to comment
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
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
Link to comment
Share on other sites

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