Jump to content

GuiMsg


Jon
 Share

Recommended Posts

  • Administrators

GuiMsg() and GuiMsg(0) are pretty much the same now, but I noticed one difference:

GuiMsg() automatically "shows" the gui when called but GuiMsg(0) doesn't (requires an explicit GuiShow())

Are there any issues with removing this difference? Or maybe GuiMsg() shouldn't automatically do the GuiShow()? Either way I can't think of a reason for them being any different now.

Link to comment
Share on other sites

Do neither of them wait for a notify, or do both do that now? If I recall correctally, calling it with the 0 paramater used to test only for a change, so that you could run other code in the background, while a simple GuiMsg() would wait until there was a notify (so you would always get a non-zero back.) I guess I'm just confused as to what excatally has changed to make them no longer different.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

  • Administrators

Do neither of them wait for a notify, or do both do that now?  If I recall correctally, calling it with the 0 paramater used to test only for a change, so that you could run other code in the background, while a simple GuiMsg() would wait until there was a notify (so you would always get a non-zero back.)  I guess I'm just confused as to what excatally has changed to make them no longer different.

GuiMsg() only returns when something happens

GuiMsg(0) returns instantly, with 0 if nothing has happened.

If GuiMsg() is called while the GUI is hidden an automatic GuiShow() is done. GuiMsg(0) has never done this. The only reason there are two methods is you can use one of them to write non-blocking code so from my point of view they should be the same in all other ways.

Link to comment
Share on other sites

Hmmm...

I have all my scripts written to use GUIMsg() and GUIRead() and GUIMsg(0) (for loop-in-loops too), like this:

GUICreate("test",100,100)
$ani = GUISetControl("avi","Shell32.dll|150",20,20)
$button = GUISetControl("button","START",20,70,70,20)
GUISetControlNotify()

While GUIMsg()
  $msg = GUIRead()
  If $msg = $button Then
      GUIWrite($button,0,"STOP")
      GUIWrite($ani,1)
      While 1
         $msg2 = GUIMsg(0)
         If $msg2 = $button Then
            GUIWrite($ani,0)
            ExitLoop
         EndIf
         If $msg2 = -3 Then ExitLoop 2
      WEnd
      GUIWrite($button,0,"START")
   EndIf
   $msg = -3 Then ExitLoop
WEnd
GUIDelete()

:huh2:

So how can I check for a change in the second loop without stopping the script or is there something that I don't see? :)

Edit: Ahhh...I see... I changed it to only GUIMsg() and GUIRead() and it works :D

GUICreate("test",100,100)
$ani = GUISetControl("avi","Shell32.dll|150",20,20)
$button = GUISetControl("button","START",20,70,70,20)
GUISetControlNotify()

While GUIMsg()
  $msg = GUIRead()
  If $msg = $button Then
      GUIWrite($button,0,"STOP")
      GUIWrite($ani,1)
      While GUIMsg()
         $msg2 =GUIRead()
         If $msg2 = $button Then
            GUIWrite($ani,0)
            ExitLoop
         EndIf
         If $msg2 = -3 Then ExitLoop 2
      WEnd
      GUIWrite($button,0,"START")
   EndIf
   $msg = -3 Then ExitLoop
WEnd
GUIDelete()

Hmmm...

Edited by Holger
Link to comment
Share on other sites

If GuiMsg() is called while the GUI is hidden an automatic GuiShow() is done.  GuiMsg(0) has never done this.  The only reason there are two methods is you can use one of them to write non-blocking code so from my point of view they should be the same in all other ways.

Okay, now I get what you're saying. I would normally say to have neither one display the GUI automatically since we have an explicit GuiShow() call, but people might have written scripts assuming that GuiMsg() does display the GUI (such as the one above my post) that would break when the change is made. Because of this, prehaps it's best to have both display the GUI, if it's not already displayed through a seperate GuiShow() call.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

I would normally say to have neither one display the GUI automatically since we have an explicit GuiShow() call, but people might have written scripts assuming that GuiMsg() does display the GUI (such as the one above my post) that would break when the change is made.  Because of this, prehaps it's best to have both display the GUI, if it's not already displayed through a seperate GuiShow() call.

Well, the GUI stuff is still beta, and bug fixes have broken some of my scripts already. I'd recommend making GuiMsg() not display the GUI automatically. Some people might have to add a GuiShow() statements to some scripts, but that's not hard.

GuiMsg(0) should never display the GUI! I can invision a situations where you want to hide a GUI window but have GuiMsg(0) still running in the background...

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

Good point CS. I guess that's one of the downsides to testing a beta. But I think you're right about uses for testing without showing a GUI.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to comment
Share on other sites

  • Administrators

Ok, assuming I remove the explicit GuiShow(), another point:

There is a case when the gui is hidden and GuiMsg(0) is called it returns -2 to distinguish it from a usual 0 (no change). I could easily make it so that GuiMsg() also returns instantly with -2 if the Gui is hidden.

My goal is so that you can take always take a GuiMsg() loop and change it to GuiMsg(0) without any differences so I think this will work.

So to summarize

- GuiMsg(0) and GuiMsg() to work in the same way

- Both to instantly return -2 if the Gui is hidden at the time GuiMsg is called

- No automatic GuiShow()

Another change that some people will require is if they are doing a loop that ignores -3 (close) and relying on the fact that in the next iteration of the loop GuiMsg() would automatically show the gui again.

Link to comment
Share on other sites

I am ok with the GuiShow not being implicit.

I still like to have maximize/restore/minimize return not having a negative value.

Easing the checking that the gui is close or hidden help the way the script can be design. :D

Link to comment
Share on other sites

Speaking of GuiShow, could we add an optional parameter that makes GUI Active when displayed, such as GuiShow(1) ?

EDIT: Well, the pre-existing optional parameter for timeout complicates this....

I dislike having to say:

$title = "MyGuiTitle"
GuiCreate($title, ...)
...
GuiShow()
WinActivate($title)
Edited by CyberSlug
Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

  • Administrators

The flag for the initial gui display was SHOWNA (show not active). I did change this to the normal SHOW about a week ago which should be active on startup but then XP/2000 are bad at honoring this anyway.

Edited by Jon
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...