MagicBox - Message Box Generator

Post your working scripts, libraries and tools for AHK v1.1 and older
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: MagicBox - Message Box Generator

17 Nov 2017, 10:46

this is excellent

Yasmeen Blu

Re: MagicBox - Message Box Generator

18 Nov 2017, 03:01

Thank you for this incredible work! Big time saver and also never knew about most of these msgbox possibilities
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

05 Jan 2018, 06:06

Version 1.0.3:
- Fixed: minor corrections in the generated code.
- Fixed: the whole background of SoftModalMessageBox was being painted white under some unknown condition. Invoking the function by its address solved the issue.
- InputBoxEx: added the options Icon and IconIndex for the title bar.
- MsgBoxEx: compatibility with high DPI scaling.

:arrow: Download
User avatar
Drugwash
Posts: 850
Joined: 29 May 2014, 21:07
Location: Ploieşti, Romania
Contact:

Re: MagicBox - Message Box Generator

05 Jan 2018, 06:28

Thank you, just yesterday I had used previous version for one of my scripts. Very useful tool! :thumbup:
Part of my AHK work can be found here.
User avatar
TheDewd
Posts: 1506
Joined: 19 Dec 2013, 11:16
Location: USA

Re: MagicBox - Message Box Generator

05 Jan 2018, 09:20

FYI -- For the "Virtuose.ahk" example, the icon used for the correct answer is transparent for me.

I corrected this by using Icon57
hIcon := LoadPicture("ieframe.dll", "w32 Icon57", _)

I had to choose a higher index number and see which icon was displayed, and then find that icon's index number, and then decrease the number until it was the correct icon I wanted.

Image

Image
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

06 Jan 2018, 00:02

TheDewd wrote:For the "Virtuose.ahk" example, the icon used for the correct answer is transparent for me.
Since the icon indexes of ieframe.dll are subject to change, I'll use the checkmark icon from SyncCenter.dll, 19.
hIcon := LoadPicture("SyncCenter.dll", "w32 Icon19", _)

Another approach is to retrieve the icon handle from the resource ID:

Code: Select all

hModule := DllCall("kernel32.dll\LoadLibraryEx", "Str", "ieframe.dll", "UInt", 0, "UInt", 0x2, "Ptr")
hIcon := DllCall("LoadIcon", "Ptr", hModule, "UInt", 18211, "Ptr")
DllCall("FreeLibrary", "Ptr", hModule)
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: MagicBox - Message Box Generator

05 Feb 2018, 08:22

Can you do an alt download to this? I don't mind GitHub, META, or even DropBox.

Either one would work.
Sorry, I just don't like the way sourceforge does its downloads and it's a bit bothersome on my computer to try to load the dang website.

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

05 Feb 2018, 19:52

I don't see what is wrong with SourceForge, but you can download from a mirror if you want:
https://sourceforge.mirrorservice.org/m ... ory/1.0.3/

It should also be noticed that MagicBox is now included with AutoGUI.
User avatar
Delta Pythagorean
Posts: 627
Joined: 13 Feb 2017, 13:44
Location: Somewhere in the US
Contact:

Re: MagicBox - Message Box Generator

06 Feb 2018, 07:11

Alguimist wrote:[...] but you can download from a mirror if you want [...]
Ah! Sorry, I did not know of this. And thank you very much!

[AHK]......: v2.0.12 | 64-bit
[OS].......: Windows 11 | 23H2 (OS Build: 22621.3296)
[GITHUB]...: github.com/DelPyth
[PAYPAL]...: paypal.me/DelPyth
[DISCORD]..: tophatcat

User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

03 Aug 2018, 21:08

SoftModalMessageBox x64 is working fine in MagicBox, but not when tested isolatedly. I found that the structure size was incorrect and the issue is now gone. I also changed LoadLibrary to GetModuleHandle, since the function is from user32.dll.

Code: Select all

