Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • August 31, 2015, 04:48:53 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: MessaBox Little MessageBox to show some info and disapear automatically  (Read 10641 times)


  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,085
    • View Profile
    • Read more about this member.
    • Donate to Member
I hope this is the right forum section to provide this script?

I have improved an AHK (www.AutoHotkey.com) script
from user "icefreez" called "Simple Message, on top for a delayed time"
found at http://www.autohotke....php?p=135127#135127

I want to display an Message Box to provide some info or help to me or an user/customer.
This script show an GUI without border and (OK,Yes,No) buttons.
The time out, the font size and the font face can be choose.

I use this MsgBox with Total Commander to add menu entry without an function but provide an info to me.
Total Commander allow no empty commands so i create an own dummy command who shows an info box only.

I could use this MessaBox script to add an menu entry to show me an longer text to hint me to an trick or the right syntax of an TC command.

I could use this MessaBox in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce" to provide an one time info to customers.

I could use this MessaBox with Task planer to remind me on something.

I could use this MessaBox in DOS batch.cmd to prompt some info.

Maybe it is helpful for others too? Here it is...

Here is the code (Open Source)

v.05 So.15.07.2007
Added some baubles to avoid making bad jokes with it
; Timeout > 15sec => Provide some Info to the user
; Timeout > 29sec => User info plus possibility to cancel
; Timeout > 119sec => User info plus possibility to cancel plus show start info

#SingleInstance force
;^!e::exitapp ; Ctrl+Alt+e exits script
;Little script for some nice Message Boxes. Code from icefreez. Enhanced from Stefan. v0.4
;Syntax: mb.exe TimeOut-in-seconds "Text to display" [Font-Size  "Font to use" Format-Bold-or-not]

If 1 =
1 = 30
mySec = %1%

If 2 =
myMsg = `nUpps, no parameters from you?`n
myMsg = %myMsg%Use %A_ScriptName% as an command line tool or use an link to %A_ScriptName% with this parameters.`n
myMsg = %myMsg%I use it in Total Commander to provide help messages. Or in HKLM\RunOnce to inform an customer. OR...`n`n
myMsg = %myMsg%Syntax:`t`t%A_ScriptName%  sec  "Message"`n
myMsg = %myMsg%Example:`t%A_SCRIPTNAME%   %1%  "My message is here"`n`n
myMsg = %myMsg%And "My message is here" will displayed over everything for %1% seconds in default font Arial in size 12.`n`n
myMsg = %myMsg%You can use ``n for line feed and ``t for tab.`n
myMsg = %myMsg%Advanced Syntax:`t%A_ScriptName%  sec  "Message"  Fontsize "Font name" b-for-bold `n`n
myMsg = %myMsg%Visit   www.AutoHotkey.com   and   www.DonationCoder.com   for more. (Stefan in 2007)`n`n
myMsg = %2%

If 3 =
3 = 12
mySize = %3%

If 4 =
4 = Arial
myFont = %4%

If 5 = b
myFormat = wbold


exitapp ;exits script


mySec := sec * 1000
myCloseTime =
myCloseTime += sec, seconds
FormatTime, myCloseTime, %myCloseTime%, HH:mm:ss

; Timeout > 15sec => User info
; Timeout > 29sec => User info plus possibility  to cancel
; Timeout > 119sec => User info plus possibility  to cancel plus show start info

If sec >14  ; Give the user some info if the time out is set longer then a few seconds
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%
    myY = y20
    myY = y10

If sec >29 ;Give the user the possibilty to exit the app if the time out is set too long
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%
    myY = y25

If sec >119 ;Give the user the possibilty to exit the app if the time out is set too long
    myInfo = Closing myself automatically in %sec% seconds at %myCloseTime%`nStartet from %A_SCRIPTFULLPATH%
    myY = y30

   Gui, +AlwaysOnTop +ToolWindow -SysMenu -Caption
   Gui, Color, dddddd ;changes background color
   Gui, Font, 000000 s8 , Arial
   Gui, Add, Text, x20 y2, %myInfo%
   Gui, Font, 000000 s%siz% %myFormat%, %myFont% ;Arial ;Lucida Console ;Comic Sans MS
   ;MS Sans Serif ;Times ;Verdana ;changes font color, size and font
   Gui, Add, Text, x20 %myY%, %text% ;the text to display
          If sec > 29
            Gui, Font, 000000 s8 , Arial
            Gui, Add, Text, cBlue gLaunchExit,
  • Close

  Gui, Show, NoActivate, X0, Y0

   sleep, %mySec%
   Gui, Destroy

           Gui, Destroy


Here is the compiled exe (Open Source):

* MessaBox_v05.exe (196.63 kB - downloaded 745 times.)

, just run it to see an help:

01-Just run it.PNG


Use it with DOS



Use it with an .LNK short cut

02-Use command line.PNG


Use it as Total Commander button

03-Use in Total Commander.png


Use it as Total Commander user command

03a-Use in Total Commander User-ini.png

