MrCreatoR Posted February 20, 2007 Posted February 20, 2007 (edited) Hi to all!Custom (GUI-Based) version of the Build-in function InputBox():;=============================================================================== ; ; Function Name: _InputBox() ; 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. ; $iTOut - [optional] How many seconds to wait before automatically cancelling the InputBox. ; ; Requirement(s): #include <GuiConstants.au3>. ; Return Value(s): String that was typed to the Input. ; Author(s): G.Sandler (a.k.a CreatoR). ; Note(s): None. ; ;===============================================================================Example + UDF:_InputBox.au3[NEW]_InputBox.au3========================================EDIT 1:Added $Timeout param - It allows to set timeout (in seconds), just like in the original function InputBox().EDIT 2:Added focus of input when window is shown.EDIT 3:Added $IsDigits param - it allows to set the behaviour of typing in the input - if this parametr set to 1, then only digits can be typed in the InputBox.EDIT 4:Change the way that parent window is disabled (now its by WinSetState() - so its' work not just for Gui).EDIT 5:Change te example, now there is no parent gui, the inputbox is “attached” to currently active window.EDIT 6:Change the function completly - * Now it is possible to set limit for entered string, * the promt text is displayed more correct now, * and the input text are scrollable now ($ES_AUTOHSCROLL).EDIT 7:The Example + UDF attached to the post.+ Little "cosmetic corrections" in the functions.EDIT 8: (19.11.2007)+ Added full description/comments to the main function.* Changed example a little.* Now the function and the example required #include <GuiConstants.au3> (see bellow why).* The function now is stripped from “Magic Numbers” Edited July 28, 2012 by MrCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Sardith Posted February 26, 2007 Posted February 26, 2007 You version has a lot of issues. Ie. The Ok and Cancel buttons don't work. You set styles, which cause some styles to be predefined. I'd leave it up to the user to define which styles they'd like. I used a lot of smokes as a building block. My code works well. Func _InputBox($Title, $Text = "", $Width = 200, $Height = 75, $Left = -1, $Top = -1, $OnTop = 1, $nInStyle = -1, $nInStyleEx = -1, $IsPassword=0, $IsDigits=0, $Timeout = 0) $hWnd = WinGetHandle(WinGetTitle("")) Local $aCID[5], $Y = 0, $sRead If $Left = -1 Or $Left = Default Then $Left = @DesktopWidth / 2.5 If $Top = -1 Or $Top = Default Then $Right = @DesktopHeight / 2.5 If $Width < 175 Then $Width = 175 If $Height < 75 Then $Height = 75 If $Text <> '' Then $Y = 20 Local $hGUI = GUICreate($Title, $Width, $Height + $Y, $Left, $Top) If $Text <> '' Then $aCID[1] = GUICtrlCreateLabel($Text, 10, 10, $Width - 20, 20, $ES_CENTER) If $IsPassword <> 0 Then $IsPassword = 32 If $IsDigits <> 0 Then $IsDigits = 8192 $aCID[2] = GUICtrlCreateInput('', 10, 10 + $Y, $Width - 20, 20, $nInStyle & $IsPassword+$IsDigits, $nInStyleEx) $aCID[3] = GUICtrlCreateButton('OK', (($Width - 150) / 2), 40 + $Y, 75, 25, $BS_DEFPUSHBUTTON) $aCID[4] = GUICtrlCreateButton('Cancel', (($Width - 150) / 2) + 80, 40 + $Y, 75, 25) WinSetOnTop($hGUI, '', $OnTop) GUISetState() If $Timeout > 0 Then $TimerStart = TimerInit() While 1 Switch GUIGetMsg() Case - 3, $aCID[4] Exit Case $aCID[3] $sRead = GUICtrlRead($aCID[2]) Return $sRead EndSwitch If $Timeout > 0 And Round(TimerDiff($TimerStart)/1000) = $Timeout Then $RetValue = GUICtrlRead($aCID[2]) WinSetState($hWnd, "", @SW_ENABLE) GUIDelete($aCID[2]) SetError(2) Return $RetValue EndIf WEnd EndFunc [font="Verdana"]Valik:Get it straight - I'm not here to say please, I'm here to help - if my help's not appreciated then lotsa luck, gentlemen.[/font]
MrCreatoR Posted February 26, 2007 Author Posted February 26, 2007 (edited) You version has a lot of issuesAnd your's even more - You say:I'd leave it up to the user to define which styles they'd likeBut what about $ES_CENTER and $BS_DEFPUSHBUTTON - i have no #Include <GuiConstants.au3> at the begining of script, and what i get? right, an error (Variable used without being declared).And also, you set in the function the title of the window (Win handle), its not ok, it should be like an option that user can set. And what for do you need it (in your changed func), if there is no disabling of that window (to allow “attaching” of input to that window).In my function, there is default forced styles (just like in many original funnctions), this is for the resizing - 0x00040000, and for the input there is the style that make it look better (0x00000001), and some styles for set the resizing behaviour. And if user want to add more styles, he can do it easily, just like with other functions that have a styles.The Ok and Cancel buttons don't workIf you use the example that i provided in my first post, you will see that everything work fine! Edited February 26, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted July 4, 2007 Author Posted July 4, 2007 Edit first post, the function now more reliable now :"> EDIT 6:Change the function completly - * Now it is possible to set limit for entered string, * the promt text is displayed more correct now, * and the input text are scrollable now ($ES_AUTOHSCROLL). Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Mast3rpyr0 Posted July 4, 2007 Posted July 4, 2007 This should be in Example Scripts should it not? My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here!
MrCreatoR Posted July 4, 2007 Author Posted July 4, 2007 (edited) I post it there, i don't know what wrong with the forum, and this is not the first time that topics are moved without any warning/message....To Moderators:Please, put it back to Example forum, it should be there i think (it is not "help asking" topic or something ).Thanks . Edited August 12, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted November 19, 2007 Author Posted November 19, 2007 First post updated! The function rewrited again (i hope that is the last time). Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now