gahhon Posted January 8, 2019 Posted January 8, 2019 I am using this Metro UDF for the application, and I have duplicate the existing InputBox function just for the Password input. expandcollapse popupFunc _Metro_InputPassword($Promt1, $Promt2, $Font_Size = 11, $DefaultText = "", $EnableEnterHotkey = True, $ParentGUI = "") Local $Metro_Input1, $Metro_Input2, $Metro_Input_GUI $Metro_Input_GUI = _Metro_CreateGUI(WinGetTitle($ParentGUI, "") & ".Input", 400, 270, -1, -1, False, $ParentGUI) _Metro_SetGUIOption($Metro_Input_GUI, True) GUICtrlCreateLabel($Promt1, 15 * $gDPI, 20 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") GUICtrlSetColor(-1, $FontThemeColor) GUICtrlCreateLabel($Promt2, 15 * $gDPI, 95 * $gDPI, 370 * $gDPI, 60 * $gDPI, BitOR(0x1, 0x0200), 0x00100000) GUICtrlSetFont(-1, $Font_Size, 400, 0, "Segoe UI") GUICtrlSetColor(-1, $FontThemeColor) $Metro_Input1 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 75 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32) GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") $Metro_Input2 = GUICtrlCreateInput($DefaultText, 16 * $gDPI, 150 * $gDPI, 370 * $gDPI, 28 * $gDPI, 32) GUICtrlSetFont(-1, 11, 500, 0, "Segoe UI") GUICtrlSetState($Metro_Input1, 256) GUICtrlSetState($Metro_Input2, 256) Local $cEnter = GUICtrlCreateDummy() Local $aAccelKeys[1][2] = [["{ENTER}", $cEnter]] Local $Button_Continue = _Metro_CreateButtonEx2("Continue", 90, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") GUICtrlSetState($Button_Continue, 512) Local $Button_Cancel = _Metro_CreateButtonEx2("Cancel", 210, 215, 100, 36, $ButtonBKColor, $ButtonTextColor, "Segoe UI") GUISetState(@SW_SHOW) If $EnableEnterHotkey Then GUISetAccelerators($aAccelKeys, $Metro_Input_GUI) EndIf If $mOnEventMode Then Opt("GUIOnEventMode", 0) ;Temporarily deactivate oneventmode While 1 $input_nMsg = GUIGetMsg() Switch $input_nMsg Case -3, $Button_Cancel _Metro_GUIDelete($Metro_Input_GUI) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode Return SetError(1, 0, "") Case $Button_Continue, $cEnter Local $User_Input1 = GUICtrlRead($Metro_Input1), $User_Input2 = GUICtrlRead($Metro_Input2) If ($User_Input1 <> $User_Input2) Then _Metro_GUIDelete($Metro_Input_GUI) Return SetError(2, 0, "Password Mismatch") ElseIf Not ($User_Input1 = "" Or $User_Input2 = "") Then _Metro_GUIDelete($Metro_Input_GUI) If $mOnEventMode Then Opt("GUIOnEventMode", 1) ;Reactivate oneventmode Return $User_Input1 EndIf EndSwitch WEnd EndFunc ;==>_Metro_InputPassword So now I have 2 labels and 2 Inputs, but the cursor always focus on the 2nd one. How can I make it focus on the 1st input instead? Thanks. Skysnake 1
Nine Posted January 8, 2019 Posted January 8, 2019 (edited) it is because focus of input2 comes after focus of input1 27 minutes ago, gahhon said: GUICtrlSetState($Metro_Input1, 256) GUICtrlSetState($Metro_Input2, 256) just remove second line, in fact just remove both lines Edited January 8, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
gahhon Posted January 9, 2019 Author Posted January 9, 2019 21 hours ago, Nine said: it is because focus of input2 comes after focus of input1 just remove second line, in fact just remove both lines Awesome. Thanks
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