kara2004 Posted February 24, 2019 Share Posted February 24, 2019 Hi there, while looking around to control sliders with the mouse wheeI I found MouseOnEvent.au3 which seems to fit my needs. But there's a strange behaviour, which I can't locate (my env Win 7x64 with au3 3.3.14.5, the UDF or the slider itself): Using the mouse wheel to change the slider the value shown/set is always "one step behind". I made a simple gui with one slider (limit -10 to 10) and after ten wheel moves the slider looks correct, but the label shows '9' (see picture "slider_1.jpg" which shows the gui after 10 wheel moves). A manual mouse click at the slider control at this time adjusts the label to the correct value (see picture "slider_2.jpg") but using the wheel ro get a value of "10" (or -10) I have to scroll eleven times. The UDF seems to work correct, every event is recognized (checked with additional debug messages added), controlling the slider with arrow keys or direct via left mouse button shows the correct value at the label. Probably it's just a simple problem with the code, but I have no idea for getting the expected behaviour (Note: I renamed the udf to '_MouseOnEvent.au3' to get all udfs togeter in my code directory). Thanks for any suggestion or correction. kara expandcollapse popup#include <_MouseOnEvent.au3> #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 567, 148, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $Slider1 = GUICtrlCreateSlider(8, 8, 497, 33) GUICtrlSetLimit(-1, 10, -10) GUICtrlSetData(-1, 0) GUICtrlSetOnEvent(-1, "Slider1Change") Global $Label1 = GUICtrlCreateLabel("", 512, 8, 36, 17) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) _MouseSetOnEvent($MOUSE_WHEELSCROLLUP_EVENT, "MOUSE_WHELLSCROLL_UP", $Form1) _MouseSetOnEvent($MOUSE_WHEELSCROLLDOWN_EVENT, "MOUSE_WHELLSCROLL_DOWN", $Form1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _sciteClearConsole() While 1 Sleep(100) WEnd Exit Func Form1Close() Exit EndFunc ;==>Form1Close Func Slider1Change() ConsoleWrite("SL_CHNG:" & GUICtrlRead($Slider1) & @CRLF) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) EndFunc ;==>Slider1Change Func MOUSE_WHELLSCROLL_UP() ConsoleWrite("SCRL_UP:" & GUICtrlRead($Slider1) & @CRLF) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) EndFunc ;==>MOUSE_WHELLSCROLL_UP Func MOUSE_WHELLSCROLL_DOWN() ConsoleWrite("SCRL_DOWN:" & GUICtrlRead($Slider1) & @CRLF) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) EndFunc ;==>MOUSE_WHELLSCROLL_DOWN Link to comment Share on other sites More sharing options...
Nine Posted February 24, 2019 Share Posted February 24, 2019 (edited) Opt ("GUIOnEventMode", 1) is missing at the top of your script... GUICtrlSetState ($Slider1, $GUI_FOCUS) Maybe for some reason, you are loosing focus on the slider so add this line in both up and down functions. Edited February 24, 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) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
kara2004 Posted February 25, 2019 Author Share Posted February 25, 2019 Thanks for your reply, Nine - but that didn't help. Link to comment Share on other sites More sharing options...
careca Posted February 25, 2019 Share Posted February 25, 2019 (edited) expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Misc.au3> #include <File.au3> #include <Array.au3> #include <WinAPI.au3> #include <String.au3> #include <Timers.au3> #include <GuiEdit.au3> #include <GDIPlus.au3> #include <Process.au3> #include <WinAPIEx.au3> #include <WinAPISys.au3> #include <GuiButton.au3> #include <Constants.au3> #include <GuiSlider.au3> #include <WinAPISys.au3> #include <WinAPIMisc.au3> #include <GuiToolTip.au3> #include <GUIListBox.au3> #include <GuiListView.au3> #include <GuiStatusBar.au3> #include <GUIConstants.au3> #include <GuiImageList.au3> #include <TrayConstants.au3> #include <FileConstants.au3> #include <GuiComboBoxEx.au3> #include <GUIConstantsEx.au3> #include <APISysConstants.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <SliderConstants.au3> #include <ButtonConstants.au3> #include <WindowsConstants.au3> #include <ListViewConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= Global $Form1 = GUICreate("Form1", 567, 148, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") Global $Slider1 = GUICtrlCreateSlider(8, 8, 497, 33) GUICtrlSetLimit($Slider1, 10, -10) GUICtrlSetData($Slider1, 0) Global $Label1 = GUICtrlCreateLabel("", 512, 8, 36, 17) ;============================================================================= Local $iFlags, $aData Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', 0x01) ; Generic Desktop Controls DllStructSetData($tRID, 'Usage', 0x02) ; Mouse DllStructSetData($tRID, 'Flags', $RIDEV_INPUTSINK) DllStructSetData($tRID, 'hTarget', $Form1) _WinAPI_RegisterRawInputDevices($tRID) GUIRegisterMsg($WM_INPUT, 'WM_INPUT') ;============================================================================= GUICtrlSetData($Label1, GUICtrlRead($Slider1)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) WEnd Func Form1Close() Exit EndFunc ;==>Form1Close Func MOUSE_WHELLSCROLL_UP() ConsoleWrite("SCRL_UP:" & GUICtrlRead($Slider1) & @CRLF) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) EndFunc ;==>MOUSE_WHELLSCROLL_UP Func MOUSE_WHELLSCROLL_DOWN() ConsoleWrite("SCRL_DOWN:" & GUICtrlRead($Slider1) & @CRLF) GUICtrlSetData($Label1, GUICtrlRead($Slider1)) EndFunc ;==>MOUSE_WHELLSCROLL_DOWN ;============================================================================= Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam If WinActive("[CLASS:YOURWINDOWCLASS]") <> 0 Then Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE) If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then $iFlags = DllStructGetData($tRIM, 'ButtonFlags') If BitAND($iFlags, $RI_MOUSE_WHEEL) Then $aData = _WinAPI_WordToShort(DllStructGetData($tRIM, 'ButtonData')) If $aData > 0 Then ;ConsoleWrite(' - Up - '&@CRLF) MOUSE_WHELLSCROLL_UP() Else ;ConsoleWrite(' - Down - '&@CRLF) MOUSE_WHELLSCROLL_DOWN() EndIf Else ToolTip('') EndIf EndIf Return $GUI_RUNDEFMSG EndIf Return $GUI_RUNDEFMSG Sleep(50) EndFunc ;==>WM_INPUT Edited February 26, 2019 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
kara2004 Posted February 26, 2019 Author Share Posted February 26, 2019 Hi careca, this works as expected. Looks like there's something wrong with MouseOnEvent.au3 - maybe only in this example/case!? Now I'll need some time to figure out, what you've done an how it works Thanks for your response kara2004 careca 1 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