03b-Use in Total Commander use as command.png


« Last Edit: July 15, 2007, 10:10:27 AM by AbteriX »


  • Charter Honorary Member
  • Joined in 2005
  • ***
  • Posts: 1,085
    • View Profile
    • Read more about this member.
    • Donate to Member

If you prefer some Yes/No/OK button  MessageBox and execute other commands try an VBS script:

myTEXT = "Timeout in 10sec. Do you want to press yes?" &chr(13)&  "Here goes the second line text"
myTitle = "Test only"
myTimeOut = 10
myOptions = 64

'34 "
'38 &

' MsgBox(prompt[, buttons] [, title] [, helpfile, context])
' Buttons
' vbOKOnly           0
' vbOKCancel         1
' vbAbortRetryIgnore 2
' vbYesNoCancel      3
' vbYesNo            4
' vbRetryCancel      5
' Icons
' vbCritical        16
' vbQuestion        32
' vbExclamation     48
' vbInformation     64
' Which is the default button
' vbDefaultButton1 0
' vbDefaultButton2 256
' vbDefaultButton3 512
' vbDefaultButton4 768
' * 4096 = vbSystemModal - System modal (all applications wont work until the user responds to the message box)
' There is a return value from which button is pressed on the MsgBox, this is an Integer
' vbOK      1
' vbCancel  2
' vbAbort   3
' vbRetry   4
' vbIgnore  5
' vbYes     6
' vbNo      7
' vbNewLine or vbcrlf is nur eine variable für Chr(13) & Chr(10))
Const wshYes = 6
Const wshNo = 7
Const wshYesNoDialog = 4
Const wshQuestionMark = 32

Set objShell = CreateObject("Wscript.Shell")

intReturn = objShell.Popup( myTEXT, myTimeOut, myTitle,  myOptions)

If intReturn = wshYes Then
    objShell.Popup  "You clicked the Yes button. : ",,"How nice from you"
ElseIf intReturn = wshNo Then
    Wscript.Echo "You clicked the No button."
ElseIf intReturn = 1 Then
    objShell.Popup "You clicked the OK button." ,,"OK"
'    Wscript.Echo "The popup timed out."
End If


Or use an little app for this like:

msgbox from http://debrock.org/
This command-line tool displays a string or the content of a text-file in a message-box.


msgbox uses the following syntax:

msgbox [-t:"caption text" -i:icon -f:filename] "Text to display"
Set the caption of the message-box

Set the icon to be displayed. Possible values can be error, warning, info, or question

Displays the content of th text file filename

"Text to display"
Text to be displayed in the message-box. Special characters \n and \t are expanded. This string must be quoted.


    * Character \n is expanded as a CR/LF pair.
    * Character \t is expanded as a tab character.

# Displays "Service not started" in a message-box. "Warning" is the title:
msgbox -t:Warning "Service not started"

# Displays the content of file "warning.txt". Title of the message-box is "Warning: service not started.":
msgbox -t:"Warning: service not started." -f:warning.txt

# Displays the content of file "warning.txt". Icon is set to "Error", and title of the message-box is "Warning: service not started.":
msgbox -i:error -t:"Warning: service not started." -f:warning.txt


2003-11-29     msgbox 1.2.1

    * Corrected a bug preventing the display of back-slash.

2003-11-21    msgbox 1.2

    * Corrected some bugs:
      * Quotes in -t flag is now working...
      * Multiple text are now concatenated:

      msgbox "Hello\n" "World!" is now same as
      msgbox "Hello\nWorld!"

2003-11-1    msgbox 1.1

    * MessageBox is now put in foreground and is topmost (will add a command-line option for that).
    * New method to display syntax.
    * Shrink exe size down to 15.5 KB

2003-09-29    msgbox 1.0

    * Initial release


or PView from Alex Kurz


PView V. 1.05


PView -pf PictureFile -pt "Picture text" -pc "Picture Caption" -ps Text Size -pp Text Position -mt "MessageBox Text" -ms MessageBox Style -mc "MessageBox Caption"

-pf: Full qualified path and filename to a valid picture file (.jpg, .bmp, .gif, .wmf, .emf)

This Parameter enables the "show picture" part of the program. It is optional if you want to use the "MessageBox" part only.

Limitation: Only "DOS" paths are supported. If you want to show a picture in "C:\Program Files\", you must use the path "C:\Progra~1\".

-pc: Caption of the picture window.

Optional parameter. If not set, the default caption (PView) is displayed.

-pt: Text to display in the picture window.

This parameter enables the "Text in Picture Window" functionality. If used without -ps and -pp, the text will be displayed in 10p on top of the window. The text will automatically wrapped to fit into the text field.

Note: You can use the key "##CR##" anywhere in your text to force a Line Feed/Carriage Return. Example: -pt "This is one line.##CR##This is the next Line.##CR##And this is the next line."

-ps: Text size in points

A numeric expression that specifies the size of the text to display in the picture window.

-pp: Text position.

Defines the position of the text in the picture windows. Valid parameters are "top" and "bottom" (without double quotes).

