Sign in to follow this  
Followers 0
i542

Muliple Whiles...is it possible?

13 posts in this topic

Hi! Is possible to I have more than one While active? For example, checking for tray actions while GUI is runned, and active, too. Help me, please!

i542

My English is maybe bad because I'm from Croatia...


I can do signature me.

Share this post


Link to post
Share on other sites



Hi! Is possible to I have more than one While active? For example, checking for tray actions while GUI is runned, and active, too. Help me, please!

i542

My English is maybe bad because I'm from Croatia...

Have you tried using Adlib?

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites
:D what Adlib???

I can do signature me.

Share this post


Link to post
Share on other sites

Aw....that Adlib! No. Send me example, please.


I can do signature me.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Aw....that Adlib! No. Send me example, please.

Look up AdlibEnable in the help file, but this will give you an idea. Notice that the script is stuck in an endless loop (just sleeping) until the notepad window is closed. However, every 250ms, it is checking to see if there's a dialog box asking if you want to save. If there is, it sends "n", allowing notepad to close and the script to exit. So run this script, wait a few seconds, then close notepad. You'll see the dialog pop up, then disappear as notepad closes, having not saved.

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
AdlibEnable("AdlibCheck")
Send("hi there")
While WinExists("Untitled - Notepad")
Sleep(3000)
WEnd

Func AdlibCheck()
    If WinActive("Notepad","Do you want to save") Then Send("n")
EndFuncoÝ÷ ØGbµ,Þt!¢é]«Þ§^×%yªÞ®ë¶¬{-y§H·l¶»¥É©ÞÙ^²Éh¢%yêb§¶)mçbjZ ¦lº®¶­se'VâgV÷C¶æ÷FWBæWRgV÷C²¥våvD7FfRgV÷CµVçFFÆVBÒæ÷FWBgV÷C²¤FÆ$Væ&ÆRgV÷C´FÆ$6V6²gV÷C²¥6VæBgV÷C¶FW&RgV÷C²¥vÆR¥6ÆVW3¥tVæ@ ¤gVæ2FÆ$6V6² bvä7FfRgV÷C´æ÷FWBgV÷C²ÂgV÷C´Fò÷RvçBFò6fRgV÷C²FVà 6VæBgV÷C¶âgV÷C² W@ VæD`¤VæDgVæ
Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

Wow, that works! And what about tray and GUI?


I can do signature me.

Share this post


Link to post
Share on other sites

Wow, that works! And what about tray and GUI?

Seriously, look at the help file. You're going to have to do most of the coding yourself. But it will look something like this:

#Include <GUIConstants.au3>
GUICreate("title","width","height")
...
GUISetState()

AdlibEnable("MyAdlibFunc")

While 1;this is your "Run the GUI loop"
    $msg=GUIGetMsg()
    If $msg = $AControl Then
        DoSomething()
    EndIf
    ;you can do anything in this loop, including sleeping, WinWaiting, etc, without fear of missing a tray event
WEnd

Func MyAdlibFunc()
    $TrayMsg = TrayGetMsg()
    If $TrayMsg = ATrayItem Then
        DoSomethingTrayish()
    EndIf
EndFunc

Func DoSomething()
...
EndFunc

Func DoSomethingTrayish()
...
EndFunc

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

You can just run multiple checks in one while loop without even thinking about Adlib.

Example:

While 1
    $msg=GUIGetMsg()
    If $msg = $AControl Then
        DoSomething()
    EndIf

    $TrayMsg = TrayGetMsg()
    If $TrayMsg = ATrayItem Then
        DoSomethingTrayish()
    EndIf
WEnd

;you can do anything in this loop, including sleeping, WinWaiting, etc, without fear of missing a tray event

I have never succesfully seen a Adlib go through a sleep command, same with GUI's OnEvent mode. Edited by Manadar

Share this post


Link to post
Share on other sites

You can just run multiple checks in one while loop without even thinking about Adlib.

Yes, but things will be more complicated then...

i542.


I can do signature me.

Share this post


Link to post
Share on other sites

Yes, but things will be more complicated then...

i542.

i disagree with you on that one, but it's your program, go whichever way you want with it.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I think he is one of those guys who really need to brush up on conrol structures.

His question can be translated as:

while 1
  ;;;Process Window events
wend
while 1
  ;;;Process Tray Events
wend
How to combine these?

The solution is:

while 1
   ;;;Process Window Events
   ;;;Process Tray Events
wend

#)

Share this post


Link to post
Share on other sites

I think he is one of those guys who really need to brush up on conrol structures.

His question can be translated as:

while 1
 ;;;Process Window events
wend
while 1
 ;;;Process Tray Events
wend
How to combine these?

The solution is:

while 1
   ;;;Process Window Events
   ;;;Process Tray Events
wend

#)

My point.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I have never succesfully seen a Adlib go through a sleep command, same with GUI's OnEvent mode.

Refer to my post #5 above - I changed the sleep time to 30000 (30 seconds) and Adlib still sent "n" to the Notepad-generated MsgBox AS SOON as it popped up. This tells me that adlib works through sleep, doesn't it?

Edit: But I do agree that unless there is any kind of wait or sleep command in one of the event loops in his program, the best way to do it is to combine them into one while loop. The adlib is just in case there is a Case $msg=$control name that would result in it running a sleep or wait command. I'd gotten that impression somewhere, but looking back, I don't see where. :D

Edit 2: Also, changing the sleep() line (line 6) to WinWaitActive("moo") which would theoretically NEVER let the script continue (since the script never creates a window named moo) doesn't change the functionality of the Adlib: Notepad is still closed without save when you click close.

Edited by james3mg

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110

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