Gui that looks like a MsgBox

Post your working scripts, libraries and tools
iPhilip
Posts: 288
Joined: 02 Oct 2013, 12:21

Gui that looks like a MsgBox

28 Jul 2015, 14:33

Hi Folks,

Just for fun, I wanted to see if I could put together a Gui that looks like a simple MsgBox.
The benefit of this is that you can add Gui controls, such as links, and it will still have the look and feel of a MsgBox.

Enjoy,

iPhilip

Code: [Select all] [Expand] [Download] (MsgBoxGui.ahk)GeSHi © Codebox Plus

Windows 7 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Gui that looks like a MsgBox

01 Aug 2015, 00:26

nice idea, very nice
have you thought of using API functions to get the font information?
since it the user can change it
you don"t need to use (-|+ToolWindow) as you can use (-|+)SysMenu, that way no need for the visual effect
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: Gui that looks like a MsgBox

01 Aug 2015, 20:23

Nice job! Can you add No and Cancel buttons, too? :morebeard: :lol:
vasili111
Posts: 748
Joined: 21 Jan 2014, 02:04
Location: Georgia

Re: Gui that looks like a MsgBox

06 Aug 2015, 04:20

Nice! Thank you :)
DRAKON-AutoHotkey: Visual programming for AutoHotkey.
iPhilip
Posts: 288
Joined: 02 Oct 2013, 12:21

Re: Gui that looks like a MsgBox

10 Aug 2015, 14:26

Thank you all for the feedback.

MJs wrote:nice idea, very nice
Thank you! :)

MJs wrote:have you thought of using API functions to get the font information?
since it the user can change it
I followed your suggestion and developed a GetMsgBoxFontInfo function to do so. I posted it in a separate thread and below as well.

MJs wrote:you don"t need to use (-|+ToolWindow) as you can use (-|+)SysMenu, that way no need for the visual effect
Unfortunately the SysMenu option also omits the close button in the title bar so the MsgBoxGui no longer looks like a MsgBox.

Guest10 wrote:Nice job! Can you add No and Cancel buttons, too? :morebeard: :lol:
I will leave that as an "exercise for the reader". :lol:

vasili111 wrote:Nice! Thank you :)
You are welcome! :)


Here is the updated version of the MsgBoxGui function along with the GetMsgBoxFontInfo function for sake of completeness:

Code: [Select all] [Expand] [Download] (MsgBoxGui.ahk)GeSHi © Codebox Plus

I added a parameter similar to the Timeout parameter for the MsgBox command and the function now supports links as well (see Example #2 below).

Here is some code with three fun examples demonstrating the capabilities of the function.

Code: [Select all] [Expand] [Download] (MsgBoxGuiTest.ahk)GeSHi © Codebox Plus

Windows 7 Pro (64 bit) - AutoHotkey v1.1+ (Unicode 32-bit)
User avatar
Soft
Posts: 174
Joined: 07 Jan 2015, 13:18
GitHub: visionary1
Location: Seoul
Contact:

Re: Gui that looks like a MsgBox

11 Aug 2015, 22:44

beautiful work!
AutoHotkey & AutoHotkey_H v1.1.22.07
Guest10
Posts: 578
Joined: 01 Oct 2013, 02:50

Re: Gui that looks like a MsgBox

14 Aug 2015, 05:50

The Link inside the MsgBox is the best feature! :geek:
garry
Posts: 1415
Joined: 22 Dec 2013, 12:50

Re: Gui that looks like a MsgBox

14 Aug 2015, 08:38

nice script
small examples with MSGBOX und GUI

Code: [Select all] [Download] GeSHi © Codebox Plus

;- msgbox timer
t=9
msgbox, 262208,TIMER %t% seconds,This MsgBoxGui will expire after %T% seconds. ,%t%
exitapp


Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



Code: [Select all] [Download] GeSHi © Codebox Plus

;-- hyperlink example GUI
c0=D4D0C8 ;- gray normal msgbox
Gui,2:Color,c%c0%
Gui,2:Font,S10 cBlack,FixedSys
Gui,2:Add, Link,, This is a <a href="http://ahkscript.org">link</a> to start http://ahkscript.org
Gui,2:Add, Link,, Underscore text like <a id="1">this</a> or <a id="2">that</a>
Gui,2:show
return
2Guiclose:
exitapp
sowen
Posts: 3
Joined: 19 Aug 2015, 21:04

Re: Gui that looks like a MsgBox

19 Aug 2015, 21:14

Love the MsgBoxGui !! Cool stuff....the ability to add a link is awesome enough...but.... :D

Any way to add an image to the MsgBoxGui ?

ie:
Text = Links may be used anywhere in the text of a MsgBoxGui.`n<a href="http://ahkscript.org">This</a> is an example.<img src="smiley.gif" alt="Smiley face" height="42" width="42">
MsgBoxGui(GuiTitle,Text)
MJs
Posts: 454
Joined: 23 Sep 2014, 03:29

Re: Gui that looks like a MsgBox

24 Aug 2015, 06:40

iPhilip wrote:I followed your suggestion and developed a GetMsgBoxFontInfo function to do so.

thanks, and thank you the nice implementation.
pneumatic
Posts: 150
Joined: 05 Dec 2016, 01:51

Re: Gui that looks like a MsgBox

18 Jan 2017, 11:23

Just a warning about using GuiMsgBoxes, when opening the GuiMsgBox it will steal the A_DefaultGui. So for example if your GuiMsgBox is in the middle of a bunch of generic GuiControl commands , they won't work after the GuiMsgBox is dismissed (unless they explicitly specify which Gui they operate on , eg. Guicontrol, MyGui: ...). To get around it you can store A_DefaultGui into a global variable at the beginning of the GuiMsgBox function , and then restore it via Gui %previousGui%:Default after OK/Cancel has been clicked. But this has a limitation for example if you have 2 Gui's open and both spawn message boxes, the order in which you close them determines which Gui becomes the default one after that. I tried using an array of A_DefaultGui's and pushing/popping them off, but have no idea how to index them with unique identifiers which match up to each GuiMsgBox and restore the corresponding default GUI. Anyway, simplest method is to just design your script where every Gui related command has its own unique GUI name , or only ever have 1 GuiMsgBox open at a time. Another thing to keep track of is every GuiMsgBox needs to have a unique title because you will probably be using WinWaitClose to pause the script while waiting for a user response, and that operates on win titles.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: feiyue, ptpt and 27 guests