Keep script on hold while mouse status is "wait"

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Keep script on hold while mouse status is "wait"

30 Jul 2019, 23:21

Hi people!
s
I have a problem. My PC occassionally lags. In certain (but painfully plentiful) moments, the mouse pointer turns to that circling thing that shows that Windows 10 is processing some weird background process.

The issue is that this behaviour screws up my AHK scripts.

Do you guys know if I could insert some lines of codes in my script that say something like "Hey, Autohotkey, if the mouse status changes to a circle, whenever it happens, do nothing, keep still and wait until it's back to normal, pleaseeee"?

Evidently, these lines of code would have to be always active (=persistent?) because I cannot know in which part of the script Windows will decide to lag and process some internal time-consuming crap.

This solution, if found, would help me a LOT.

Thanks!
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Keep script on hold while mouse status is "wait"

31 Jul 2019, 01:03

This will give you an idea. When you press the M key, your code will not work if the cursor is "AppStarting" or "Wait".

Code: Select all

#If A_Cursor != "AppStarting"
m::
IfNotEqual,A_Cursor,Wait
	IfNotEqual,A_Cursor,AppStarting
{
		MsgBox % A_Cursor
}
return
also:

https://autohotkey.com/docs/Variables.htm#Cursor
Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Re: Keep script on hold while mouse status is "wait"

31 Jul 2019, 21:02

I am not sure if your code does what I need. I have a long script with many hotkeys. Some of those hotkeys take seconds or minutes to process, and when Windows decides to process some weird background process, all copypasting processes within the script are screwed up, among other things.

So it's not that I need a hotkey that won't work if the cursor is in Waiting state, what I need is some way to make the script to stop while the cursor is in Waiting status and resume once Windows 10 becomes responsive again.

It has to be something that triggers automatically and stops the script whenever mouse state turns to "Wait" and then resumes execution when the Wait mouse status is gone. And ideally it should apply to the entire script and hotkeys, not one code for each hotkey.

What I believe you are providing here is a hotkey than won't run at all if the mouse is in the Wait state. It's definitely not the same.

Any ideas?

I am wondering. Can you control one AHK script from ANOTHER AHK script? I am wondering if you could have a persistent tiny script that checks continuosly for mouse state, and when it turns to Wait, holds back the main AHK script until the condition is resolved. But in this case I would need two scripts at the same time, one persistent and being able to pause/resume the other... I don't even know if that is possible or an awful idea, whether it would gobble up a lot of resources and slow down everything, or whether it can be done in a different or more sensible way...
gregster
Posts: 9001
Joined: 30 Sep 2013, 06:48

Re: Keep script on hold while mouse status is "wait"

31 Jul 2019, 21:30

If your whole Win10 becomes unresponsive that probably includes your AHK scripts, too... at least at some times, perhaps in unpredictive manners.
That said, there might be ways to make their processes more reliable, but it probably strongly depends on what your scripts are actually doing.
Nixcalo
Posts: 116
Joined: 06 Feb 2018, 04:24

Re: Keep script on hold while mouse status is "wait"

31 Jul 2019, 21:42

Well, you know, it is when the cursor changes to that circling thing... I would not say completely unresponsive, as I can usually switch to other applications and they work fine...

It's as it were doing something in the background for a second or two...
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: Keep script on hold while mouse status is "wait"

01 Aug 2019, 01:31

I shared only one example as a shortcut. You can put an expression between processes that checks the mouse state before processing.

The copying process will begin
Check the mouse cursor
Mouse cursor in arrow shape
Go ahead
Mouse cursor in standby form
Wait 10 seconds
Check the mouse cursor again
The mouse cursor came to The Shape of the arrow
Go ahead

If you share your sample code, maybe they can help more.

Maybe you'd like to use it to detect the processor load.
https://www.autohotkey.com/boards/viewtopic.php?t=3413

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Mannaia666 and 415 guests