Jump to content
Sign in to follow this  
LongBowNZ

Message Box Generator

Recommended Posts

LongBowNZ

Generate code for message boxes using a GUI.

Screenshot: '>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>

Global $sOK, $sOKCANCEL, $sABORTRETRYIGNORE, $sYESNOCANCEL, $sYESNO, $sRETRYCANCEL, $sCANCELTRYCONTINUE, $sButtonOptions
$sOK = 'OK'
$sOKCANCEL = 'OK and Cancel'
$sABORTRETRYIGNORE = 'Abort, Retry, and Ignore'
$sYESNOCANCEL = 'Yes, No, and Cancel'
$sYESNO = 'Yes and No'
$sRETRYCANCEL = 'Retry and Cancel'
$sCANCELTRYCONTINUE = 'Cancel, Try Again, and Continue'
$sButtonOptions = StringFormat('%s|%s|%s|%s|%s|%s|%s', $sOK, $sOKCANCEL, $sABORTRETRYIGNORE, $sYESNOCANCEL, $sYESNO, $sRETRYCANCEL, $sCANCELTRYCONTINUE)

$hWnd = GUICreate('Message Box Generator', 500, 470)

GUICtrlCreateGroup('Title', 10, 0, 485, 50)
$iInputTitle = GUICtrlCreateInput('', 20, 20, 461, 21)

GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Text', 10, 50, 485, 135)
$iEditText = GUICtrlCreateEdit('', 20, 70, 461, 101)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Icon', 10, 190, 211, 91)
$iIconNone = GUICtrlCreateIcon('', 0, 20, 210, 32, 32)
GUICtrlSetTip(-1, 'No icon')
$iIconError = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -4, 60, 210, 32, 32)
GUICtrlSetTip(-1, 'Error')
$iIconQuestion = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -3, 100, 210, 32, 32)
GUICtrlSetTip(-1, 'Question')
$iIconWarning = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -2, 140, 210, 32, 32)
GUICtrlSetTip(-1, 'Warning')
$iIconInformation = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -5, 180, 210, 32, 32)
GUICtrlSetTip(-1, 'Information')
$iRadioIconNone = GUICtrlCreateRadio('', 30, 250, 13, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, 'No icon')
$iRadioIconError = GUICtrlCreateRadio('', 70, 250, 13, 17)
$iRadioIconQuestion = GUICtrlCreateRadio('', 110, 250, 13, 17)
$iRadioIconWarning = GUICtrlCreateRadio('', 150, 250, 13, 17)
$iRadioIconInformation = GUICtrlCreateRadio('', 190, 250, 13, 17)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Buttons', 10, 290, 211, 51)
$iComboButtons = GUICtrlCreateCombo('', 20, 310, 195, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, $sButtonOptions, $sOK)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Default Button', 10, 350, 100, 51)
$iComboDefButton = GUICtrlCreateCombo('', 20, 370, 80, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, 'First|Second|Third|Fourth', 'First')
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Modality', 120, 350, 100, 51)
$iComboModality = GUICtrlCreateCombo('', 130, 370, 80, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, 'Application|System|Task', 'Application')
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Miscellaneous', 230, 190, 265, 241)
$iCheckboxMB_HELP = GUICtrlCreateCheckbox('Add a Help button to the message box', 240, 210, 247, 17)
GUICtrlSetTip(-1, 'Adds a Help button to the message box.' & @CRLF & 'When the user clicks the Help button or ' & @CRLF & 'presses F1, the system sends a WM_HELP ' & @CRLF & 'message to the owner.')
$iCheckboxMB_SETFOREGROUND = GUICtrlCreateCheckbox('The message box becomes the foreground window', 240, 232, 247, 37, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_DEFAULT_DESKTOP_ONLY = GUICtrlCreateCheckbox('Message box shows on the desktop of the interactive window station.', 240, 270, 247, 27, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_TOPMOST = GUICtrlCreateCheckbox('Message box has top-most attribute set', 240, 300, 247, 17)
$iCheckboxMB_RIGHT = GUICtrlCreateCheckbox('Title and text are right-justified', 240, 320, 247, 17)
$iCheckboxMB_RTLREADING = GUICtrlCreateCheckbox('Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems', 240, 340, 247, 37, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_SERVICE_NOTIFICATION = GUICtrlCreateCheckbox('The function displays a message box on the current active desktop, even if there is no user logged on to the computer', 240, 380, 247, 47, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Timeout(seconds)', 10, 410, 101, 51)
$iInputTimeout = GUICtrlCreateInput('0', 20, 430, 80, 21)
GUICtrlCreateUpdown(-1, BitOR($UDS_ARROWKEYS, $UDS_NOTHOUSANDS))
GUICtrlSetLimit(-1, 10000, 0)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Parent Handle', 120, 410, 101, 51)
$iInputParentHandle = GUICtrlCreateInput('', 130, 430, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)

$iButtonCopyToClipboard = GUICtrlCreateButton('Copy code to clipboard', 230, 436, 120, 25)
$iButtonInsertIntoScite = GUICtrlCreateButton('Insert into SciTE', 355, 436, 90, 25)
$iButtonPreview = GUICtrlCreateButton('Preview', 450, 436, 45, 25)

GUISetState(@SW_SHOW)

$iFlags = 0
$sFlags = ''
$iPreviewFlags = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iButtonCopyToClipboard
            _GenerateFlags()
            ClipPut(_GenerateCode($sFlags))
            _Reset()
        Case $iButtonInsertIntoScite
            _GenerateFlags()
            _InsertIntoSciTE(_GenerateCode($sFlags))
            _Reset()
        Case $iButtonPreview
            _GenerateFlags()
            _Preview()
            _Reset()
    EndSwitch
WEnd

Func _Reset()
    $iFlags = 0
    $sFlags = ''
    $iPreviewFlags = 0
EndFunc

Func _GenerateCode($LsFlags = '')
    Local $sMsgBoxCode = ''
    $sMsgBoxCode &= 'MsgBox('
    If $iFlags > 1 Then
        $sMsgBoxCode &= 'BitOr(' & $LsFlags & ')'
    Else
        $sMsgBoxCode &= $LsFlags
    EndIf
    $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTitle)
    $sMsgBoxCode &= ', ' & GUICtrlRead($iEditText)
    If GUICtrlRead($iInputParentHandle) <> '' Then
        $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTimeout) & ', '
        $sMsgBoxCode &= GUICtrlRead($iInputParentHandle)
    ElseIf Guictrlread($iInputTimeout) <> 0 Then
        $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTimeout)
    EndIf
    $sMsgBoxCode &= ')'
    Return $sMsgBoxCode
EndFunc

Func _GenerateFlags()
    If BitAND(GUICtrlRead($iRadioIconError), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONERROR', $MB_ICONERROR)
    ElseIf BitAnd(GUICtrlRead($iRadioIconQuestion), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONQUESTION', $MB_ICONQUESTION)
    ElseIf BitAnd(GUICtrlRead($iRadioIconWarning), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONWARNING', $MB_ICONWARNING)
    ElseIf BitAND(GUICtrlRead($iRadioIconInformation), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONINFORMATION', $MB_ICONINFORMATION)
    EndIf
    Switch GUICtrlRead($iComboButtons)
        Case $sOK
            _AddToFlags('')
        Case $sOKCANCEL
            _AddToFlags('$MB_OKCANCEL', $MB_OKCANCEL)
        Case $sABORTRETRYIGNORE
            _AddToFlags('$MB_ABORTRETRYIGNORE', $MB_ABORTRETRYIGNORE)
        Case $sYESNOCANCEL
            _AddToFlags('$MB_YESNOCANCEL', $MB_YESNOCANCEL)
        Case $sYESNO
            _AddToFlags('$MB_YESNO', $MB_YESNO)
        Case $sRETRYCANCEL
            _AddToFlags('$MB_RETRYCANCEL', $MB_RETRYCANCEL)
        Case $sCANCELTRYCONTINUE
            _AddToFlags('$MB_CANCELTRYCONTINUE', $MB_CANCELTRYCONTINUE)
    EndSwitch
    Switch GUICtrlRead($iComboDefButton)
        Case 'First'
            _AddToFlags('')
        Case 'Second'
            _AddToFlags('$MB_DEFBUTTON2', $MB_DEFBUTTON2)
        Case 'Third'
            _AddToFlags('$MB_DEFBUTTON3', $MB_DEFBUTTON3)
        Case 'Fourth'
            _AddToFlags('$MB_DEFBUTTON4', $MB_DEFBUTTON4)
    EndSwitch
    If BitAND(GUICtrlRead($iCheckboxMB_HELP), $GUI_CHECKED) Then _AddToFlags('$MB_HELP', $MB_HELP)
    If BitAND(GUICtrlRead($iCheckboxMB_SETFOREGROUND), $GUI_CHECKED) Then _AddToFlags('$MB_SETFOREGROUND', $MB_SETFOREGROUND)
    If BitAND(GUICtrlRead($iCheckboxMB_DEFAULT_DESKTOP_ONLY), $GUI_CHECKED) Then _AddToFlags('$MB_DEFAULT_DESKTOP_ONLY', $MB_DEFAULT_DESKTOP_ONLY)
    If BitAND(GUICtrlRead($iCheckboxMB_TOPMOST), $GUI_CHECKED) Then _AddToFlags('$MB_TOPMOST', $MB_TOPMOST)
    If BitAND(GUICtrlRead($iCheckboxMB_RIGHT), $GUI_CHECKED) Then _AddToFlags('$MB_RIGHT', $MB_RIGHT)
    If BitAND(GUICtrlRead($iCheckboxMB_RTLREADING), $GUI_CHECKED) Then _AddToFlags('$MB_RTLREADING', $MB_RTLREADING)
    If BitAND(GUICtrlRead($iCheckboxMB_SERVICE_NOTIFICATION), $GUI_CHECKED) Then _AddToFlags('$MB_SERVICE_NOTIFICATION', $MB_SERVICE_NOTIFICATION)
    Switch GUICtrlRead($iComboModality)
        Case 'Application'
            _AddToFlags('')
        Case 'System'
            _AddToFlags('$MB_SYSTEMMODAL', $MB_SYSTEMMODAL)
        Case 'Task'
            _AddToFlags('$MB_TASKMODAL', $MB_TASKMODAL)
    EndSwitch
EndFunc

Func _InsertIntoSciTE($sCode)
    If WinExists('[CLASS:SciTEWindow]') Then
        Local $sClip = ClipGet()
        ClipPut($sCode)
        ControlSend('[CLASS:SciTEWindow]', '', '[ID:350;CLASS:Scintilla]', '^v')
        ClipPut($sClip)
    Else
        MsgBox($MB_ICONERROR, 'Error', 'Cannot find SciTe window.')
    EndIf
EndFunc

Func _Preview()
    MsgBox($iPreviewFlags, GUICtrlRead($iInputTitle), GUICtrlRead($iEditText), GUICtrlRead($iInputTimeout), GUICtrlRead($iInputParentHandle))
EndFunc

Func _AddToFlags($LsFlag = '', $LiPreviewFlags = 0)
    If $LsFlag <> '' Then
        If $iFlags > 0 Then $sFlags &= ', '
        $sFlags &= $LsFlag
        $iFlags += 1
        $iPreviewFlags += $LiPreviewFlags
    EndIf
EndFunc

MsgBoxGenerator.au3

Edited by LongBowNZ
  • Like 1

Share this post


Link to post
Share on other sites
LongBowNZ

Lot of code to not have at least a decent description.

Yeah, sorry about that.

Share this post


Link to post
Share on other sites
sammy1983

 

Generate code for message boxes using a GUI.

Screenshot: '>

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>

Global $sOK, $sOKCANCEL, $sABORTRETRYIGNORE, $sYESNOCANCEL, $sYESNO, $sRETRYCANCEL, $sCANCELTRYCONTINUE, $sButtonOptions
$sOK = 'OK'
$sOKCANCEL = 'OK and Cancel'
$sABORTRETRYIGNORE = 'Abort, Retry, and Ignore'
$sYESNOCANCEL = 'Yes, No, and Cancel'
$sYESNO = 'Yes and No'
$sRETRYCANCEL = 'Retry and Cancel'
$sCANCELTRYCONTINUE = 'Cancel, Try Again, and Continue'
$sButtonOptions = StringFormat('%s|%s|%s|%s|%s|%s|%s', $sOK, $sOKCANCEL, $sABORTRETRYIGNORE, $sYESNOCANCEL, $sYESNO, $sRETRYCANCEL, $sCANCELTRYCONTINUE)

$hWnd = GUICreate('Message Box Generator', 500, 470)

GUICtrlCreateGroup('Title', 10, 0, 485, 50)
$iInputTitle = GUICtrlCreateInput('', 20, 20, 461, 21)

GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Text', 10, 50, 485, 135)
$iEditText = GUICtrlCreateEdit('', 20, 70, 461, 101)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Icon', 10, 190, 211, 91)
$iIconNone = GUICtrlCreateIcon('', 0, 20, 210, 32, 32)
GUICtrlSetTip(-1, 'No icon')
$iIconError = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -4, 60, 210, 32, 32)
GUICtrlSetTip(-1, 'Error')
$iIconQuestion = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -3, 100, 210, 32, 32)
GUICtrlSetTip(-1, 'Question')
$iIconWarning = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -2, 140, 210, 32, 32)
GUICtrlSetTip(-1, 'Warning')
$iIconInformation = GUICtrlCreateIcon('C:\Windows\System32\user32.dll', -5, 180, 210, 32, 32)
GUICtrlSetTip(-1, 'Information')
$iRadioIconNone = GUICtrlCreateRadio('', 30, 250, 13, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetTip(-1, 'No icon')
$iRadioIconError = GUICtrlCreateRadio('', 70, 250, 13, 17)
$iRadioIconQuestion = GUICtrlCreateRadio('', 110, 250, 13, 17)
$iRadioIconWarning = GUICtrlCreateRadio('', 150, 250, 13, 17)
$iRadioIconInformation = GUICtrlCreateRadio('', 190, 250, 13, 17)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Buttons', 10, 290, 211, 51)
$iComboButtons = GUICtrlCreateCombo('', 20, 310, 195, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, $sButtonOptions, $sOK)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Default Button', 10, 350, 100, 51)
$iComboDefButton = GUICtrlCreateCombo('', 20, 370, 80, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, 'First|Second|Third|Fourth', 'First')
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Modality', 120, 350, 100, 51)
$iComboModality = GUICtrlCreateCombo('', 130, 370, 80, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
GUICtrlSetData(-1, 'Application|System|Task', 'Application')
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Miscellaneous', 230, 190, 265, 241)
$iCheckboxMB_HELP = GUICtrlCreateCheckbox('Add a Help button to the message box', 240, 210, 247, 17)
GUICtrlSetTip(-1, 'Adds a Help button to the message box.' & @CRLF & 'When the user clicks the Help button or ' & @CRLF & 'presses F1, the system sends a WM_HELP ' & @CRLF & 'message to the owner.')
$iCheckboxMB_SETFOREGROUND = GUICtrlCreateCheckbox('The message box becomes the foreground window', 240, 232, 247, 37, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_DEFAULT_DESKTOP_ONLY = GUICtrlCreateCheckbox('Message box shows on the desktop of the interactive window station.', 240, 270, 247, 27, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_TOPMOST = GUICtrlCreateCheckbox('Message box has top-most attribute set', 240, 300, 247, 17)
$iCheckboxMB_RIGHT = GUICtrlCreateCheckbox('Title and text are right-justified', 240, 320, 247, 17)
$iCheckboxMB_RTLREADING = GUICtrlCreateCheckbox('Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems', 240, 340, 247, 37, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
$iCheckboxMB_SERVICE_NOTIFICATION = GUICtrlCreateCheckbox('The function displays a message box on the current active desktop, even if there is no user logged on to the computer', 240, 380, 247, 47, BitOR($GUI_SS_DEFAULT_CHECKBOX,$BS_MULTILINE))
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Timeout(seconds)', 10, 410, 101, 51)
$iInputTimeout = GUICtrlCreateInput('0', 20, 430, 80, 21)
GUICtrlCreateUpdown(-1, BitOR($UDS_ARROWKEYS, $UDS_NOTHOUSANDS))
GUICtrlSetLimit(-1, 10000, 0)
GUICtrlCreateGroup('', -99, -99, 1, 1)

GUICtrlCreateGroup('Parent Handle', 120, 410, 101, 51)
$iInputParentHandle = GUICtrlCreateInput('', 130, 430, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)

$iButtonCopyToClipboard = GUICtrlCreateButton('Copy code to clipboard', 230, 436, 120, 25)
$iButtonInsertIntoScite = GUICtrlCreateButton('Insert into SciTE', 355, 436, 90, 25)
$iButtonPreview = GUICtrlCreateButton('Preview', 450, 436, 45, 25)

GUISetState(@SW_SHOW)

$iFlags = 0
$sFlags = ''
$iPreviewFlags = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $iButtonCopyToClipboard
            _GenerateFlags()
            ClipPut(_GenerateCode($sFlags))
            _Reset()
        Case $iButtonInsertIntoScite
            _GenerateFlags()
            _InsertIntoSciTE(_GenerateCode($sFlags))
            _Reset()
        Case $iButtonPreview
            _GenerateFlags()
            _Preview()
            _Reset()
    EndSwitch
WEnd

Func _Reset()
    $iFlags = 0
    $sFlags = ''
    $iPreviewFlags = 0
EndFunc

Func _GenerateCode($LsFlags = '')
    Local $sMsgBoxCode = ''
    $sMsgBoxCode &= 'MsgBox('
    If $iFlags > 1 Then
        $sMsgBoxCode &= 'BitOr(' & $LsFlags & ')'
    Else
        $sMsgBoxCode &= $LsFlags
    EndIf
    $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTitle)
    $sMsgBoxCode &= ', ' & GUICtrlRead($iEditText)
    If GUICtrlRead($iInputParentHandle) <> '' Then
        $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTimeout) & ', '
        $sMsgBoxCode &= GUICtrlRead($iInputParentHandle)
    ElseIf Guictrlread($iInputTimeout) <> 0 Then
        $sMsgBoxCode &= ', ' & GUICtrlRead($iInputTimeout)
    EndIf
    $sMsgBoxCode &= ')'
    Return $sMsgBoxCode
EndFunc

Func _GenerateFlags()
    If BitAND(GUICtrlRead($iRadioIconError), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONERROR', $MB_ICONERROR)
    ElseIf BitAnd(GUICtrlRead($iRadioIconQuestion), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONQUESTION', $MB_ICONQUESTION)
    ElseIf BitAnd(GUICtrlRead($iRadioIconWarning), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONWARNING', $MB_ICONWARNING)
    ElseIf BitAND(GUICtrlRead($iRadioIconInformation), $GUI_CHECKED) Then
        _AddToFlags('$MB_ICONINFORMATION', $MB_ICONINFORMATION)
    EndIf
    Switch GUICtrlRead($iComboButtons)
        Case $sOK
            _AddToFlags('')
        Case $sOKCANCEL
            _AddToFlags('$MB_OKCANCEL', $MB_OKCANCEL)
        Case $sABORTRETRYIGNORE
            _AddToFlags('$MB_ABORTRETRYIGNORE', $MB_ABORTRETRYIGNORE)
        Case $sYESNOCANCEL
            _AddToFlags('$MB_YESNOCANCEL', $MB_YESNOCANCEL)
        Case $sYESNO
            _AddToFlags('$MB_YESNO', $MB_YESNO)
        Case $sRETRYCANCEL
            _AddToFlags('$MB_RETRYCANCEL', $MB_RETRYCANCEL)
        Case $sCANCELTRYCONTINUE
            _AddToFlags('$MB_CANCELTRYCONTINUE', $MB_CANCELTRYCONTINUE)
    EndSwitch
    Switch GUICtrlRead($iComboDefButton)
        Case 'First'
            _AddToFlags('')
        Case 'Second'
            _AddToFlags('$MB_DEFBUTTON2', $MB_DEFBUTTON2)
        Case 'Third'
            _AddToFlags('$MB_DEFBUTTON3', $MB_DEFBUTTON3)
        Case 'Fourth'
            _AddToFlags('$MB_DEFBUTTON4', $MB_DEFBUTTON4)
    EndSwitch
    If BitAND(GUICtrlRead($iCheckboxMB_HELP), $GUI_CHECKED) Then _AddToFlags('$MB_HELP', $MB_HELP)
    If BitAND(GUICtrlRead($iCheckboxMB_SETFOREGROUND), $GUI_CHECKED) Then _AddToFlags('$MB_SETFOREGROUND', $MB_SETFOREGROUND)
    If BitAND(GUICtrlRead($iCheckboxMB_DEFAULT_DESKTOP_ONLY), $GUI_CHECKED) Then _AddToFlags('$MB_DEFAULT_DESKTOP_ONLY', $MB_DEFAULT_DESKTOP_ONLY)
    If BitAND(GUICtrlRead($iCheckboxMB_TOPMOST), $GUI_CHECKED) Then _AddToFlags('$MB_TOPMOST', $MB_TOPMOST)
    If BitAND(GUICtrlRead($iCheckboxMB_RIGHT), $GUI_CHECKED) Then _AddToFlags('$MB_RIGHT', $MB_RIGHT)
    If BitAND(GUICtrlRead($iCheckboxMB_RTLREADING), $GUI_CHECKED) Then _AddToFlags('$MB_RTLREADING', $MB_RTLREADING)
    If BitAND(GUICtrlRead($iCheckboxMB_SERVICE_NOTIFICATION), $GUI_CHECKED) Then _AddToFlags('$MB_SERVICE_NOTIFICATION', $MB_SERVICE_NOTIFICATION)
    Switch GUICtrlRead($iComboModality)
        Case 'Application'
            _AddToFlags('')
        Case 'System'
            _AddToFlags('$MB_SYSTEMMODAL', $MB_SYSTEMMODAL)
        Case 'Task'
            _AddToFlags('$MB_TASKMODAL', $MB_TASKMODAL)
    EndSwitch
EndFunc

Func _InsertIntoSciTE($sCode)
    If WinExists('[CLASS:SciTEWindow]') Then
        Local $sClip = ClipGet()
        ClipPut($sCode)
        ControlSend('[CLASS:SciTEWindow]', '', '[ID:350;CLASS:Scintilla]', '^v')
        ClipPut($sClip)
    Else
        MsgBox($MB_ICONERROR, 'Error', 'Cannot find SciTe window.')
    EndIf
EndFunc

Func _Preview()
    MsgBox($iPreviewFlags, GUICtrlRead($iInputTitle), GUICtrlRead($iEditText), GUICtrlRead($iInputTimeout), GUICtrlRead($iInputParentHandle))
EndFunc

Func _AddToFlags($LsFlag = '', $LiPreviewFlags = 0)
    If $LsFlag <> '' Then
        If $iFlags > 0 Then $sFlags &= ', '
        $sFlags &= $LsFlag
        $iFlags += 1
        $iPreviewFlags += $LiPreviewFlags
    EndIf
EndFunc

 

Awesome LongBowNZ!!! This could be very useful. Will test more and let you know. Thanks again.

Share this post


Link to post
Share on other sites
Myicq

Suggestion: a listbox to the left of this - perhaps using M23s slide-out-part - with library of message box content. I know from myself that I keep adding the same text to these things over and over.

Library should also remember state of options.

Nice work already though !


I am just a hobby programmer, and nothing great to publish right now.

Share this post


Link to post
Share on other sites
kyo

Suggestion: a listbox to the left of this - perhaps using M23s slide-out-part - with library of message box content. I know from myself that I keep adding the same text to these things over and over.

Library should also remember state of options.

Nice work already though !

That's a good idea too.

Kudos to LongBowNZ for that generator, it will prove useful!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      can we  create a list box with  Columns?
      welcome everybody
      Dears I have a question if you let me
      can we  create a list box with  Columns?
      i know we can create a list view with Columns
      but my question is about the list box
      I'm waiting your responses
      Thank you in advance
    • nacerbaaziz
      By nacerbaaziz
      Detect if the focus item is a button or check box
      Hello everyone.
      My dears I have a problem
      When I try to use
      ControlGetFocus function
      it  doesn't recognize the check  boxes.
      The result is that the selector is a button
      Although the specified is a check box
      but I want a way to identify the check boxes.
      Because I want to make a tool that helps screen readers users
      I hope you have the solution.
      Thank you in advance.
       
    • funkey
      By funkey
      Hello,
      it's quite often, that someone asks how to change the texts of the MsgBox buttons or the InputBox buttons or how to change the position of ta MsgBox. Since years I use CBT hooks for that, but now I made a small UDF out of it for the ease of use. Of course you can build your own GUI or use already existing UDFs to do the same, but I like this way and you can hack (hook) the inbuild InputBox.
       
      HookDlgBox.au3
      #include-once #include <WinAPI.au3> Global Const $tagCBT_CREATEWND = "ptr lpcs;HWND tagCBT_CREATEWND" Global Const $tagCREATESTRUCT = "ptr lpCreateParams;handle hInstance;HWND hMenu;HWND hwndParent;int cy;int cx;int y;int x;LONG style;ptr lpszName;ptr lpszClass;DWORD dwExStyle" Global $g__hProcDlgBox = DllCallbackRegister("__DlgBox_CbtHookProc", "int", "int;int;int") Global $g__TIdDlgBox = _WinAPI_GetCurrentThreadId() Global $g__hHookDlgBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($g__hProcDlgBox), 0, $g__TIdDlgBox) Global Const $g__MaxDlgBtns = 5 ; maximum of 5 buttons to rename text Global Const $g__MaxDlgItemId = 11 ; maximun ID of buttons to search is 11 as this is the maximun used in Messagebox Global $g__DlgBoxPosX, $g__DlgBoxPosY, $g__DlgBoxWidth, $g__DlgBoxHeight Global $g__aDlgBoxBtnText[$g__MaxDlgBtns] Global $g__DlgBtnCount = 0 _DlgBox_SetDefaults() OnAutoItExitRegister("__DlgBox_UnregisterHook") Func _DlgBox_SetButtonNames($TxtBtn1 = Default, $TxtBtn2 = Default, $TxtBtn3 = Default, $TxtBtn4 = Default, $TxtBtn5 = Default) $g__aDlgBoxBtnText[0] = $TxtBtn1 $g__aDlgBoxBtnText[1] = $TxtBtn2 $g__aDlgBoxBtnText[2] = $TxtBtn3 $g__aDlgBoxBtnText[3] = $TxtBtn4 $g__aDlgBoxBtnText[4] = $TxtBtn5 $g__DlgBtnCount = @NumParams EndFunc ;==>_DlgBox_SetButtonNames Func _DlgBox_SetPosition($x = Default, $y = Default) ;only for MsgBox, not working and not needed for InputBox $g__DlgBoxPosX = $x $g__DlgBoxPosY = $y EndFunc ;==>_DlgBox_SetPosition Func _DlgBox_SetSize($w = Default, $h = Default) $g__DlgBoxWidth = $w $g__DlgBoxHeight = $h EndFunc ;==>_DlgBox_SetSize Func _DlgBox_SetDefaults() $g__DlgBoxPosX = Default $g__DlgBoxPosY = Default $g__DlgBoxWidth = Default $g__DlgBoxHeight = Default For $i = 0 To UBound($g__aDlgBoxBtnText) - 1 $g__aDlgBoxBtnText[$i] = Default Next EndFunc ;==>_DlgBox_SetDefaults Func __DlgBox_CbtHookProc($nCode, $wParam, $lParam) Local $tcw, $tcs Local $iSearch = 0 Local $ahBtn[$g__DlgBtnCount] If $nCode < 0 Then Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndIf Switch $nCode Case 3 ;5=HCBT_CREATEWND If _WinAPI_GetClassName(HWnd($wParam)) = "#32770" Then ;Dialoig window class $tcw = DllStructCreate($tagCBT_CREATEWND, $lParam) $tcs = DllStructCreate($tagCREATESTRUCT, DllStructGetData($tcw, "lpcs")) If $g__DlgBoxPosX <> Default Then DllStructSetData($tcs, "x", $g__DlgBoxPosX) If $g__DlgBoxPosY <> Default Then DllStructSetData($tcs, "y", $g__DlgBoxPosY) If $g__DlgBoxWidth <> Default Then DllStructSetData($tcs, "cx", $g__DlgBoxWidth) If $g__DlgBoxHeight <> Default Then DllStructSetData($tcs, "cy", $g__DlgBoxHeight) EndIf Case 5 ;5=HCBT_ACTIVATE For $i = 1 To $g__MaxDlgItemId If IsHWnd(_WinAPI_GetDlgItem($wParam, $i)) Then If $g__aDlgBoxBtnText[$iSearch] <> Default Then _WinAPI_SetDlgItemText($wParam, $i, $g__aDlgBoxBtnText[$iSearch]) $iSearch += 1 If $iSearch >= UBound($ahBtn) Then ExitLoop EndIf Next EndSwitch Return _WinAPI_CallNextHookEx($g__hHookDlgBox, $nCode, $wParam, $lParam) EndFunc ;==>__DlgBox_CbtHookProc Func __DlgBox_UnregisterHook() _WinAPI_UnhookWindowsHookEx($g__hHookDlgBox) DllCallbackFree($g__hProcDlgBox) EndFunc ;==>__DlgBox_UnregisterHook Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText  
      Simple example to see how to use it
      #include "HookDlgBox.au3" _DlgBox_SetButtonNames("1", "two", "3") MsgBox(4, "Test 1", "Custom button texts") _DlgBox_SetPosition(20, 20) MsgBox(66, "Test 2", "Custom position and button texts") _DlgBox_SetButtonNames("Submit", "Don't submit", "Don't know") InputBox("Test 3", "Where were you born?", "Planet Earth") _DlgBox_SetSize(800, 800) InputBox("Test 4", "Where were you born?", "Planet Earth") _DlgBox_SetSize(Default, 800) MsgBox(66, "Test 5", "Strange but working") _DlgBox_SetButtonNames(Default, "Wait", "What?") _DlgBox_SetSize(Default, Default) _DlgBox_SetPosition(500, 500) MsgBox(66, "Test 6", "So far so good!") _DlgBox_SetDefaults() MsgBox(6, "Test 7", "Default position and button texts") Hope you like it.
       
      Best regards
      funkey
      HookDlgBox Example.au3
      HookDlgBox.au3
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys i am working on automating a flashing tool..When flashing is started if there is any error in connection it pops's up a error window...(as shown below)

       whenever this popup appears i need a msgbox to appear saying "error occured" how can i do this?
      Thanks

    • Nareshm
      By Nareshm
      I have autoit script like this :
      winActivate ("BillReceipt") ControlClick ( "BillReceipt", "", "[NAME:winviewer]", "right") Send ( "{ENTER}") WinWait ("Print") ControlClick ("Print", "", "[CLASS:Button; INSTANCE:13]") Winwait ("Save As") WinActivate ("Save As") Send ("{TAB 5} {Backspace} ^v {Enter}") I need Saved successfully msgbox with file name as i saved like Filename.extension (Example = test.pdf is saved successfull)

      Please Help
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.