SoftModalMessageBox(Text, Title, Buttons, DefBtn := 1, Options := 0x1, IconRes := "", IconID := 1, Timeout := -1, Owner := 0, Callback := "") {

    If (IconRes != "") {
        hModule := DllCall("GetModuleHandle", "Str", IconRes, "Ptr")
        LoadLib := !hModule
            && hModule := DllCall("kernel32.dll\LoadLibraryEx", "Str", IconRes, "UInt", 0, "UInt", 0x2, "Ptr")
        Options |= 0x80 ; MB_USERICON
    } Else {
        hModule := 0
        LoadLib := False
    }

    cButtons := Buttons.Length()
    VarSetCapacity(ButtonIDs, cButtons * A_PtrSize, 0)
    VarSetCapacity(ButtonText, cButtons * A_PtrSize, 0)
    Loop %cButtons% {
        NumPut(Buttons[A_Index][1], ButtonIDs, 4 * (A_Index - 1), "UInt")
        NumPut(&(b%A_Index% := Buttons[A_Index][2]), ButtonText, A_PtrSize * (A_Index - 1), "Ptr")
    }

    If (Callback != "") {
        Callback := RegisterCallback(Callback, "F")
    }

    x64 := A_PtrSize == 8
    Offsets := (A_Is64BitOS) ? (x64 ? [96, 104, 112, 116, 120, 124] : [52, 56, 60, 64, 68, 72]) : [48, 52, 56, 60, 64, 68]

    ; MSGBOXPARAMS and MSGBOXDATA structures
    NumPut(VarSetCapacity(MBCONFIG, (x64) ? 136 : 76, 0), MBCONFIG, 0, "UInt")
    NumPut(Owner,    MBCONFIG, 1 * A_PtrSize, "Ptr")  ; Owner window
    NumPut(hModule,  MBCONFIG, 2 * A_PtrSize, "Ptr")  ; Icon resource
    NumPut(&Text,    MBCONFIG, 3 * A_PtrSize, "Ptr")  ; Message
    NumPut(&Title,   MBCONFIG, 4 * A_PtrSize, "Ptr")  ; Window title
    NumPut(Options,  MBCONFIG, 5 * A_PtrSize, "UInt") ; Options
    NumPut(IconID,   MBCONFIG, 6 * A_PtrSize, "Ptr")  ; Icon resource ID
    NumPut(Callback, MBCONFIG, 8 * A_PtrSize, "Ptr")  ; Callback
    NumPut(&ButtonIDs,  MBCONFIG, Offsets[1], "Ptr")  ; Button IDs
    NumPut(&ButtonText, MBCONFIG, Offsets[2], "Ptr")  ; Button texts
    NumPut(cButtons,    MBCONFIG, Offsets[3], "UInt") ; Number of buttons
    NumPut(DefBtn - 1,  MBCONFIG, Offsets[4], "UInt") ; Default button
    NumPut(1,           MBCONFIG, Offsets[5], "UInt") ; Allow cancellation
    NumPut(Timeout,     MBCONFIG, Offsets[6], "Int")  ; Timeout (ms)

    ProcAddr := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", "User32.dll", "Ptr"), "AStr", "SoftModalMessageBox", "Ptr")
    Ret := DllCall(ProcAddr, "Ptr", &MBCONFIG)

    If (LoadLib) {
        DllCall("FreeLibrary", "Ptr", hModule)
    }

    If (Callback != "") {
        DllCall("GlobalFree", "Ptr", Callback)
    }

    Return Ret
}
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

07 Sep 2018, 05:48

Version 1.0.4:
• More functions added.
• Minor bug fixes.

:arrow: Download MagicBox
List of functions:
• MsgBox
MsgBoxEx
• MessageBoxCheck (SHMessageBoxCheck)
ShellMessageBox
MessageBox
MessageBoxTimeout
• MessageBoxIndirect
• SoftModalMessageBox
• WTSSendMessage
• MsiMessageBox
FatalAppExit
ShellAbout
InputBoxEx
• TaskDialog
TaskDialogEx (TaskDialogIndirect)
• And the dinamically generated TaskDialogIndirect (no wrapper function).

