#include-once #include #include #include #include ;=============================================================================== ; ; Function Name: _InputBoxEx() ; Description: Custom InputBox Function (GUI based). ; Parameter(s): $Title - The title of the Input Box. ; $Prmt - A message to the user indicating what kind of input is expected. ; $sDef - [Optional] The value that the input box starts with. ; $hWnd - [Optional] Window handle of the parent. ; $IsPass - [optional] If <> 0 Then typed characters will be replaced with password characters (*). ; $IsDig - [optional] If <> 0 Then only numbers can by typed to the input. ; $Limit - [optional] Limit the input for accept N characters. ; $W - [optional] The width of the window. Use -1 for default width (200). ; $H - [optional] The height of the window. Use -1 for default height (150). ; $Left - [optional] The left side of the input box. By default (-1), the box is centered. ; $Top - [optional] The top of the input box. By default (-1), the box is centered. ; $Style - [optional] Defines the style of the GUI window (forced style(s): $WS_SIZEBOX). ; $exStyle - [optional] Defines the extended style of the GUI window. -1 is the default. ; $InputExStyle - [optional] Defines the extended style of the input. -1 is the default. ; $iTOut - [optional] How many seconds to wait before automatically cancelling the InputBox. ; $WinBkgnd - [optional] The background color of the windows ; $InputBkgnd - [optional] The background color of the inputBox ; $FntSize - [optional] Font size ; $FntWgt - [optional] Font weight ; $FntAttb - [optional] Font attribute ; $FntName - [optional] Font name ; $FntColor - [optional] Font color ; ; Requirement(s): #include ; #include ; #include ; #include ; Return Value(s): String that was typed to the Input. ; Author(s): G.Sandler (a.k.a CreatoR). ; Updated by Tlem to made it like InputBox and to have ; colors/font control and Input Extented Style. ; Note(s): Original code : ; http://www.autoitscript.com/forum/index.php?showtopic=41403 ; ;=============================================================================== Func _InputBoxEx($Title,$Prmt,$sDef="",$hWnd="",$IsPass=0,$IsDig=0,$Limit=-1,$W=250,$H=180,$Left=-1,$Top=-1,$Style=0,$exStyle=0,$InputExStyle=-1,$iTOut=0,$WinBkgnd="",$InputBkgnd="",$FntSize=-1,$FntWgt=-1,$FntAttb=-1,$FntName=-1,$FntColor=-1) Local $OldOpt_GOEM = Opt("GuiOnEventMode", 0) WinSetState($hWnd, "", @SW_DISABLE) If $W < 200 Then $W = 200 If $H < 150 Then $H = 150 If $hWnd = "" Then $hWnd = WinGetHandle(WinGetTitle("")) EndIf Local $InputGui, $OKButton, $CancelButton, $InputBoxID Local $RetValue, $RetErr = 0, $InputMsg, $iTimerStart Local $InputStyle = 0 If $IsPass <> 0 Then $InputStyle += $ES_PASSWORD If $IsDig <> 0 Then $InputStyle += $ES_NUMBER $InputGui = GUICreate($Title, $W, $H, $Left, $Top, $WS_SIZEBOX+$Style, $exStyle, $hWnd) GuiSetIcon(@SystemDir & "\cmmon32.exe", 0) If $WinBkgnd <> "" Then GUISetBkColor($WinBkgnd) EndIf GUICtrlCreateLabel($Prmt, 10, 10, $W - 20, $H - 100) GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) GUICtrlSetFont(-1, $FntSize, $FntWgt, $FntAttb, $FntName) GUICtrlSetColor(-1, $FntColor) GUIRegisterMsg(0x24, "MY_WM_GETMINMAXINFO") $OKButton = GUICtrlCreateButton("OK", ($W/4)-38, $H-60, 76, 24, $BS_DEFPUSHBUTTON) GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR) GUICtrlSetState(-1, $GUI_ONTOP) $CancelButton = GUICtrlCreateButton("Annuler", ($W/2)+($W/4)-38, $H-60, 76, 24) GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR) GUICtrlSetState(-1, $GUI_ONTOP) $InputBoxID = GUICtrlCreateInput($sDef, 10, $H-85, $W-20, 20, $ES_AUTOHSCROLL+$InputStyle, $InputExStyle) GUICtrlSetResizing(-1, $GUI_DOCKSTATEBAR) GUICtrlSetState(-1, $GUI_FOCUS) If $InputBkgnd <> "" Then GUICtrlSetBkColor($InputBoxID,$InputBkgnd) EndIf If $Limit > 0 Then GUICtrlSetLimit(-1, $Limit) GUISetState(@SW_SHOW, $InputGui) If $iTOut > 0 Then $iTimerStart = TimerInit() While 1 $InputMsg = GUIGetMsg() Switch $InputMsg Case -12 ControlFocus($InputGui, "", $OKButton) ControlFocus($InputGui, "", $CancelButton) Case -3, $CancelButton $RetValue = "" $RetErr = 1 ExitLoop Case $OKButton $RetValue = GUICtrlRead($InputBoxID) $RetErr = 0 ExitLoop EndSwitch If $iTOut > 0 And Round(TimerDiff($iTimerStart)/1000) = $iTOut Then $RetValue = GUICtrlRead($InputBoxID) $RetErr = 2 ExitLoop EndIf WEnd WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($InputGui) GUISwitch($hWnd) Opt("GuiOnEventMode", $OldOpt_GOEM) Return SetError($RetErr, 0, $RetValue) EndFunc Func MY_WM_GETMINMAXINFO($hWnd, $Msg, $wParam, $lParam) Local $MinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int",$lParam) Local $MINGuiX = 200, $MINGuiY = 150, $MAXGuiX = 400, $MAXGuiY = 300 DllStructSetData($MinMaxInfo, 7, $MINGuiX) ; Min X DllStructSetData($MinMaxInfo, 8, $MINGuiY) ; Min Y DllStructSetData($MinMaxInfo, 9, $MAXGuiX) ; Max X DllStructSetData($MinMaxInfo, 10, $MAXGuiY) ; Max Y Return 0 EndFunc