Jump to content


Pause script with mouse move


  • Please log in to reply
5 replies to this topic

#1 Orr

Orr
  • Guests

Posted 22 April 2012 - 03:46 PM

Hi,

I have a script which run infinite loop.

I would like to pause the script when there is a mouse move, and continue to run the script when there is no mouse movement for X seconds.
It's basically like a screensaver.

How can I do that?

Thanks

#2 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 22 April 2012 - 03:55 PM

Use A_TimeIdlePhysical (<!-- m -->http://www.autohotke...s/Variables.htm<!-- m -->):
#persistent
Settimer, checkforactivity, 1000 ; check every second (1000ms) how long there has been no activity

checkforactivity:
 If A_TimeIdlePhysical > 10000 ; meaning there has not been any activity (keystrokes, mousemovement) for 10 seconds
   gosub dowhatever
return

dowhatever:
   Loop
   {
     ; do whatever
     if A_TimeIdlePhysical < 10000 ; meaning there has been user activity
       break
   }
return


#3 Guests

  • Guests

Posted 22 April 2012 - 05:28 PM

WOW!
That was quick!

Thanks!

#4 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 22 April 2012 - 06:38 PM

More importantly, did it do what you wanted it to?

#5 guest1

guest1
  • Guests

Posted 29 April 2012 - 09:16 AM

right on the money mate. cheers

#6 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 29 April 2012 - 11:41 AM

I've said it before, and I'll say it again, we aim to please, glad I could help :)
Most of that is due to you formulating your question sufficiently precise ;)