anutt217 Posted November 4, 2021 Share Posted November 4, 2021 Hello, I'm new to using Autoit and I was wondering if there is a way to have text that is entered in one box show up in another box. Since everyone's username and email start the same (first.last name) at my work, I want it so all you have to type is the username and it will autofill in the email address. Any help would be greatly appriciated. #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1", 372, 218, 192, 124) GUISetBkColor(0x008080) $Username = GUICtrlCreateInput("Username", 35, 56, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Useremail = GUICtrlCreateInput("email", 35, 84, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_LOWERCASE,$ES_READONLY)) $Password = GUICtrlCreateInput("password", 35, 112, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Computer = GUICtrlCreateLabel("Computer Setup", 80, 8, 213, 34) GUICtrlSetFont(-1, 18, 400, 0, "Showcard Gothic") $Exit = GUICtrlCreateButton("Exit", 216, 168, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Useremail Send($Username & "@email.com") Case $Exit Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Solution Musashi Posted November 4, 2021 Solution Share Posted November 4, 2021 (edited) 44 minutes ago, anutt217 said: Since everyone's username and email start the same (first.last name) at my work, I want it so all you have to type is the username and it will autofill in the email address. Try this : #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1", 372, 218, 192, 124) GUISetBkColor(0x008080) $idUsername = GUICtrlCreateInput("Username", 35, 56, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $idUseremail = GUICtrlCreateInput("email", 35, 84, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_LOWERCASE,$ES_READONLY)) $idPassword = GUICtrlCreateInput("password", 35, 112, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Computer = GUICtrlCreateLabel("Computer Setup", 80, 8, 213, 34) GUICtrlSetFont(-1, 18, 400, 0, "Showcard Gothic") $Exit = GUICtrlCreateButton("Exit", 216, 168, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idUsername GUICtrlSetData($idUseremail, GUICtrlRead($idUsername) & "@email.com") Case $Exit Exit EndSwitch WEnd Edit : @anutt217 Explanation : GUICtrlCreateInput returns a controlID on success, not the data (in this case e.g. not the 'username') itself. To read or set the data you have to use GUICtrlRead or GUICtrlSetData. Edited November 4, 2021 by Musashi anutt217 and JockoDundee 1 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
anutt217 Posted November 4, 2021 Author Share Posted November 4, 2021 Thank you so must! Works like a charm. Link to comment Share on other sites More sharing options...
Zedna Posted November 8, 2021 Share Posted November 8, 2021 Here is modification which reacts on each keypress: #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### $Form1_1 = GUICreate("Form1", 372, 218, 192, 124) GUISetBkColor(0x008080) $idUsername = GUICtrlCreateInput("Username", 35, 56, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $idUseremail = GUICtrlCreateInput("email", 35, 84, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_LOWERCASE,$ES_READONLY)) $idPassword = GUICtrlCreateInput("password", 35, 112, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER)) $Computer = GUICtrlCreateLabel("Computer Setup", 80, 8, 213, 34) GUICtrlSetFont(-1, 18, 400, 0, "Showcard Gothic") $Exit = GUICtrlCreateButton("Exit", 216, 168, 123, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $Exit Exit EndSwitch WEnd Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_LoWord($wParam) = $idUsername And _WinAPI_HiWord($wParam) = $EN_CHANGE Then GUICtrlSetData($idUseremail, GUICtrlRead($idUsername) & "@email.com") EndIf EndFunc Musashi 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted November 8, 2021 Share Posted November 8, 2021 You can setup password *** mask by this (added ES_PASSWORD style): $idPassword = GUICtrlCreateInput("password", 35, 112, 305, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_PASSWORD)) Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Musashi Posted November 8, 2021 Share Posted November 8, 2021 36 minutes ago, Zedna said: Here is modification which reacts on each keypress: This is certainly the more elegant solution. I had it in mind as well (this question didn't arise for the first time), but wanted to stay as close to the OP's original code as possible so he could follow it . "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
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