Razi Posted February 5, 2023 Posted February 5, 2023 (edited) Is there an OnKeyPress event in the Input GUI control? For example, need to create GUI form with 1 Input and 2 labels. And if any keyboard button was pressed in Input1 (or if the text in Input1 changed), then change text in label1, with current text from Input1. If the text in Input1 is not = nil/null or empty and 'Enter' keyboard button was pressed, then change text in the label2, with current text from Input1. Saw this OnKeyPress topic , but need a simpler example. Edited February 5, 2023 by Razi
ioa747 Posted February 5, 2023 Posted February 5, 2023 take a look in https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm maybe it help I know that I know nothing
Zedna Posted February 5, 2023 Posted February 5, 2023 (edited) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Func WM_COMMAND($hWinHandle, $iMsg, $wParam, $lParam) If _WinAPI_LoWord($wParam) = $idInput And _WinAPI_HiWord($wParam) = $EN_CHANGE Then ... EndIf EndFunc Look for example here Edited February 5, 2023 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
mistersquirrle Posted February 6, 2023 Posted February 6, 2023 I recommend that you also take a look at GUISetAccelerators: https://www.autoitscript.com/autoit3/docs/functions/GUISetAccelerators.htm We ought not to misbehave, but we should look as though we could.
ioa747 Posted February 6, 2023 Posted February 6, 2023 15 hours ago, Razi said: but need a simpler example. I thing this is a start #include <GUIConstantsEx.au3> Local $Form1 = GUICreate("Form1", 300, 150) Local $Label1 = GUICtrlCreateLabel("Tip new txt and hit enter", 10, 10, 280, 21) Local $Input1 = GUICtrlCreateInput("Tip new txt and hit enter", 10, 25, 280, 21) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Input1 Local $NewTxt = GUICtrlRead($Input1) If StringLen($NewTxt) > 0 Then GUICtrlSetData($Label1, $NewTxt) ConsoleWrite("New txt = " & $NewTxt & @CRLF) Else ConsoleWrite("! New txt must be somthing" & @CRLF) EndIf EndSwitch WEnd I know that I know nothing
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