Weird priority for mouse control
-
Hello,
I use Qt5.7 on Windows 10 to offer a gUI and to control the position of the mouse on the screen. I use SetCursorPos.
However, when a High-level feature of Windows is active, the mouse control stops. For instance, if the Task Manager has the focus, the mouse control stops. The same thing happen if Visual Studio has the focus. This happens if I use MinGW or MSVC compilers.
The exact same program but compiled with Visual Studio doesn't have this problem. The mouse control continues if the Task Manager has the focus.
With the program compiled with Qt, if I run the program as administrator, there is no problem either, the mouse control continues.
This is not really my field of expertise, would you have any suggestions ?
Thank you very much,
Alex
-
@alecs26 You're running into permissions issues. You don't have access to control the mouse over those administrator level tasks so you "lose control".
The reason it "works" for visual studio is it sounds like you are running VS with heightened privileges. Which is why the mingw built version won't control the mouse over your VS either.
This is for good reason and the only way around it is to run with elevated permissions.
-
@ambershark Thank you for your answer.
I know how to elevate privileges with VS (UAC Execution level) but I didn't changed those, they are set to the default settings.
Anyway, is there a way to elevate rights with Qt MinGW ? Is it discouraged ?
Thanks,
Alex
-
@alecs26 If you launched as admin (right click Qt Creator and run as administrator) that would elevate all sub processes as well, including mingw and your application if run from the IDE.
As for discouraged.. I wouldn't worry too much about that for the IDE but just know that if you distribute your application it will need to run with admin level permissions which is a whole other issue you need to deal with inside your installer.
Edit: made an assumption you were using qt creator, if not then just run your resulting executable as administrator either from an elevated command prompt or doing the right click method. You don't need mingw to run as admin, ever.