lyly Posted October 25, 2022 Share Posted October 25, 2022 (edited) Hi How to force mouse wheel to perform same event like the upDown arrow ? (changing input box value) Thanks ly upDown_test.au3 Edited October 25, 2022 by lyly Link to comment Share on other sites More sharing options...
Nine Posted October 25, 2022 Share Posted October 25, 2022 Try this : expandcollapse popup#include <WinAPIShellEx.au3> #include <WinAPIConv.au3> #include <GUIConstants.au3> Global $hGUI = GUICreate("UpDown and scroll", -1, -1, -1, -1, $WS_SIZEBOX) Global $idInput = GUICtrlCreateInput("2", 10, 10, 50, 20) ;~ $hInput = GUICtrlGetHandle($idInput) Global $idUpdown = GUICtrlCreateUpdown($idInput) ;~ $hUpdown =GUICtrlGetHandle($idUpdown) GUISetState(@SW_SHOW) Global $hDll = DllCallbackRegister(SubclassProc, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') Global $pDll = DllCallbackGetPtr($hDll) _WinAPI_SetWindowSubclass($hGUI, $pDll, $idInput, 0) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() _WinAPI_RemoveWindowSubclass($hGUI, $pDll, 1000) DllCallbackFree($hDll) Func SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) If $iMsg = $WM_MOUSEWHEEL Then Local $iDelta = _WinAPI_HiWord($wParam) Local $iCurrent = GUICtrlRead($iID) GUICtrlSetData($iID, $iDelta > 0 ? $iCurrent + 1 : $iCurrent - 1) EndIf Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc mLipok 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted October 25, 2022 Share Posted October 25, 2022 A couple of years ago, I used the following code in one of my script, which registers the WM_MOUSEWHEEL message : #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_idInput GUICreate("UpDown and scroll", -1, -1, -1, -1, $WS_SIZEBOX) $g_idInput = GUICtrlCreateInput("2", 10, 10, 50, 20) Local $idUpdown = GUICtrlCreateUpdown($g_idInput) GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $g_idInput ; ConsoleWrite("here" & @crlf) EndSwitch WEnd ;================================================ Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) Local $iDistance = BitShift($wParam, 16) ; +120 or -120 (based on WHEEL_DELTA, which is 120 : msdn) Local $iCurrent = GUICtrlRead($g_idInput) GUICtrlSetData($g_idInput, $iDistance > 0 ? $iCurrent + 1 : $iCurrent - 1) Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL @Nine subclassing a window or registering a message, do you think one method could be preferred to the other ? Or are there equivalents ? Thanks Link to comment Share on other sites More sharing options...
lyly Posted October 25, 2022 Author Share Posted October 25, 2022 Hi Pixelsearch Thanks a lot it works🙂 ly Link to comment Share on other sites More sharing options...
Nine Posted October 25, 2022 Share Posted October 25, 2022 I thought that if you have multiple input boxes, it would be easier to subclass each box individually. “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
pixelsearch Posted October 25, 2022 Share Posted October 25, 2022 (edited) @Nine thanks for your answer @lyly as there are probably other controls in your GUI, then you'll have to take care of not modifying inadvertently the input box value when "mouse wheeling" anywhere in the GUI To prevent that, this is (basically) what I did in my WM_MOUSEWHEEL function, where 2 GUI's were involved : Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) Local $iDistance = BitShift($wParam, 16) ; +120 or -120 (based on WHEEL_DELTA, which is 120 : msdn) ; MouseWheel when GUI Preview exists (interactive resize of any previewed image) ; .................................. If $hGUI_Preview Then ... ; process the resize of the previewed image Return $GUI_RUNDEFMSG EndIf ; MouseWheel when GUI Preview doesn't exist (interactive modification of 7 possible Input fields in main GUI) => update of one field ; ......................................... Local $aInfo = GUIGetCursorInfo($hGUI_Main) If IsArray($aInfo) Then Switch $aInfo[4] ; ID of the control that the mouse cursor is hovering over (or 0 if none) Case $idInput11 ... Case $idInput12 ... Case ... ... EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL So as you see, in case you got several input fields "mouse wheelables", you'll have to hover over the concerned input field, then start the mouse wheeling. The input field taken care of will be the one retrieved by this line in the fuction : Local $aInfo = GUIGetCursorInfo($hGUI_Main) Good luck Edited October 25, 2022 by pixelsearch Link to comment Share on other sites More sharing options...
lyly Posted October 25, 2022 Author Share Posted October 25, 2022 Hi again I just was thinking about that as i will have much more than one edit controls, I will try with 2 controls and see what is going on... Thanks again ly Link to comment Share on other sites More sharing options...
lyly Posted October 25, 2022 Author Share Posted October 25, 2022 Hi pixelsearch I have done with 2 edit controls and it works as yousaid each edit has different number changes. Thanks again I did not use: $hGUI_Preview as it not included in my script and I think I do not need it, I only need about 10 edit control each with different number changes. If $hGUI_Preview Then ... ; process the resize of the previewed image Return $GUI_RUNDEFMSG EndIf Link to comment Share on other sites More sharing options...
lyly Posted October 25, 2022 Author Share Posted October 25, 2022 Hi Nine Where I can find : #include <WinAPIConv.au3> Link to comment Share on other sites More sharing options...
Nine Posted October 25, 2022 Share Posted October 25, 2022 It is part of base package. Maybe install latest version. “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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
lyly Posted October 25, 2022 Author Share Posted October 25, 2022 Hi Nine I have an old version I will install anew version... Thanks ly 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