Page 2 of 2

Re: MagicBox - Message Box Generator

Posted: 17 Nov 2017, 10:46
by guest3456
this is excellent

Re: MagicBox - Message Box Generator

Posted: 18 Nov 2017, 03:01
by Yasmeen Blu
Thank you for this incredible work! Big time saver and also never knew about most of these msgbox possibilities

Re: MagicBox - Message Box Generator

Posted: 05 Jan 2018, 06:06
by Alguimist
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

Re: MagicBox - Message Box Generator

Posted: 05 Jan 2018, 06:28
by Drugwash
Thank you, just yesterday I had used previous version for one of my scripts. Very useful tool! :thumbup:

Re: MagicBox - Message Box Generator

Posted: 05 Jan 2018, 09:20
by TheDewd
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

Re: MagicBox - Message Box Generator

Posted: 06 Jan 2018, 00:02
by Alguimist
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)

Re: MagicBox - Message Box Generator

Posted: 05 Feb 2018, 08:22
by Delta Pythagorean
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.

Re: MagicBox - Message Box Generator

Posted: 05 Feb 2018, 19:52
by Alguimist
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.

Re: MagicBox - Message Box Generator

Posted: 06 Feb 2018, 07:11
by Delta Pythagorean
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!

Re: MagicBox - Message Box Generator

Posted: 03 Aug 2018, 21:08
by Alguimist
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
}

Re: MagicBox - Message Box Generator

Posted: 07 Sep 2018, 05:48
by Alguimist
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.

Re: MagicBox - Message Box Generator

Posted: 16 Jul 2019, 11:11
by estochin
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.

Re: MagicBox - Message Box Generator

Posted: 16 Jul 2019, 14:30
by gregster
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.

Re: MagicBox - Message Box Generator

Posted: 24 Sep 2019, 11:06
by Milenko
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?

Re: MagicBox - Message Box Generator

Posted: 26 Sep 2019, 18:01
by burque505
@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

Re: MagicBox - Message Box Generator

Posted: 28 Sep 2019, 17:15
by Alguimist
@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.

Re: MagicBox - Message Box Generator

Posted: 28 Sep 2019, 18:14
by Milenko
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.

Re: MagicBox - Message Box Generator

Posted: 29 Sep 2019, 11:43
by burque505
@Alguimist, thanks for clearing that up.

Re: MagicBox - Message Box Generator

Posted: 15 Mar 2020, 00:30
by julesverne
Just a message to say this is great @Alguimist !!

Re: MagicBox - Message Box Generator

Posted: 10 Apr 2021, 23:33
by YatoAntrax20XX
I was doing my script, and I couldn't, but thanks to this I was able to do the msgbox. Thanks