[RELEASE] MsgBox for Batch
Moderator: DosItHelp
[RELEASE] MsgBox for Batch
Hey guys!!
Im new to this forum and decided to make my first post as a small contribution. My friend has learnt a bit of batch and wanted me to make a msgbox command for him. I put it up on mediafire: http://www.mediafire.com/?4zc1iev95w7e79i
To use:
Message only: msgbox "My Msg"
Message and Title: msgbox "My Msg" , "My Title"
THE SPACE BEFORE AND AFTER THE "," IS ESSENTIAL!
Please give feedback!!
Im new to this forum and decided to make my first post as a small contribution. My friend has learnt a bit of batch and wanted me to make a msgbox command for him. I put it up on mediafire: http://www.mediafire.com/?4zc1iev95w7e79i
To use:
Message only: msgbox "My Msg"
Message and Title: msgbox "My Msg" , "My Title"
THE SPACE BEFORE AND AFTER THE "," IS ESSENTIAL!
Please give feedback!!
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: [RELEASE] MsgBox for Batch
Well, I'll try the .exe through VirtualBox... lol.
Edit: Ok well, the syntax is odd with requiring whitespace in the comma... also I was wondering why not just use vbscript in the first place, as this just creates a temp .vbs that it doesn't clean up after, and comes in at a whopping 465~ KB?
So why not...
box.vbs:
dos:
boxtype and title are optional. boxtype should be one of these values:
But then I question why use a message box with DOS anyways? That's intrusive compared to just controlling echos to the Command Prompt window.
Edit: Ok well, the syntax is odd with requiring whitespace in the comma... also I was wondering why not just use vbscript in the first place, as this just creates a temp .vbs that it doesn't clean up after, and comes in at a whopping 465~ KB?
So why not...
box.vbs:
Code: Select all
x=msgbox(wscript.arguments(0),wscript.arguments(1),wscript.arguments(2))
dos:
Code: Select all
cscript box.vbs //nologo "message" boxtype "title"
boxtype and title are optional. boxtype should be one of these values:
But then I question why use a message box with DOS anyways? That's intrusive compared to just controlling echos to the Command Prompt window.
Last edited by orange_batch on 27 May 2011 06:19, edited 1 time in total.
Re: [RELEASE] MsgBox for Batch
There different type of coding which batch is used for. The most common would be what you are refering to; in which no message box is required. But my friend needed it for a more graphical end. Not alot of people enjoy using a batch file as a program of choice.
As for the program not cleaning up, i accidentaly uploaded the wrong version i just did the correct one at:http://www.mediafire.com/?4zc1iev95w7e79i
As for the program not cleaning up, i accidentaly uploaded the wrong version i just did the correct one at:http://www.mediafire.com/?4zc1iev95w7e79i
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: [RELEASE] MsgBox for Batch
Alright, but I'd still go with the solution I posted.
It can be ran in the same context of creating and deleting the VB script file as yours too, straight from DOS.
It can be ran in the same context of creating and deleting the VB script file as yours too, straight from DOS.
Code: Select all
set msgbox="%temp%\msgbox%random%%random%.vbs"
echo:x=msgbox(wscript.arguments(0),wscript.arguments(1),wscript.arguments(2))>%msgbox%
cscript %msgbox% //nologo "message" boxtype "title"
del %msgbox%
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: [RELEASE] MsgBox for Batch
kD3V wrote:But my friend needed it for a more graphical end.
Why not use something that is geared more towards gui applications. In most cases batch, vbscript, etc...
are used by sysadmins for executing their daily task.
kD3V wrote:Not alot of people enjoy using a batch file as a program of choice.
Yes, using batch scripts are a little outdated do to the fact that there are much more powerful tools that are out there to use these days. Hey but the command prompt is still fun to use, and as powershell continue to seep into everyone's world a little more each day, forget about it.
kD3V wrote:As for the program not cleaning up...
Again this is extra work that does not have to be done. If your friend is looking at creating gui apps or msg boxes whatever, have a look at autoit, it is easy to learn and you can create all the msg boxes your heart desires. Though if 465k is an issue watch out now.
Re: [RELEASE] MsgBox for Batch
AutoIT rocks
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: [RELEASE] MsgBox for Batch
Ed Dyreen wrote:AutoIT rocks
lol you are damn skippy Ed
Re: [RELEASE] MsgBox for Batch
kD3V wrote:Hey guys!!
Im new to this forum and decided to make my first post as a small contribution. My friend has learnt a bit of batch and wanted me to make a msgbox command for him. I put it up on mediafire: http://www.mediafire.com/?4zc1iev95w7e79i
To use:
Message only: msgbox "My Msg"
Message and Title: msgbox "My Msg" , "My Title"
THE SPACE BEFORE AND AFTER THE "," IS ESSENTIAL!
Please give feedback!!
This is not very complex. Like, not even a few C++ /C#/VB/etc lines.
I'm not trying to be mean or anything, but it would be like 10 times better if you actually made some more features. Like the type of message box (maybe with a /t switch), make the space before and after the "," not essential, and the buttons in the message box (maybe with a /b switch). Also maybe allow it to pause the prompt until a button is pressed, then return the value in "%errorlevel%".
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: [RELEASE] MsgBox for Batch
This comes included with autoit in the examples.
Why code it yourself when someone can do the work for you.
Code: Select all
;===============================================================================
;
; Program Name: MsgBoxWizard()
; Description: Generate the MessageBox function code according to the user
; choices
; Requirement(s): None
; Return Value(s): None
; Author(s): Giuseppe Criaco <gcriaco@quipo.it>
;
;===============================================================================
;
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
Opt('MustDeclareVars', 1)
Global $iFlag, $Button, $msgbox, $asMsgText
Global $optWarning, $optInfo, $optCritical, $optQuestion
Global $optNoIcon, $optApplication, $optSysModal, $optTaskModal, $optOK
Global $optOkCancel, $optYesNo, $optYesNoCancel, $optAbortRetryIgnore
Global $optRetryCancel, $optCancelRetryContinue, $optNothing, $optTopMost
Global $optRightJust, $optFirst, $optSecond, $optThird
_Main()
Func _Main()
Local $TITLE, $TEXT, $Timeout
Local $BTNCOPY, $BTNEXIT, $BTNPREVIEW, $MSG, $sText
GUICreate("MsgBox Wizard v.1.0", 440, 540, 100, 100) ; will create a dialog box
GUICtrlCreateLabel("Title", 10, 5, 30)
$TITLE = GUICtrlCreateInput("", 10, 20, 420, 20)
GUICtrlSetState(-1, $GUI_FOCUS)
GUICtrlSetTip(-1, "The title of the message box.")
GUICtrlCreateLabel("Text", 10, 50, 30)
$TEXT = GUICtrlCreateEdit("", 10, 65, 420, 100, $ES_AUTOVSCROLL + $WS_VSCROLL + $ES_MULTILINE + $ES_WANTRETURN)
GUICtrlSetTip(-1, "The text of the message box.")
GUICtrlCreateGroup("Icons", 10, 170, 200, 130)
$optWarning = GUICtrlCreateRadio("Warning", 20, 190, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$optInfo = GUICtrlCreateRadio("Informational", 20, 210, 100, 20)
$optCritical = GUICtrlCreateRadio("Critical", 20, 230, 100, 20)
$optQuestion = GUICtrlCreateRadio("Question", 20, 250, 100, 20)
$optNoIcon = GUICtrlCreateRadio("None", 20, 270, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Modality", 10, 310, 200, 90)
$optApplication = GUICtrlCreateRadio("Application", 20, 330, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$optSysModal = GUICtrlCreateRadio("System Modal", 20, 350, 100, 20)
$optTaskModal = GUICtrlCreateRadio("Task Modal", 20, 370, 100, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Buttons", 230, 170, 200, 170)
$optOK = GUICtrlCreateRadio("OK", 240, 190, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$optOkCancel = GUICtrlCreateRadio("OK, Cancel", 240, 210, 100, 20)
$optYesNo = GUICtrlCreateRadio("Yes, No", 240, 230, 100, 20)
$optYesNoCancel = GUICtrlCreateRadio("Yes, No, Cancel", 240, 250, 100, 20)
$optAbortRetryIgnore = GUICtrlCreateRadio("Abort, Retry, Ignore", 240, 270, 120, 20)
$optRetryCancel = GUICtrlCreateRadio("Retry, Cancel", 240, 290, 100, 20)
$optCancelRetryContinue = GUICtrlCreateRadio("Cancel, Retry, Continue", 240, 310, 130, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Miscellaneous", 10, 410, 200, 90)
$optNothing = GUICtrlCreateRadio("Nothing", 20, 430, 100, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$optTopMost = GUICtrlCreateRadio("Top-most attribute set", 20, 450, 130, 20)
$optRightJust = GUICtrlCreateRadio("Right-justified title/text", 20, 470, 150, 20)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Default Buttons", 230, 350, 200, 90)
$optFirst = GUICtrlCreateRadio("First Button", 240, 370, 130, 20)
GUICtrlSetState(-1, $GUI_CHECKED)
$optSecond = GUICtrlCreateRadio("Second Button", 240, 390, 130, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$optThird = GUICtrlCreateRadio("Third Button", 240, 410, 130, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
GUICtrlCreateGroup("Timeout", 230, 450, 200, 50)
$Timeout = GUICtrlCreateInput("", 240, 470, 100, 20, $ES_NUMBER)
GUICtrlSetTip(-1, "Optional Timeout in seconds. After the timeout has elapsed the message box will be automatically closed.")
GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group
$BTNPREVIEW = GUICtrlCreateButton("&Preview", 10, 510, 100)
GUICtrlSetTip(-1, "Show the MessageBox")
$BTNCOPY = GUICtrlCreateButton("&Copy", 120, 510, 100)
GUICtrlSetTip(-1, "Copy the generated AutoIt code to the Clipboard")
$BTNEXIT = GUICtrlCreateButton("&Exit", 230, 510, 100)
GUICtrlSetTip(-1, "Quit the program")
$Button = $optOK
GUISetState() ; will display an empty dialog box
; Run the GUI until the dialog is closed
While 1
$MSG = GUIGetMsg()
Select
Case $MSG = $GUI_EVENT_CLOSE Or $MSG = $BTNEXIT
Exit
Case $MSG = $optOK
$Button = $optOK
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_DISABLE)
GUICtrlSetState($optThird, $GUI_DISABLE)
Case $MSG = $optOkCancel
$Button = $optOkCancel
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_DISABLE)
Case $MSG = $optYesNo
$Button = $optYesNo
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_DISABLE)
Case $MSG = $optYesNoCancel
$Button = $optYesNoCancel
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_ENABLE)
Case $MSG = $optAbortRetryIgnore
$Button = $optAbortRetryIgnore
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_ENABLE)
Case $MSG = $optRetryCancel
$Button = $optRetryCancel
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_DISABLE)
Case $MSG = $optCancelRetryContinue
$Button = $optCancelRetryContinue
GUICtrlSetState($optFirst, $GUI_CHECKED)
GUICtrlSetState($optFirst, $GUI_ENABLE)
GUICtrlSetState($optSecond, $GUI_ENABLE)
GUICtrlSetState($optThird, $GUI_ENABLE)
Case $MSG = $BTNPREVIEW
MsgBox(_SetFlag($iFlag), GUICtrlRead($TITLE), GUICtrlRead($TEXT), GUICtrlRead($Timeout))
Case $MSG = $BTNCOPY
$asMsgText = StringSplit(GUICtrlRead($TEXT), @CRLF, 1)
If $asMsgText[0] = 1 Then
$sText = GUICtrlRead($TEXT)
Else
$sText = $asMsgText[1]
For $iCtr = 2 To $asMsgText[0]
$sText = $sText & Chr(34) & " & @CRLF & " & Chr(34) & $asMsgText[$iCtr]
Next
EndIf
Select
Case $Button = $optOK
If GUICtrlRead($Timeout) = "" Then
$msgbox = "MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
" Case Else ;OK" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optOkCancel
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 1 ;OK" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 1 ;OK" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optYesNo
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 6 ;Yes" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 7 ;No" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 6 ;Yes" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 7 ;No" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optYesNoCancel
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 6 ;Yes" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 7 ;No" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 6 ;Yes" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 7 ;No" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optAbortRetryIgnore
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 3 ;Abort" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 4 ;Retry" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 5 ;Ignore" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 3 ;Abort" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 4 ;Retry" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 5 ;Ignore" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optRetryCancel
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 4 ;Retry" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 4 ;Retry" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
Case $Button = $optCancelRetryContinue
If GUICtrlRead($Timeout) = "" Then
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 10 ;Try Again" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 11 ;Continue" & @CRLF & @CRLF & _
"EndSelect"
Else
$msgbox = "Dim $iMsgBoxAnswer" & @CRLF & _
"$iMsgBoxAnswer = MsgBox(" & _SetFlag($iFlag) & "," & Chr(34) & GUICtrlRead($TITLE) & Chr(34) & "," _
& Chr(34) & $sText & Chr(34) & "," & GUICtrlRead($Timeout) & ")" & @CRLF & _
"Select" & @CRLF & _
" Case $iMsgBoxAnswer = 2 ;Cancel" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 10 ;Try Again" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = 11 ;Continue" & @CRLF & @CRLF & _
" Case $iMsgBoxAnswer = -1 ;Timeout" & @CRLF & @CRLF & _
"EndSelect"
EndIf
EndSelect
ClipPut($msgbox)
EndSelect
WEnd
EndFunc ;==>_Main
;===============================================================================
;
; Function Name: _SetFlag()
; Description: Set the flag that indicates the type of message box and the
; possible button combinations.
; Parameter(s): $iFlag - Flag
; Requirement(s): None
; Return Value(s): On Success - Returns the message box flag
; None
; Author(s): Giuseppe Criaco <gcriaco@quipo.it>
;
;===============================================================================
;
Func _SetFlag($iFlag)
$iFlag = 0
;Icons
Select
Case GUICtrlRead($optWarning) = $GUI_CHECKED
$iFlag = $iFlag + 48
Case GUICtrlRead($optInfo) = $GUI_CHECKED
$iFlag = $iFlag + 64
Case GUICtrlRead($optCritical) = $GUI_CHECKED
$iFlag = $iFlag + 16
Case GUICtrlRead($optQuestion) = $GUI_CHECKED
$iFlag = $iFlag + 32
EndSelect
;Modality
Select
Case GUICtrlRead($optSysModal) = $GUI_CHECKED
$iFlag = $iFlag + 4096
Case GUICtrlRead($optTaskModal) = $GUI_CHECKED
$iFlag = $iFlag + 8192
EndSelect
;Buttons
Select
Case GUICtrlRead($optOkCancel) = $GUI_CHECKED
$iFlag = $iFlag + 1
Case GUICtrlRead($optYesNo) = $GUI_CHECKED
$iFlag = $iFlag + 4
Case GUICtrlRead($optYesNoCancel) = $GUI_CHECKED
$iFlag = $iFlag + 3
Case GUICtrlRead($optAbortRetryIgnore) = $GUI_CHECKED
$iFlag = $iFlag + 2
Case GUICtrlRead($optRetryCancel) = $GUI_CHECKED
$iFlag = $iFlag + 5
Case GUICtrlRead($optCancelRetryContinue) = $GUI_CHECKED
$iFlag = $iFlag + 6
EndSelect
;Miscellaneous
Select
Case GUICtrlRead($optTopMost) = $GUI_CHECKED
$iFlag = $iFlag + 262144
Case GUICtrlRead($optRightJust) = $GUI_CHECKED
$iFlag = $iFlag + 5244288
EndSelect
;Default Buttons
Select
Case GUICtrlRead($optSecond) = $GUI_CHECKED
$iFlag = $iFlag + 256
Case GUICtrlRead($optThird) = $GUI_CHECKED
$iFlag = $iFlag + 512
EndSelect
Return $iFlag
EndFunc ;==>_SetFlag
Why code it yourself when someone can do the work for you.
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: [RELEASE] MsgBox for Batch
..... or just use the TWO lines of code I wrote, lmao. What the crap, it's only a message box.
Re: [RELEASE] MsgBox for Batch
orange_batch wrote:..... or just use the TWO lines of code I wrote, lmao. What the crap, it's only a message box.
Code: Select all
@echo off
echo x = msgbox("Your computer is infected!",vbcritical,"Warning") > msgbox.vbs rem this line
start msgbox.vbs rem and this one?
ping 0 -n 1 > nul
del msgbox.vbs
pause
?
That's the most basic way I can possibly think of. This way is also useful because you can pause the prompt until a button is pressed, and then catch the value with a simple file transfer.
Code: Select all
@echo off
set NLM=^
set NL=^^^%NLM%%NLM%^%NLM%%NLM%
echo x = msgbox("Click one:",vbyesnocancel)%NL%set fso = createobject("scripting.filesystemobject")%NL%set file = fso.createtextfile("tmp")%NL%file.write(x)%NL%file.close() > msgbox.vbs
start msgbox.vbs
ping 0 -n 1 > nul
del msgbox.vbs
:loop
if exist tmp (
goto read
) else (
goto loop
)
:read
set /p buttonval=< tmp
echo You pressed: %buttonval%
del tmp
pause
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: [RELEASE] MsgBox for Batch
nitt wrote:orange_batch wrote:..... or just use the TWO lines of code I wrote, lmao. What the crap, it's only a message box.
Code: Select all
@echo off
echo x = msgbox("Your computer is infected!",vbcritical,"Warning") > msgbox.vbs rem this line
start msgbox.vbs rem and this one?
ping 0 -n 1 > nul
del msgbox.vbs
pause
Why are we doing this, can you explain why you are using dos to spit out vbscipt, what is the purpose, why just not vbscript. Ok this is a dumb topic for it is just a message box. Topic go fall down the ladder.
Re: [RELEASE] MsgBox for Batch
Cleptography wrote:nitt wrote:orange_batch wrote:..... or just use the TWO lines of code I wrote, lmao. What the crap, it's only a message box.Code: Select all
@echo off
echo x = msgbox("Your computer is infected!",vbcritical,"Warning") > msgbox.vbs rem this line
start msgbox.vbs rem and this one?
ping 0 -n 1 > nul
del msgbox.vbs
pause
Why are we doing this, can you explain why you are using dos to spit out vbscipt, what is the purpose, why just not vbscript. Ok this is a dumb topic for it is just a message box. Topic go fall down the ladder.
Because if you are coding something in Batch, but you want a MSGBOX, you can't code it in VBScript... Yes, you cross-code, but it still works just fine.
-
- Posts: 287
- Joined: 16 Mar 2011 19:17
- Location: scriptingpros.com
- Contact:
Re: [RELEASE] MsgBox for Batch
It still makes no logical sense you could do the same with c# and compile with csc.exe or autoit or even javascript. Yes it works but it is a waste of time.
Last edited by Cleptography on 28 May 2011 16:58, edited 1 time in total.
-
- Expert
- Posts: 442
- Joined: 01 Aug 2010 17:13
- Location: Canadian Pacific
- Contact:
Re: [RELEASE] MsgBox for Batch
Cleptography wrote:what is the purpose, why just not vbscript.
To add certain vbscript functionalities to batch, that's all. Ofc vbscript doesn't have a console, either.
I wrote a tool set that I'm still building upon, which adds a lot of useful functionality to batch.