Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/03/2014 in all areas

  1. LongBowNZ

    Message Box Generator

    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
    1 point
  2. ClipPut($iColor) Read the helpfile.
    1 point
  3. guinness, Hi "Cheese" M23
    1 point
  4. Call me cheese as I am on a roll today with code snippets! Example() Func Example() Local $sString = '3EDF35C6C10345A78F885679C86D701A' Local $aPos[] = [3, 6, 3, 7, 9] ; The positions. ConsoleWrite(_StringStringByPos($sString, $aPos) & @CRLF) $sString = 'ABCDE' $sString = _StringStringByPos($sString, $aPos) ConsoleWrite($sString & @CRLF) ; This will work as well, though 6,3,7,9 don't exist as the string is quite short. EndFunc ;==>Example Func _StringStringByPos($sString, ByRef $aPos) ; $aPos must be a zero based array of integer values. Local Const $STRING_LEN = StringLen($sString) If Not UBound($aPos) Or Not $STRING_LEN Then Return SetError(1, 0, $sString) Local $iGroup = 1, $iLength = $STRING_LEN, $iTotalPos = 0, _ $sReplacePattern = '', $sSearchPattern = '' For $i = 0 To UBound($aPos) - 1 $aPos[$i] = Int($aPos[$i]) $iLength -= $aPos[$i] $iTotalPos += $aPos[$i] If $iTotalPos > $STRING_LEN Then $iLength += $aPos[$i] ExitLoop EndIf $sSearchPattern &= '([[:xdigit:]]{' & $aPos[$i] - 1 & '})[[:xdigit:]]' ; Search pattern. $sReplacePattern &= '${' & $iGroup & '}' ; Replacement pattern. $iGroup += 1 ; Increment the replacement group value. Next If $iLength > 0 Then ; If there is values still remaining create a capture all group. $sSearchPattern &= '([[:xdigit:]]{' & $iLength - 1 & '})' $sReplacePattern &= '${' & $iGroup & '}' EndIf Return StringRegExpReplace($sString, $sSearchPattern, $sReplacePattern) EndFunc ;==>_StringStringByPos
    1 point
  5. You're right, it's a system-wide setting. On the other hand I've used it for years now and never had the problem that the state was not reset correctly, as the reset is fired when you let go the border. It might get stuck when your app exits while resizing; for that maybe use an exit function as outlined below. The only risk left then would be if your app crashes / the process is closed while you're resizing. ; http://www.autoitscript.com/forum/topic/55024-ho-to-set-resizing-without-displaying-window-content/#entry417869 ; by Siao #include <GUIConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> Opt("GUIOnEventMode", 1) Const $SC_MOVE = 0xF010 Const $SC_SIZE = 0xF000 Global $i_DRAGFULLWINDOWS_Current Global $i_DRAGFULLWINDOWS_Initial = _SPI_GETDRAGFULLWINDOWS() OnAutoItExitRegister("_Reset_DRAGFULLWINDOWS") Func _Reset_DRAGFULLWINDOWS() DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", $i_DRAGFULLWINDOWS_Initial, "ptr", 0, "int", 2) EndFunc ;==>_Reset_DRAGFULLWINDOWS $parent = GUICreate("GUI", 200, 400, -1, -1, $WS_SIZEBOX) ;~ GUIRegisterMsg($WM_ENTERSIZEMOVE, "WM_ENTERSIZEMOVE") GUIRegisterMsg($WM_EXITSIZEMOVE, "WM_EXITSIZEMOVE") GUIRegisterMsg($WM_SYSCOMMAND, "On_WM_SYSCOMMAND") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $Button = GUICtrlCreateButton("Button", 50, 100, 100, 21) GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func On_WM_SYSCOMMAND($hWnd, $Msg, $wParam, $lParam) Switch BitAND($wParam, 0xFFF0) Case $SC_MOVE, $SC_SIZE ;Const $SPI_SETDRAGFULLWINDOWS = 37 ;Const $SPI_GETDRAGFULLWINDOWS = 38 ;Const SPIF_SENDWININICHANGE = 2 $i_DRAGFULLWINDOWS_Current = _SPI_GETDRAGFULLWINDOWS() DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", 0, "ptr", 0, "int", 2) EndSwitch EndFunc ;==>On_WM_SYSCOMMAND Func WM_EXITSIZEMOVE() DllCall("user32.dll", "int", "SystemParametersInfo", "int", 37, "int", $i_DRAGFULLWINDOWS_Current, "ptr", 0, "int", 2) EndFunc ;==>WM_EXITSIZEMOVE Func _Exit() Exit EndFunc ;==>_Exit Func _SPI_GETDRAGFULLWINDOWS() $tBool = DllStructCreate("int") DllCall("user32.dll", "int", "SystemParametersInfo", "int", 38, "int", 0, "ptr", DllStructGetPtr($tBool), "int", 0) Return DllStructGetData($tBool, 1) EndFunc ;==>_SPI_GETDRAGFULLWINDOWS
    1 point
×
×
  • Create New...