Legend:
Normal text: a wrapper function around a Windows API function with the same name.
Bold: custom function.
Gray text: MagicBox does not generate code for this function.
estochin
Posts: 7
Joined: 21 Feb 2019, 11:35

Re: MagicBox - Message Box Generator

16 Jul 2019, 11:11

I just downloaded MagicBox (MagicBox-1.0.4.7z) and there is documentation on how to install it -it's not an .exe file.

What am I missing?

Any help would be appreciated.
gregster
Posts: 8916
Joined: 30 Sep 2013, 06:48

Re: MagicBox - Message Box Generator

16 Jul 2019, 14:30

estochin wrote:
16 Jul 2019, 11:11
I just downloaded MagicBox (MagicBox-1.0.4.7z) and there is documentation on how to install it -it's not an .exe file.
.7z is an archive format, similar to .zip or .rar: https://en.wikipedia.org/wiki/7z
I, for example, use WinRAR to open it, but there are also 7-zip (https://en.wikipedia.org/wiki/7-Zip) and other unpackers that can handle it.

Just unpack the folder in the file and find MagicBox.ahk.
User avatar
Milenko
Posts: 11
Joined: 18 Sep 2019, 15:20

Re: MagicBox - Message Box Generator

24 Sep 2019, 11:06

Looks like a great tool but unfortunately it won't load for me.
Did I break it?

Code: Select all

>"C:\Program Files (x86)\AutoHotkey\AutoHotkey.exe" /ErrorStdOut "C:\Users\DuStiN\Desktop\MagicBox\MagicBox.ahk"    
C:\Users\DuStiN\Desktop\MagicBox\Lib\GuiButtonIcon.ahk (36) : ==> Missing comma
     Specifically: GuiButtonIcon(Handle, File, Index := 1, Options := "")
>Exit code: 2    Time: 0.4484
Note: I'm on windows 10 using AHK Version 1.1.30.03



OK, so after searching a salutation for hours i thought to myself, maybe i can find a compiled version... WAIT! what if i just compile myself? :shock:
and of course it works great.
Thanks for sharing.
But i still wonder why the .ahk would not run? Maybe the version os AHK im using?
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: MagicBox - Message Box Generator

26 Sep 2019, 18:01

@Milenko, I find myself having to add this code (from the docs) to scripts that work for me on Win7 to get them to work (uncompiled, that is), on Win10. Not all of them, but a fair amount.

Code: Select all

full_command_line := DllCall("GetCommandLine", "str")

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}
Regards,
burque505
User avatar
Alguimist
Posts: 428
Joined: 05 Oct 2015, 16:41
Contact:

Re: MagicBox - Message Box Generator

28 Sep 2019, 17:15

@Milenko and @burque505: It has nothing to do with Windows 10 or administrative privileges. An outdated version of AHK was used to execute the script, while a more recent one was used to compile it.
User avatar
Milenko
Posts: 11
Joined: 18 Sep 2019, 15:20

Re: MagicBox - Message Box Generator

28 Sep 2019, 18:14

That was my first thought but when i entered the AHK world just a few months ago, I'm pretty sure i clicked the lasted version. I may be wrong.
But all in all I got it to work and its a job well done.
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: MagicBox - Message Box Generator

29 Sep 2019, 11:43

@Alguimist, thanks for clearing that up.
julesverne
Posts: 42
Joined: 18 Apr 2017, 14:39
Contact:

Re: MagicBox - Message Box Generator

15 Mar 2020, 00:30

Just a message to say this is great @Alguimist !!
YatoAntrax20XX
Posts: 2
Joined: 09 Apr 2021, 13:28

Re: MagicBox - Message Box Generator

10 Apr 2021, 23:33

I was doing my script, and I couldn't, but thanks to this I was able to do the msgbox. Thanks

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 115 guests