MagicBox is a development tool to assist in the creation of message boxes.
"Message boxes provide a simple, standardised method to display information, warnings and errors to the user. They can also be used to ask simple questions and to request confirmation of actions." Source
The Windows API has many message box functions, MessageBox being the most commonly used, and MagicBox is able to generate the code for a variety of such functions, including task dialogs.
Download
MsgBoxEx
Custom message box function. It offers custom buttons and icon, support for hyperlinks, verification text, font and color, callback and the look and feel of a regular message box.
Parameters: Text [, Title, Buttons, Icon, ByRef CheckText, Styles, Owner, Timeout, FontOptions, FontName, BGColor, Callback]
MsgBox
The MsgBox function displays a message box and waits for the user to click a button and then an action is performed based on the button clicked by the user. This is a generic description valid for any type of message box.
Parameters:
MsgBox, Text
MsgBox [, Options, Title, Text, Timeout]
Extended options: custom button text, icons and position.
SHMessageBoxCheck
Displays a message box that gives the user the option of suppressing further occurrences. If the user has already opted to suppress the message box, the function does not display a dialog box and instead simply returns the default value.
This function supports only a subset of the flags supported by MessageBox. The question mark icon and the "always on top" option are not available on Windows Vista and higher.
The unique ID is stored in a registry key.
Parameters: Text [, Title, Options, RegVal, Owner]
MessageBoxIndirect
Creates, displays, and operates a message box. The message box contains application-defined message text and title, any icon, and any combination of predefined push buttons.
Parameters: Text [, Title, Options, IconRes, IconID, Owner]
SoftModalMessageBox
SoftModalMessageBox encompasses functions like MessageBox, MessageBoxTimeout and MessageBoxIndirect. Up to 10 buttons can be defined.
Parameters: Text, Title, Buttons [, DefBtn, Options, IconRes, IconID, Timeout, Owner, Callback]
MsiMessageBox
Little is known about this function.
Parameters: Text [, Title, Options, Owner]
WTSSendMessage (WinStationSendMessage)
This function can be used to display a message box from a service or on the client desktop of a specified Remote Desktop Services session. Always on top, no owner, no focus and no theme.
Parameters: Text [, Title, Options, Timeout, Wait, Session, Server, ByRef Response]
TaskDialog
Displays a simple task dialog that contains application-defined message text and title, an icon, and any combination of predefined push buttons.
Parameters: Instruction [, Content, Title, Buttons, IconID, IconRes, Owner]
TaskDialogIndirect
The TaskDialogIndirect function creates, displays, and operates a task dialog. The task dialog contains application-defined icons, messages, title, verification check box, command links, push buttons, and radio buttons. This function can register a callback function to receive notification messages.
The code for this function is generated "on demand": only the necessary members of the TASKDIALOGCONFIG structure are defined.
Sample scripts demonstrating TaskDialogIndirect and MsgBoxEx can be found in the Examples folder.
More functions
The following functions are included in the functions folder, but MagicBox does not generate the code for them:
TaskDialogEx
Parameters: Instruction [, Content, Title, CustomButtons, CommonButtons, MainIcon, Flags, Owner, VerificationText, ExpandedText, FooterText, FooterIcon, Width]
The CustomButtons parameter is a pipe-delimited list of button labels that can be displayed as command links provided the flag 0x10 or 0x20.
ShellMessageBox
This function uses MessageBox on Windows XP and TaskDialog on Vista+.
Parameters: Text [, Title, Options, Owner]
Return value
MagicBox generates the conditional statements for the return value. For most types of message box it is one of the following values: OK, Cancel, Abort, Retry, Ignore, Yes, No, Try Again, Continue and Timeout.
For SoftModalMessageBox and TaskDialogIndirect, the return value is the button ID.
For the MagicBox function, the return value is the button text with ampersands removed. If the window is dismissed with the close button in the title bar or by pressing the Esc key, the value is Cancel.
Keyboard shortcuts:
• F1: Help (MSDN links).
• F9: Displays the message box.
• F10: Opens the code window.
• Alt+F9: Displays the message box in a new instance of AHK.
• Ctrl+F9: Runs the script from the code window.
Limitations on Windows XP:
• Task dialog functions require Windows Vista or higher.
• MsgBox custom button: icon is not supported.
• SHMessageBoxCheck: only the combinations of buttons OK, OK|Cancel and Yes|No are available.
• MsiMessageBox: the font size is microscopic.
Credits to:
• Lexicos, for the function ResourceIdOfIcon.
• TheGood, for task dialog examples.
• just_me, for additional task dialog options via callback.
• A guest, for MsgBoxV2.
• Fanatic Guru, for MsgBox_XY.
• Authors of libraries in use.
• The layout of the custom buttons dialog is based on TDXML Editor.
Requirements:
AutoHotkey 1.1.23 or higher, Unicode, 32 or 64-bit. Tested on Windows XP, 7 and 10.
MagicBox - Message Box Generator
MagicBox - Message Box Generator
Last edited by Alguimist on 07 Sep 2018, 05:22, edited 3 times in total.
Re: MagicBox Factory
Hi Alguimist ;
Many thanks for this, been looking for some easy way to change key names. Can't get any easier then this. Just gave it a fast look, and with all those
features I don't think it can be beat. Does everything but brew my tea. Very, very nice! Thanks again, hunter99
Edit: Sorry I forgot to also thank all those listed in credits and all who took part. Thank you.
Many thanks for this, been looking for some easy way to change key names. Can't get any easier then this. Just gave it a fast look, and with all those
features I don't think it can be beat. Does everything but brew my tea. Very, very nice! Thanks again, hunter99
Edit: Sorry I forgot to also thank all those listed in credits and all who took part. Thank you.
Re: MagicBox Factory
This tool is perfect !!
I love these tools which make your life easier
Thank you !!
I downloaded your tool and successfully updated few of my messaging stuff I wrote before to different kind of %Box (more beautiful ). But I faced a problem now when I was changing few of my MsgBox to MagicBox, I couldn't pass the variables, even the built in ones such as %A_UserName% when I write them in my message body.
Is this a bug?
I love these tools which make your life easier
Thank you !!
I downloaded your tool and successfully updated few of my messaging stuff I wrote before to different kind of %Box (more beautiful ). But I faced a problem now when I was changing few of my MsgBox to MagicBox, I couldn't pass the variables, even the built in ones such as %A_UserName% when I write them in my message body.
Is this a bug?
Re: MagicBox Factory
It's something that has not been implemented. Not a bug.
Re: MagicBox Factory
Thanks Alguimist, great tool as always from you!
Re: MagicBox Factory
InputBoxEx
The InputBoxEx function allows the user to enter input value. The type of input control used by this function can be specified so that the input can be made by means of a ComboBox or DropDownList, a ListBox, a CheckBox, a calendar (DateTime or MonthCal), a Hotkey box, a Slider. By default, an Edit box is used.
Parameters: [Instruction, Content, Title, Default, ControlType, ControlOptions, Width, x, y, WindowOptions, Timeout, Owner]
Instruction: Text in a bigger font size to explain the user's objective with the dialog box.
Content: Descriptive information, additional details. Hyperlinks can be used.
Title: Title of the window.
Default: Initial text of the input control.
ControlType: The type of the input control.
ControlOptions: Options of the input control. For example: r3 (3 rows), number, password, checked.
Width: Optional width of the window. Height is adjusted automatically.
x and y: Coordinates. If blank or omitted, the window is centered on the screen.
WindowOptions: Options such as MinimizeBox, AlwaysOnTop and -SysMenu.
Timeout: Time (in seconds) after which the window is automatically closed.
Owner: Handle of the parent window.
The return value is the string or value selected, according to the control type. ErrorLevel is set as follows: 0 - The user pressed OK. 1 - The user pressed the Cancel button. 2 - InputBoxEx exited due to timeout.
The function and the example script are in the respective folders. MagicBox Factory does not generate the code for InputBoxEx.
Download
The InputBoxEx function allows the user to enter input value. The type of input control used by this function can be specified so that the input can be made by means of a ComboBox or DropDownList, a ListBox, a CheckBox, a calendar (DateTime or MonthCal), a Hotkey box, a Slider. By default, an Edit box is used.
Parameters: [Instruction, Content, Title, Default, ControlType, ControlOptions, Width, x, y, WindowOptions, Timeout, Owner]
Instruction: Text in a bigger font size to explain the user's objective with the dialog box.
Content: Descriptive information, additional details. Hyperlinks can be used.
Title: Title of the window.
Default: Initial text of the input control.
ControlType: The type of the input control.
ControlOptions: Options of the input control. For example: r3 (3 rows), number, password, checked.
Width: Optional width of the window. Height is adjusted automatically.
x and y: Coordinates. If blank or omitted, the window is centered on the screen.
WindowOptions: Options such as MinimizeBox, AlwaysOnTop and -SysMenu.
Timeout: Time (in seconds) after which the window is automatically closed.
Owner: Handle of the parent window.
The return value is the string or value selected, according to the control type. ErrorLevel is set as follows: 0 - The user pressed OK. 1 - The user pressed the Cancel button. 2 - InputBoxEx exited due to timeout.
The function and the example script are in the respective folders. MagicBox Factory does not generate the code for InputBoxEx.
Download
Re: MagicBox Factory
Hello,
Thank you for this amazing generator, I have been looking for this long ago.
Suggestion, can you add default selected button in msgbox?
Thank you for this amazing generator, I have been looking for this long ago.
Suggestion, can you add default selected button in msgbox?
Re: MagicBox Factory
This tool may come in handy sometimes. Nice work!
There may still be a few minor tweaks needed in regard to generated code. I've noticed some handles are retrieved as type Ptr and subsequently used or freed as UInt. Same with GlobaFree-ing callback pointers. This would potentially create trouble on x64 systems.
For example in SHMessageBoxCheck where hModule is retrieved as Ptr, then used in GetProcAddress as UInt, then The Owner/Desktop ternary operation is also cast to a UInt although it should be a Ptr.
In MessageBoxIndirect hModule is retrieved as Ptr at first attempt, no type definition in LoadLibraryEx() and in the end FreeLibrary() casts it as an UInt.
Same pattern in SoftModalMessageBox with Callback, where RegisterCallback() returns a pointer while GlobalFree() casts an UInt.
There may be other places I haven't checked so maybe a thorough code review would be advisable.
The MsiMessageBox is a hard nut to crack. Behaves differently on two similar XP-SP3 systems.
One has msi.dll v4.5.6002.23731 and text is nothing but empty squares as if it tried to use a language not implemented on the system (asian or so).
The other has msi.dll v3.1.4001.5512 and display texts correctly, not so microscopic as mentioned in first post but indeed smaller than system-wide.
Both libraries are advertised as Unicode, both systems are English with Regional settings Romanian. However, the second has full support for RTL and East-Asian languages installed. No idea how things work here because, well, it's Micro$oft. Hopefully this information is helpful somehow.
@ Slada: For any messagebox type, after you select the sequence of buttons you want using the radiobuttons, click the button (on the same row) that you wish to make as default; it will appear selected and the code will take care of it all.
There may still be a few minor tweaks needed in regard to generated code. I've noticed some handles are retrieved as type Ptr and subsequently used or freed as UInt. Same with GlobaFree-ing callback pointers. This would potentially create trouble on x64 systems.
For example in SHMessageBoxCheck where hModule is retrieved as Ptr, then used in GetProcAddress as UInt, then The Owner/Desktop ternary operation is also cast to a UInt although it should be a Ptr.
In MessageBoxIndirect hModule is retrieved as Ptr at first attempt, no type definition in LoadLibraryEx() and in the end FreeLibrary() casts it as an UInt.
Same pattern in SoftModalMessageBox with Callback, where RegisterCallback() returns a pointer while GlobalFree() casts an UInt.
There may be other places I haven't checked so maybe a thorough code review would be advisable.
The MsiMessageBox is a hard nut to crack. Behaves differently on two similar XP-SP3 systems.
One has msi.dll v4.5.6002.23731 and text is nothing but empty squares as if it tried to use a language not implemented on the system (asian or so).
The other has msi.dll v3.1.4001.5512 and display texts correctly, not so microscopic as mentioned in first post but indeed smaller than system-wide.
Both libraries are advertised as Unicode, both systems are English with Regional settings Romanian. However, the second has full support for RTL and East-Asian languages installed. No idea how things work here because, well, it's Micro$oft. Hopefully this information is helpful somehow.
@ Slada: For any messagebox type, after you select the sequence of buttons you want using the radiobuttons, click the button (on the same row) that you wish to make as default; it will appear selected and the code will take care of it all.
Part of my AHK work can be found here.
Re: MagicBox Factory
This is very nice. It should be linked to in the documentation.
I see the InputBoxEx example file and the function in the functions folder, but I don't see the option to generate code for such an inputbox in the factory.
Cheers.
I see the InputBoxEx example file and the function in the functions folder, but I don't see the option to generate code for such an inputbox in the factory.
Cheers.
Re: MagicBox Factory
@Drugwash: Thanks for pointing that out.
@Helgef: InputBoxEx was a later addition and it will probably not be featured in the GUI.
@Helgef: InputBoxEx was a later addition and it will probably not be featured in the GUI.
Re: MagicBox - Message Box Generator
Changes in version 1.0.2:
- Generated code can be directly copied from the main window.
- Fixed incorrect or unspecified data types in DllCalls and NumPuts.
- The name of the project is MagicBox only. The MagicBox function was renamed to MsgBoxEx.
Download
- Generated code can be directly copied from the main window.
- Fixed incorrect or unspecified data types in DllCalls and NumPuts.
- The name of the project is MagicBox only. The MagicBox function was renamed to MsgBoxEx.
Download
Re: MagicBox - Message Box Generator
Suggestion: Allow user to export the current configuration, to be imported at a later time to make changes. XML Export?
Re: MagicBox - Message Box Generator
Or with JSON -> AutoHotkey-JSON (by coco)
btw Alguimist.. did you changed my suggestions via pm too? was also about Datatypes
Another tip for gui with different background-color than the normal one (see this example)
It removes the grey border around the button border
btw Alguimist.. did you changed my suggestions via pm too? was also about Datatypes
Another tip for gui with different background-color than the normal one (see this example)
It removes the grey border around the button border
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Re: MagicBox - Message Box Generator
@TheDewd: Some fields can be loaded from MagicBox.ini (must be created):
@jNizM: The data types were fixed in WinSpy as well, but I have yet to fix some minor bugs for a new release. For MagicBox I checked Windows Data Types for AHK.
Code: Select all
[MagicBox]
Type=TaskDialogIndirect
Title=Title
Text=Sample text
Content=Details
Re: MagicBox - Message Box Generator
@Alguimist:
Thanks! I should have looked at your code. I just found the option to right-click on the "Question" icon to get a different style for TaskDialog and TaskDialogIndirect. It's like an easter egg to me
Thanks! I should have looked at your code. I just found the option to right-click on the "Question" icon to get a different style for TaskDialog and TaskDialogIndirect. It's like an easter egg to me
Re: MagicBox - Message Box Generator
Code: Select all
The code generated directly from MagicBox 1.0.2 for my test (#Warn is on) is:
Spoiler
If I change
Code: Select all
TDCallback(hWnd, Notification, wParam, lParam, RefData) {
CBData := Object(RefData)
Code: Select all
TDCallback(hWnd, Notification, wParam, lParam, RefData) {
Global CBData := Object(RefData)
Code: Select all
TDCallback := RegisterCallback("TDCallback", "Fast")
CBData := {}
CBData.Timeout := 3000 ; ms
Code: Select all
TDCallback := RegisterCallback("TDCallback", "Fast")
Global CBData := {}
CBData.Timeout := 3000 ; ms
Re: MagicBox - Message Box Generator
The warn can be avoided with:
Code: Select all
Local CBData := Object(RefData)
Re: MagicBox - Message Box Generator
Thank you, Alguimist! I went at it backwards.
Re: MagicBox - Message Box Generator
Thanks a lot for this great tool, Alguimist... I love it...
I created a Project with a TaskDialogIndirect-box (compiled x86) which works as expected on my Windows10 x64-barebone, but on my Windows10 x86-notebook no defined icon has been displayed next to text and footer.
The box can be closed with no error... any idea ? To err is human.
moefr01
The box can be closed with no error... any idea ?
moefr01
Last edited by moefr01 on 18 Nov 2017, 15:10, edited 1 time in total.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 118 guests