WildByDesign Posted Tuesday at 05:15 PM Posted Tuesday at 05:15 PM I am adding a feature to a project that detects changes in Input boxes. It already successfully detects changes and displays a "Unsaved Changes" label in the GUI. If I undo those changes, the "Unsaved Changes" label is hidden. I'm kind of proud of myself for figuring that part out. I am using WM_COMMAND to detect the changes. However, when I tried the same technique with Slider controls, it did not work. And I was kind of expecting it to fail. I checked over the SliderConstants.au3 file to see if there was anything that I could work with in there. I could probably do something with GUICtrlSetOnEvent since this project uses OnEvent mode. But I was really hoping to monitor the Slider value changes in WM_COMMAND so that it's all together with the Input controls. Does anyone know if it's possible to watch for Slider value changes in WM_COMMAND? Thank you expandcollapse popupFunc ED_WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local Static $b01 = True, $b02 = True, $b03 = True, $b04 = True, $b05 = True, $b06 = True, $b07 = True, $b08 = True, $b09 = True Local Static $b10 = True, $b11 = True, $b12 = True, $b13 = True, $b14 = True, $b15 = True Local $iCode = BitShift($wParam, 16) Case GUICtrlGetHandle($BorderColorInput) Switch $iCode Case $EN_SETFOCUS $bWatchSaveChanges = True Case $EN_CHANGE If $bWatchSaveChanges And GUICtrlRead($BorderColorInput) <> $sWatchBorderColorInput Then GUICtrlSetState($idPart4, $GUI_SHOW) $b01 = False Else $b01 = True If $bWatchSaveChanges Then If $b01 And $b02 And $b03 And $b04 And $b05 And $b06 And $b07 And $b08 And $b09 And $b10 And $b11 And $b12 And $b13 And $b14 And $b15 Then GUICtrlSetState($idPart4, $GUI_HIDE) EndIf EndIf EndIf EndSwitch Case GUICtrlGetHandle($TitlebarColorInput) Switch $iCode Case $EN_SETFOCUS $bWatchSaveChanges = True Case $EN_CHANGE If $bWatchSaveChanges And GUICtrlRead($TitlebarColorInput) <> $sWatchTitlebarColorInput Then GUICtrlSetState($idPart4, $GUI_SHOW) $b02 = False Else $b02 = True If $bWatchSaveChanges Then If $b01 And $b02 And $b03 And $b04 And $b05 And $b06 And $b07 And $b08 And $b09 And $b10 And $b11 And $b12 And $b13 And $b14 And $b15 Then GUICtrlSetState($idPart4, $GUI_HIDE) EndIf EndIf EndIf EndSwitch Case GUICtrlGetHandle($BlurColorIntensitySliderInact) Switch $iCode Case $EN_SETFOCUS $bWatchSaveChanges = True Case $EN_CHANGE If $bWatchSaveChanges And GUICtrlRead($BlurColorIntensitySliderInact) <> $sWatchBlurColorIntensitySliderInact Then ConsoleWrite("slider trigger" & @CRLF) GUICtrlSetState($idPart4, $GUI_SHOW) $b03 = False Else $b03 = True If $bWatchSaveChanges Then If $b01 And $b02 And $b03 And $b04 And $b05 And $b06 And $b07 And $b08 And $b09 And $b10 And $b11 And $b12 And $b13 And $b14 And $b15 Then GUICtrlSetState($idPart4, $GUI_HIDE) EndIf EndIf EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>ED_WM_COMMAND
SOLVE-SMART Posted Tuesday at 05:46 PM Posted Tuesday at 05:46 PM I am on my smartphone, without any coding possibilities right now, but why do you want to go with WD_COMMAND? You could also try using AdLibRegister to register a function that constantly checks for slider value updates (simple polling). I guess in a GUI each 250ms is totally enough to check and trigger the label change (hint text etc.). Just another approach which is easily implemented in my point of view. Besides that @WildByDesign , best regards as usually, Sven 😀 . WildByDesign 1 ==> AutoIt related: 🔗 GitHub, 🔗 Discord Server, 🔗 Cheat Sheet, 🔗 autoit-webdriver-boilerplate Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
WildByDesign Posted Tuesday at 05:56 PM Author Posted Tuesday at 05:56 PM 4 minutes ago, SOLVE-SMART said: but why do you want to go with WD_COMMAND? The reason why I decided to go with WM_COMMAND is because I already had it in place to do some things with comboboxes. So I only ended up having to add "Case $EN_CHANGE" for each Input box to deal with changes. Also, there are 13 input boxes plus 2 slider controls. So it just seemed like the best option for me. 7 minutes ago, SOLVE-SMART said: You could also try using AdLibRegister to register a function that constantly checks for slider value updates (simple polling). I guess in a GUI each 250ms is totally enough to check and trigger the label change (hint text etc.). This is a good idea. I've used AdLibRegister before in a few projects. This should do the job, for sure. I'll wait a bit and see what other possible suggestions may come along. Although I feel like sliders aren't used a lot so there may not be too much to reference. I'll do some more reading into it as well. Best regards as well. Cheers! SOLVE-SMART 1
pixelsearch Posted Tuesday at 06:10 PM Posted Tuesday at 06:10 PM 49 minutes ago, WildByDesign said: Does anyone know if it's possible to watch for Slider value changes in WM_COMMAND? @Melba23 does it nicely, not in WM_COMMAND, by using $SB_THUMBTRACK via a $WM_H/VSCROLL message, in this post, Hope it helps. WildByDesign 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
WildByDesign Posted Tuesday at 06:14 PM Author Posted Tuesday at 06:14 PM 2 minutes ago, pixelsearch said: @Melba23 does it nicely, not in WM_COMMAND, by using $SB_THUMBTRACK via a $WM_H/VSCROLL message, in this post, Hope it helps. That looks like a perfect option. I’m away from my PC right now but I will give it a try in a few hours. Thank you.
Solution Nine Posted Tuesday at 07:57 PM Solution Posted Tuesday at 07:57 PM For the record, you need to use WM_NOTIFY not WM_COMMAND. Here a working example how to use $TRBN_THUMBPOSCHANGING on Win11 (didn't test on other OS). expandcollapse popup#include <GUIConstants.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", True) Global Const $TRBN_THUMBPOSCHANGING = -1502 Global Const $tagTRBTHUMBPOSCHANGING = $tagNMHDR & ";dword Pos;int Reason" Global Const $TBS_NOTIFYBEFOREMOVE = 2048 Global $idSlider Example() Func Example() Local $hGUI = GUICreate("Example", 500, 500) $idSlider = GUICtrlCreateSlider(10, 10, 200, 20, $TBS_NOTIFYBEFOREMOVE) GUISetState() GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) Local $tChange = DllStructCreate($tagTRBTHUMBPOSCHANGING, $lParam) If $tChange.IDfrom = $idSlider And $tChange.Code = $TRBN_THUMBPOSCHANGING Then ConsoleWrite("Position = " & $tChange.Pos & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY SOLVE-SMART 1 “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
WildByDesign Posted Tuesday at 11:03 PM Author Posted Tuesday at 11:03 PM 3 hours ago, Nine said: For the record, you need to use WM_NOTIFY not WM_COMMAND. Here a working example how to use $TRBN_THUMBPOSCHANGING on Win11 (didn't test on other OS). This is beautiful, fast and accurate. This is exactly what I was hoping for. Thank you for your time, I appreciate it.
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