ilikeautoit Posted 6 hours ago Posted 6 hours ago (edited) I want to do something while my Right Mouse Button is held down, but in the below code the console message only fires after the mouse button has been released (which defeats the purpose). Basically I'm wanting to temporarily change my mouse cursor when I'm holding down the mouse button. I have working code for changing the cursor (and their are also modifier keys being held as well, all of which works fine), but I can't get things to work for holding down the mouse button. Any help/guidance is greatly appreciated! ; Include the Misc UDF which contains the _IsPressed function #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") While 1 ; Check if the right mouse button is pressed (hex code '02') If _IsPressed("02", $hDLL) Then ; This code block is supposed to execute as long as the right button is held ConsoleWrite("Right mouse button is currently held down! (This only fires AFTER mouse button is RELEASED.)" & @CRLF) ; Wait for button to be released to prevent repeated firing (removing the below does not fix my problem) While _IsPressed("02", $hDLL) ConsoleWrite("Right mouse button is currently held down!!!!! (This also only fires AFTER mouse button is RELEASED -- it just fires a bunch of times at that point.)" & @CRLF) Sleep(10) WEnd EndIf ; Sleep for a short duration to prevent the script from using 100% CPU usage Sleep(10) WEnd Edited 5 hours ago by ilikeautoit
Developers Jos Posted 6 hours ago Developers Posted 6 hours ago Not sure I understand what it is you want to do other than what you coded, which is to stay in the inner loop while the mouse is pressed? So do what you have to do in that inner loop... no? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ilikeautoit Posted 5 hours ago Author Posted 5 hours ago (edited) Thanks much for the reply @Jos! Ideally, the first ConsoleWrite would fire while the mouse button is held down, but it doesn't fire until after it is released. And the same is true for the inner loop as well. Basically, I want to do something when the mouse button is first held down, and then reverse that action whenever the mouse button is released. But with the above code nothing is executed until the mouse button is released. The above _IsPressed code works fine for when holding a key down (eg, a modifier key), but not for the mouse button for some reason. Edited 5 hours ago by ilikeautoit
ilikeautoit Posted 5 hours ago Author Posted 5 hours ago I think I might be able to do what I need with this UDF (though I was hoping for a simpler solution):
Solution Nine Posted 5 hours ago Solution Posted 5 hours ago 47 minutes ago, ilikeautoit said: but it doesn't fire until after it is released. And the same is true for the inner loop as well. This is not what is happening with my computer (and a couple other ones). So there must be a problem with your setup. It works for me as expected. ilikeautoit 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
ilikeautoit Posted 4 hours ago Author Posted 4 hours ago 13 minutes ago, Nine said: This is not what is happening with my computer (and a couple other ones). So there must be a problem with your setup. It works for me as expected. Ah, okay -- that is very helpful to know! I do have some other software that could possibly be interfering. I will investigate. I was so puzzled as to why the code was not working! 😆 Thanks much for testing and replying -- 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