Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

How to make MsgBox NON-modal?


  • Please log in to reply
20 replies to this topic
a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

This will not work in STD-LIB because of need of uniqueb labels in the code (but your solution has the same problem)

Arent "After_MsgBox:" & "Wait_For_MsgBox:" unique enough?

Not as I see it

How to use that in this case:
<code> 

MsgBoxNoWait("msgbox text")   ; 1st msgbox
After_MsgBox: 

<code> 
MsgBoxNoWait("msgbox text")   ; 2nd msgbox
After_MsgBox:    ; <----  DUPLICATE LABEL

ExitApp


Oh i see what you mean. For the moment im just concerned with getting it to work with a single msgbox .. if get working then i would with >1 msgboxes & other fine-tuning, etc

Eedis
  • Members
  • 1775 posts
  • Last active: Sep 26 2014 05:59 PM
  • Joined: 12 Jun 2009
Well, I read the first thread and wasn't really reading the rest so I'm not completely to sure at what you wanted.

What I thought was that you wanted a MsgBox to pop up but the code keeps going, instead of waiting on the user to hit ok.

I came up with the solution to use a GUI.

I just did this to resemble a MsgBox. The sound beeps still even though the MsgBox is open.

Gui, Add, Button, x11 y49 w88 h28 , OK
Gui, Add, Text, x17 y13 w89 h18 , asdf
Gui, Show, w133 h92, New GUI Window
goto, a
Return

a:
SoundBeep
return

buttonok:
gui, destroy
return

GuiClose:
ExitApp
Return

Not to sure if that was what you really wanted.

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

Well, I read the first thread and wasn't really reading the rest so I'm not completely to sure at what you wanted.

What I thought was that you wanted a (standard) MsgBox to pop up but the code keeps going, instead of waiting on the user to hit ok <--- yes

I came up with the solution to use a GUI <--- only as last resort

...

Not to sure if that was what you really wanted.


My original goal was to somehow make the standard/ahk "MsgBox" (command) act as non-modal

And i accepted that IF it COULDN'T be done, THEN i would try sth similar (eg Gui) (& make it LOOK just like the standrd/ahk MsgBox) ..................
.................. BUT NOW .................................... :D

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008
.................. that i have FOUND A SOLUTION :):):), that may not be necessary (but still might do it anyway, for completeness)

My solution is a little "messy", but it works perfectly...

CALLING SCRIPT...
SetTitleMatchMode, 3	;Exact

;<code>

[color=orange]MsgBox("[/color]NON-MODAL MsgBox !!![color=orange]")[/color]		; <--- (MsgBox) function = modal, but initiates a non-modal "thread" within it

;<code>

; Code which deals with the MsgBox
winwait, ahk_class #32770
sleep, 1500
;
tooltip the code AFTER "MsgBox" command will now close MsgBox !!!
sleep, 4000
tooltip
;
sleep, 1000
winclose, ahk_class #32770
;
sleep, 250
tooltip DONE !!!
sleep, 750
tooltip

;<code>

ExitApp
MSGBOX FUNCTION file...
(<user library>\MsgBox.ahk)
MsgBox(textMsgbox)
{
  ;Makes MsgBox NON-modal

  textMsgbox = "%textMsgbox%"					  ;add "" (so can pass spaces)

  Run, <path>\MsgBoxexe.exe %textMsgbox%		;starts this as "non-modal thread" (Run = non-modal process, RunWait = modal process)

  ;Immediately continues here
}
MsgBox "THREAD" file...
(compiled to exe; <path>\MsgBoxexe.exe)
MsgBox %1%


Eedis
  • Members
  • 1775 posts
  • Last active: Sep 26 2014 05:59 PM
  • Joined: 12 Jun 2009
Why not just do this.


Your main script.
^a::
{
run, msgbox.exe
"Do other stuff."
}
return

The MsgBox. Compile this or change the extension above to .ahk.
MsgBox, "Your message."

That would do what I understand you wanted. Sorry, I still haven't read the complete post, I'm in a rush.

a_h_k
  • Members
  • 681 posts
  • Last active: Oct 27 2012 04:50 AM
  • Joined: 02 Feb 2008

Why not just do this.

Your main script.

^a::
{
run, msgbox.exe
"Do other stuff."
}
return
The MsgBox. Compile this or change the extension above to .ahk.
MsgBox, "Your message."


Yes, basically that would suffice (if pass msgbox text as parameter), but i'm wanting somethnig a bit more "elegant" .. hence my MsgBox() function
(ie i call this function first, and THEN call the exe from there)
.