-mt: Text to display in the Message Box. Must be delimited with double quotes.

This Parameter enables the "Message Box" part of the program. If used without -ms and -mc parameters, a standard Message Box with an "OK" button and no icon will appear.

-ms: Message Box Style.
A numeric expression that is the sum of values specifying the number and type of buttons to display and the icon style to use. Optional.

0   Display OK button only.
1   Display OK and Cancel buttons.
2   Display Abort, Retry, and Ignore buttons.
3   Display Yes, No, and Cancel buttons.
4   Display Yes and No buttons.
5   Display Retry and Cancel buttons.
16   Display Critical Message icon.
32   Display Warning Query icon (question mark).
48   Display Warning Message icon (exclamation mark).
64   Display Information Message icon.

-mc: Message Box Caption. The Title of the Message Box. If no -mc parameter is used, the default caption "Message" is used.


PView.exe -pf c:\somepath\somepicture.jpg -pc "This is a Test Caption"
- shows the picture "c:\somepath\somepicture.jpg" with the windows title ""This is a Test Caption"

PView.exe -pf c:\somepath\somepicture.jpg -pt "This is a message." -ps 12 -pp bottom
- shows the picture "c:\somepath\somepicture.jpg" and a text line saying "This is a message." in 12p MS Sans Serif at the bottom of the picture window.

PView.exe -mt "This is a Message. Press OK."
- comes up with a message box saying "This is a Message. Press OK." and an "OK" button.

PView.exe -pf c:\somepath\somepicture.jpg -mt "This is a Message. Press OK." -ms 65 -mc "Some Title"
- shows the picture "c:\somepath\somepicture.jpg", comes up with a message box saying "This is a Message. Press OK.", the title "Some Title" and an "OK" and a "Cancel" button.

General Limitations:
Today I am not able to deliver a return code, so the "OK/Cancel", "Abort/Retry/Ignore" etc. buttons make no sense at all. To enable a return code I would have to compile the program as a .dll and this would make the message boxes script modal. I suggest to use the "OK" code only.

The code is generally quick and dirty and I cannot guarantee the functionality of the program. If someone finds a significant error or problem, please let me know. The same goes for suggestions and feature requests.

Have Fun!

Alex Kurz


Or Wprompt from Horst Schaeffer
Homepage: http://home.mnet-online.de/horst.muc/

Wprompt - Batch Tool Ver. 1.2 (c) 2003-2004, Horst Schaeffer

This tool displays a prompt box with up to 3 standard buttons, and returns
an Errorlevel to check the selected button in batch files.

Syntax: Wprompt "Title" "Text" Buttons [Default[:TimeOut]] [Icon]

*  Title (in double quote marks) will show in the title bar of the window.

*  Text (in double quote marks) is the message for the user
   A line feed can be inserted with the caret symbol (^).

*  Buttons are specified by the following keywords (case ignored):
        Ok                (as Pause repacement)

*  Default is the number of the default button 1..3 (for Enter key)
   If omitted or invalid, the default button is 1.
   Optional TimeOut (seconds), separated by a colon, e.g.: 2:10
   The time-out feature requires a non-empty title.

*  Icon (optional, case ignored) with associated sound:
        i       Info
        !       Exclamation
        ?       Question
        x       Critical Error

Parameters must be separated by space(s), no commas!

Note: The prompt box remains "on top" in case the user clicks into
another window. However, the time-out countdown will be cancelled.

The Exit Code (Errorlevel) is 1..3 according to the selected button number.
Note that in batch files "If Errorlevel 2" means:
"If the Exit Code is equal to or greater than 2".
Warning : That is why the different cases are always put in a decreasing order.

        Wprompt "Error" "Continue Search?" YesNo 2 ?
        if not errorlevel 2 goto Continue
        echo You have cancelled the search
        goto END

My example:
        @ECHO OFF
        Wprompt "Error" "Continue Search?" YesNo 2:10 ?
        if not errorlevel 2 goto Continue
        echo You have cancelled the search
        GOTO END
        ECHO Also doch?
        goto END

Note: after the time out the default button is pressed automatically.

Syntax errors will produce a syntax box, and return Exit Code 255.
Once you tested the command sucessfully, this error will not occur,
so you need not check it in your batch file.

    ver. 1.2, 2004/07/15  new compiler version; exe size reduced


This program is freeware (c) Horst Schaeffer. No warranty, no liability of any kind.
PureBasic Source: http://home.mnet-onl...source/wprompt12.zip

Contact:  horst.schaeffer@gmx.net
Homepage: http://home.mnet-online.de/horst.muc/

15 JUL 2004


or maybe NirCmd from NirSoft

As always .....  all very small in size, stand alone & portable, freeware (or the like)

If you have any use, please reply so i know if it's useful for others or not.
« Last Edit: July 15, 2007, 07:47:29 AM by AbteriX »


  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 34,952
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Donate to Member
hey this could be useful!

nice work abterix!  :Thmbsup: