MaximusCZ Posted January 23, 2019 Posted January 23, 2019 (edited) #include "_MouseOnEvent.au3" #include <Misc.au3> _MouseSetOnEvent($MOUSE_WHEELDOWN_EVENT, "aa") Func aa() ToolTip ("a") While _IsPressed ("04") == false ToolTip ("f") WEnd ToolTip ("e") EndFunc while 1 WEnd Code above. I run the code, and click middle mouse button repeatedly, observing tooltip to follow flow. After several seconds (or several tries, usually less than 10), the tooltips stops changing (always ends on "e") The rest of the script becomes unresponsive. After CTRL+Break this is the output in console >"C:\Programs\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Programs\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\*****\Desktop\Work\AutoitSkripts\Test.au3" /UserParams +>13:47:20 Starting AutoIt3Wrapper v.18.708.1148.0 SciTE v.4.1.0.0 Keyboard:00000405 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0409) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Programs\AutoIt3\SciTE UserDir => C:\Users\******\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\******\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.14.5) from:C:\Programs\AutoIt3 input:C:\Users\Zika\Desktop\Work\AutoitSkripts\Test.au3 +>13:47:21 AU3Check ended.rc:0 >Running:(3.3.14.5):C:\Programs\AutoIt3\autoit3.exe "C:\Users\*****\Desktop\Work\AutoitSkripts\Test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 9.624 Whats happening? If I ommit the _IsPressed check inside the function, the script is running OK indefinetly. _MouseOnEvent.au3 Edited January 23, 2019 by MaximusCZ
Danp2 Posted January 23, 2019 Posted January 23, 2019 Probably due to the function being called recursively each time you press the middle button. Try disabling the _MouseSetOnEvent at the beginning of your function and then enabling it at the end. Latest Webdriver UDF Release Webdriver Wiki FAQs
MaximusCZ Posted January 23, 2019 Author Posted January 23, 2019 (edited) @Danp2 _MouseSetOnEvent is called before function declaration. Its in a same space as #include Edited January 23, 2019 by MaximusCZ
Danp2 Posted January 23, 2019 Posted January 23, 2019 I was suspecting that the AA function was being called recursively due to the existing _MouseSetOnEvent command. I was suggesting that you disable this functionality while within the AA function. Another option would be to add a ConsoleWrite at the beginning of the function so you can observe each time the function is executed. Latest Webdriver UDF Release Webdriver Wiki FAQs
MaximusCZ Posted January 23, 2019 Author Posted January 23, 2019 @Danp2 Tested it with Consolewrite at the beggining of function and I can confirm that it gets called once per "mouse button down event". Holding the mousebutton does not call the function multipletimes. The problem persist even when I make another press only after tooltip "e" is visible, indicating exiting the function. After several tries it just exits the function and never enter again. Its not like its then just waiting in while loop, as stopping the script reveals it was actually hung.
MaximusCZ Posted January 23, 2019 Author Posted January 23, 2019 Correction After adding "Tooltip ("w")" inside while loop, I can confirm the scipt is not actually hung. It just doesnt call the function again. Strange that CTRL+Break is unable to gracefully stop the function, tho. Sadly the same seems to apply when tryin to stop the script before a single keypress is made -- every time at any script
TheSaint Posted January 23, 2019 Posted January 23, 2019 If you are gonna repeatedly use _IsPressed, you should be using the OpenDLL method. See the help file. And I strongly suspect you need to throw a Sleep in there too, even if it is only Sleep(10). What's this for? Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
MaximusCZ Posted January 23, 2019 Author Posted January 23, 2019 (edited) @TheSaint I need to send ESC before and after I hold MMB mouse to switch program into mode where MMB drag can be utilized. But when I want to close modified window, the second ESC cancels "close without saving" dialog. I wanted to record distance traveled while holding MMB to be able to choose to omit second ESC, but ran into this problem Edited January 23, 2019 by MaximusCZ
MaximusCZ Posted January 24, 2019 Author Posted January 24, 2019 @TheSaint I have tried both adding Sleep in while loop and calling uuser32.dll only once at the begining and then passing the handle to _IsPressed, no difference.
TheSaint Posted January 24, 2019 Posted January 24, 2019 (edited) If I recall correctly, ESC can end a script, so that might be part of your problem??? Or maybe that is just a GUI window??? I also seem to recall you can change that behavior??? Best way to quickly test that I guess, is try another key and see what happens ... perhaps SHIFT. But definitely use the DLLOpen method, to help narrow down possibilities ... Sleep too. What value Sleeps have you tried? And where are you putting them? I see two places where you should use Sleep. Have you tried something like the following? #include "_MouseOnEvent.au3" #include <Misc.au3> _MouseSetOnEvent($MOUSE_WHEELDOWN_EVENT, "aa") Global $dll = DllOpen("user32.dll") While 1 Sleep(50) WEnd DllClose($dll) Func aa() ToolTip ("a") While _IsPressed("04", $dll) == false ToolTip ("f") Sleep(50) WEnd ToolTip ("e") EndFunc I would also incorporate a Timer that checks periodically for a Key press to allow exiting your While 1 loop. Edited January 24, 2019 by TheSaint Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)
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