Champak Posted August 16, 2023 Share Posted August 16, 2023 I want to activate a function based on any key up detection in an input, the function would enable/disable a button based on if the input is empty or not. The only way I can think of to do this INSTANTLY is put an if condition in the main while loop and I don't want to do that. Any other way would require some secondary interaction to enable/disable the button. Is there a better way to accomplish this? Link to comment Share on other sites More sharing options...
Danp2 Posted August 16, 2023 Share Posted August 16, 2023 You should be able to do this by subclassing the control. Lots of prior discussions on the topic if you do a search. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Solution KaFu Posted August 16, 2023 Solution Share Posted August 16, 2023 Register WM_COMMAND and look for the respective EN_UPDATE call. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiEdit.au3> #include <WinAPIConv.au3> Global $hGUI = GUICreate("Example") Global $c_Input = GUICtrlCreateInput("", 10, 10, 200, 20) Global $h_Input = GUICtrlGetHandle($c_Input) Global $c_Button = GUICtrlCreateButton("Test", 10, 50, 200, 20) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Local $nNotifyCode = _WinAPI_HiWord($wParam) Local $iId = _WinAPI_LoWord($wParam) Local $hCtrl = $lParam If $hCtrl = $h_Input Then If $nNotifyCode = $EN_UPDATE Then ; Sent when an edit control is about to redraw itself. This notification code is sent after the control has formatted the text, but before it displays the text. ; https://learn.microsoft.com/en-us/windows/win32/controls/en-update ConsoleWrite(GUICtrlRead($c_Input) & @CRLF) If GUICtrlRead($c_Input) Then GUICtrlSetState($c_Button, $GUI_DISABLE) Else GUICtrlSetState($c_Button, $GUI_ENABLE) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Zedna and Champak 1 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Champak Posted August 16, 2023 Author Share Posted August 16, 2023 Excellent, thanks. I was actually able to utilize this for another issue as well. 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