Jefrey Posted June 26, 2016 Posted June 26, 2016 Taking the idea from @Melba23's (btw, thanks ) ExtMsgBox and also making use of his StringSize UDF, I made a extended version of the InputBox function. From the README file: This UDF creates input boxes (just like native InputBox), but with multiple inputs. You can also set some inputs to be password-style, set the default texts for some of the edits and even set the label of the OK/cancel buttons. How to use _ExtInputBox($sTitle, $sTexts [ , $sDefaults = Null [ , $sPasswords = Null [ , $sBtnLabels = "OK|Cancel" [ , $iWidth = -1 [ , $iLeft = -1 [ , $iTop = -1 [ , $iTimeout = 0 [ , $hParent = 0 ] ] ] ] ] ] ] ] ) Arguments are: $sTitle (mandatory): The window title (e.g.: "Hello World") $sTexts (mandatory): The edit labels, separated by | (e.g.: "Your email|Your password") $sDefaults: The default input texts, separated by | (e.g.: "|you@us.com||" will tell that the first input will have nothing as default text, the second will have you@us.com as default text and the third and forth will also have nothing). Note that if you set the default value of 1 input, you must set the value of them all (even if it's nothing), otherwise all inputs will have no default value. Default is none. $sPasswords: One or more 1-based index of inputs, separated by anything that is not a number (pipeline - | - recommended), of the inputs that will receive password style (e.g.: "2|3" wíll tell that the second and third inputs are password-style, default is none) $sBtnLabels: The TWO label of the default OK/Cancel buttons (e.g.: "Submit|Close") $iWidth: Window width (default is the size of the longest string with the limit of 25% of the screen width). Obviously it's not possible to set the height as it's calculated automatically. $iLeft: Distance of the window from the left side of the screen (default is centered) $iTop: Distance of the window to the top of the screen (default is centered) $iTimeout: Time limit for filling the form data (default is none) $hParent: Parent form (default is none) Return value Sucess: an 1-based array with the input values entered ($aArray[1] = 1st input value, $aArray[2] = 2nd input value, $aArray[n] = nth input value, whereas $aArray[0] = input count) Failure: False, and set @extended to 1 if the user clicked cancel, 2 if the user closed the window, or 3 if timeout ended. Examples (two of them) #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Username|Password", Null, "2") If $sData = False Then MsgBox(0, "", "You pressed cancel, exit or timeout ended.") Else MsgBox(0, "You entered:", "Username: " & $sData[1] & @CRLF & "Password: " & $sData[2]) EndIf #include 'ExtInputBox.au3' $sData = _ExtInputBox("Login", "Your full name|Your email|Your telephone|Choose an username|Choose a password|Repeat password", "Mr./Ms. ||+1 |admin||", "5,6", "Register|Cancel") If $sData = False Then Switch @extended Case 1 MsgBox(0, "", "You clicked Cancel") Case 2 MsgBox(0, "", "You closed the window.") Case 3 MsgBox(0, "", "Timeout ended (but we have no timeout on this example, so this will never happen)") EndSwitch Else MsgBox(0, "You entered:", "Full name: " & $sData[1] & @CRLF & _ "Email: " & $sData[2] & @CRLF & _ "Telephone:" & $sData[3] & @CRLF & _ "Username: " & $sData[4] & @CRLF & _ "Password: " & $sData[5] & @CRLF & _ "Password repeat: " & $sData[6]) EndIf Download Download ZIP from GitHub Btw, fork me on Github sylremo, coffeeturtle, Gianni and 1 other 4 My stuff Spoiler My UDFs _AuThread multithreading emulation for AutoIt · _ExtInputBox an inputbox with multiple inputs and more features · forceUTF8 fix strings encoding without knowing its original charset · JSONgen JSON generator · _TCPServer UDF multi-client and multi-task (run on background) event-based TCP server easy to do · _TCPClient_UDF multi-server and multi-task (runs on background) event-based TCP client easy to do · ParseURL and ParseStr functions ported from PHP · _CmdLine UDF easily parse command line parameters, keys or flags · AutoPHP Create documents (bills, incomes) from HTML by sending variables/arrays from AutoIt to PHP · (Un)Serialize Convert arrays and data into a storable string (PHP compatible) · RTTL Plays and exports to MP3 Nokia-format monophonic ringtones (for very old cellphones) · I18n library Simple and easy to use localization library · Scripting.Dictionary OOP and OOP-like approach · Buffer/stack limit arrays to N items by removing the last one once the limit is reached · NGBioAPI UDF to work with Nitgen fingerprint readers · Serial/Licensing system require license key based on unique machine ID from your users · HTTP a simple WinHTTP library that allows GET, POST and file uploads · Thread true AutoIt threads (under-dev) · RC4 RC4 encryption compatible with PHP and JS · storage.au3 localStorage and sessionStorage for AutoIt Classes _WKHtmlToX uses wkhtmlto* to convert HTML files and webpages into PDF or images (jpg, bmp, gif, png...) Snippets _Word_DocFindReplaceByLongText replace strings using Word UDF with strings longer than 255 characters (MSWord limit) rangeparser parser for printing-like pages interval (e.g.: "1,2,3-5") EnvParser parse strings/paths with environment variables and get full path GUICtrlStaticMarquee static text scrolling Random stuff Super Mario beep sound your ears will hurt
TheSaint Posted June 26, 2016 Posted June 26, 2016 Very good. Thanks for sharing! Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
emendelson Posted March 6, 2020 Posted March 6, 2020 @Jefrey - This is an excellent script. Thank you! One request to you or to anyone else who might know the answer: Is it possible to make the Enter key have the same effect as clicking OK? With the script where I hope to use this input box, the user will normally accept the defaults, and it seems intuitive to press Enter. Is there an easy way to make the script allow this? Thank you again!
emendelson Posted March 8, 2020 Posted March 8, 2020 (edited) To answer my own question, I've made some very slight modifications to this excellent code. I've added a parameter that lets you specify the OK or Cancel button as the default (so the user can press Enter instead of clicking on the button) and also added some spacing between the fields and buttons and the dialog border. Here's the fork, with thanks to Jefrey: https://github.com/emendelson/extinputbox_au3 Edited March 8, 2020 by emendelson
TripScott Posted May 26, 2020 Posted May 26, 2020 how can I use a variable as a default? I am parsing data I copied & would like that to be in the input-box. when I try Quote $sData = _ExtInputBox("Entry", "First Name|Last Name|Date ymd|State|City|Media Type", || $sYear||$sCity, "Ok|Cancel") If $sData = False Then ... Else MsgBox(0, "You entered:", "First name: " & $sData[1] & @CRLF & _ "Last Name: " & $sData[2] & @CRLF & _ "Date:" & $sData[3] & @CRLF & _ "State: " & $sData[4] & @CRLF & _ "City: " & $sData[5] & @CRLF & _ "Media Type: " & $sData[6]) EndIf I receive an error. Looks like the defaults need to be in quotes, however that doesn't work with variables. What am I doing wrong? Thanks, Kristine
abberration Posted May 29, 2020 Posted May 29, 2020 Looks like you are missing the parameter for the number of input boxes. Easy MP3 | Software Installer | Password Manager
dersiniar Posted July 27, 2022 Posted July 27, 2022 On 5/27/2020 at 2:18 AM, TripScott said: how can I use a variable as a default? I am parsing data I copied & would like that to be in the input-box. when I try I receive an error. Looks like the defaults need to be in quotes, however that doesn't work with variables. What am I doing wrong? Thanks, Kristine I know its old post, But since I started to use this my self and I had same problem. But I figured it out. And i want to help others out who might have the same question. Use variables like this. Its working for me $sData = _ExtInputBox("Settings", "markup.|Extra days|Auto Update every x minutes|Where to save|Insert url to file|Enter your name|", $Add&"|"&$ExtraDays&"|"&$minutes&"|"&$drive&"|"&$Url&"|"&$UserRAW&"|", "Save|Cancel")
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