pixelsearch Posted October 31, 2020 Share Posted October 31, 2020 (edited) Hi everybody I got an issue with the mousewheel message : it stops working under certain conditions. expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> HotKeySet("{ESC}", "_Wanna_Quit") $hGUI = GUICreate("MouseWheel issue", 400, 300, 100, 100) $idControl = GUICtrlCreateLabel("Label #0", _ 0, 0, 400, 300, BitOr($SS_CENTERIMAGE, $SS_CENTER)) GUISetState() GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") $Inc = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Exit() Case $GUI_EVENT_PRIMARYDOWN $Inc += 1 If GUICtrlDelete($idControl) = 0 Then ; 0 = failure, 1 = success MsgBox($MB_TOPMOST, "Error", "Control not deleted") _Exit() EndIf $idControl = GUICtrlCreateLabel("Label #" & $Inc, _ 0, 0, 400, 300, BitOr($SS_CENTERIMAGE, $SS_CENTER)) ; WinActivate($hGUI) EndSwitch WEnd ;==================================================== Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) Local Static $iCount = 0 $iCount +=1 ConsoleWrite($iCount & @lf) Return $GUI_RUNDEFMSG EndFunc ; WM_MOUSEWHEEL ;==================================================== Func _Wanna_Quit() HotKeySet("{ESC}") If MsgBox(BitOr($MB_TOPMOST, $MB_OKCANCEL), _ "Esc was keyed", "Quit script ?") = $IDOK Then _Exit() EndIf HotKeySet("{ESC}", "_Wanna_Quit") EndFunc ; _Wanna_Quit ;==================================================== Func _Exit() GUIDelete($hGUI) Exit EndFunc ; _Exit If you run this script and immediately turn the mouse wheel up or down, you will notice its counter correctly incremented in the Console. So far so good... Now if you left click inside the GUI, it will delete the label control #0 and replace it with a new label control #1 ... and after that the mouse wheel doesn't respond at all. Then if you key Escape (asking you to quit the script or not), choose not to quit... and the mouse wheel is reactivated ! Anyone noticed such a strange behavior ? Edit: this is a "kind of" reproducer of the issue. In fact it happens in a more complicated script, with a parent gui + a child gui, the left click deleting the child gui (and the pic control inside it), before a new child gui is created with a new pic in it : now the mousewheel doesn't respond in the 2nd pic... unless I click Escape, choosing not to quit etc... exactly the same issue as described in the script above. Thanks for any advice. Edited October 31, 2020 by pixelsearch [Solved] in topic title Link to comment Share on other sites More sharing options...
Nine Posted October 31, 2020 Share Posted October 31, 2020 (edited) 10 minutes ago, pixelsearch said: Now if you left click inside the GUI, it will delete the label control #0 and replace it with a new label control #1 ... and after that the mouse wheel doesn't respond at all. Nope, still works for me. Number keeps incrementing in console after. Edit : I was able to reproduce you issue. But by minimizing and restoring the GUI it starts working well. So I suppose (without any testing) that it refers to some kind of focus lost.... Edited October 31, 2020 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...
pixelsearch Posted October 31, 2020 Author Share Posted October 31, 2020 Thanks Nine for the test Link to comment Share on other sites More sharing options...
Nine Posted October 31, 2020 Share Posted October 31, 2020 Please see my edit, in case you missed it, we just submit at the same time. “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...
Musashi Posted October 31, 2020 Share Posted October 31, 2020 12 minutes ago, pixelsearch said: Anyone noticed such a strange behavior ? I do not have a solution, but I can reproduce the behaviour you describe. "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted October 31, 2020 Share Posted October 31, 2020 Yep, my first assumption seems to be right. Just put this after changing label : ControlFocus ($hGUI,"", "") pixelsearch 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...
Musashi Posted October 31, 2020 Share Posted October 31, 2020 This also seems to work : ... Case $GUI_EVENT_PRIMARYDOWN ... $idControl = GUICtrlCreateLabel("Label #" & $Inc, _ 0, 0, 400, 300, BitOr($SS_CENTERIMAGE, $SS_CENTER)) GUICtrlSetState($idControl, $GUI_FOCUS) ... pixelsearch 1 "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Nine Posted October 31, 2020 Share Posted October 31, 2020 @Musashi “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 31, 2020 Author Share Posted October 31, 2020 (edited) Same as both of you, it works by minimizing and restoring the GUI but how could we improve this behavior ? I felt for a long time that MsgBox in _Wanna_Quit() solved this issue because it gave back the focus to the GUI when we choose not to quit, but after that, even if we activate again the GUI in the script, it's not enough. You'll never imagine how it happened to me the 1st time in my real script : I use the mouse wheel to resize pics, with a dynamic tooltip displayed at the top of the GUI As soon as I click on the ToolTip, the issue will start because clicking on the tooltip => GUI loses focus and I never found any AutoIt instruction to get the focus back and solve this mouse wheel issue. Edit: just read Nine's last answer, gonna see how to implement this solution in my real script, after the new child window is created : ControlFocus ($hGUI,"", "") It works in my real script, bravo Nine How did you find this ? Especially you didn't indicate any controlID in the command ! Thanks Musashi, you made it work too ! Edited October 31, 2020 by pixelsearch Link to comment Share on other sites More sharing options...
pixelsearch Posted October 31, 2020 Author Share Posted October 31, 2020 My only regret ? I should have exposed my issue days ago in the Forum, many thanks guys Musashi 1 Link to comment Share on other sites More sharing options...
Nine Posted October 31, 2020 Share Posted October 31, 2020 5 minutes ago, pixelsearch said: How did you find this ? Well, I have seem something similar in the past. I suppose we can call it experience. It is now one of my first test to minimize and restore to see if a strange behavior is still persiting. “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...
caramen Posted November 1, 2020 Share Posted November 1, 2020 He did the same with me xD. Now I won the same reflex 😛 My video tutorials : ( In construction ) || My Discord : https://discord.gg/S9AnwHw How to Ask Help || UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote Spoiler Water's UDFs:Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - Wiki Tutorials:ADO - Wiki 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