Detecting key and mouse actions in the background

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Detecting key and mouse actions in the background

tbodine
Hi All.

I'm working on a "get up and move" reminder app that needs to be aware when the user is working at the machine. Can a LC standalone (on Mac) detect key and mouse actions while LC is in the background?

In my tests so far, it doesn't. Suggestions welcome!

Thanks,
Tom Bodine
Reply | Threaded
Open this post in threaded view
|

Re: Detecting key and mouse actions in the background

Mike Bonner
Just tried it using a send loop.

local sRunning, sMouseLoc

on mouseUp
   if sRunning is empty then put false into sRunning
   put not sRunning into sRunning
   set the label of me to "Running: " & sRunning
   startloop
end mouseUp

command startLoop
   if sRunning then
      put the keysdown & cr
      put the mouseloc after msg
      send "startloop" to me in 50 millisec
   end if
end startLoop

I set the msg box where I can see it, clicked my button to toggle the loop
on, and as i'm typing this, if I move the mouse, the mouseloc is updating,
and every key I press pops up.

Will this do what you want?  Should be a simple thing to track the mouseloc
and compare it to the previous hit, 50 millisec is probably more often than
you need the check too.   And you can check to see if the keysdown is
empty. If its empty enough times in a row, and the mouseloc doesn't change
in the same period, you can guess the person is afk.  (though, if they go
face down on the keyboard all bets are off)

On Sat, Feb 7, 2015 at 3:08 PM, tbodine <[hidden email]>
wrote:

> Hi All.
>
> I'm working on a "get up and move" reminder app that needs to be aware when
> the user is working at the machine. Can a LC standalone (on Mac) detect key
> and mouse actions while LC is in the background?
>
> In my tests so far, it doesn't. Suggestions welcome!
>
> Thanks,
> Tom Bodine
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Detecting-key-and-mouse-actions-in-the-background-tp4688595.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Detecting key and mouse actions in the background

tbodine
In reply to this post by tbodine
Thanks, Mike. It helped to see your approach. I was using keydown and mousedown handlers and that was not detecting events outside of the LC app itself. So I adapted your method using the keys down and mouseloc, and it works nicely. Thanks!
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Detecting key and mouse actions in the background

Mike Bonner
Glad it helped, have a good one!

On Sun, Feb 8, 2015 at 1:25 PM, tbodine <[hidden email]>
wrote:

> Thanks, Mike. It helped to see your approach. I was using keydown and
> mousedown handlers and that was not detecting events outside of the LC app
> itself. So I adapted your method using the keys down and mouseloc, and it
> works nicely. Thanks!
> Tom
>
>
>
> --
> View this message in context:
> http://runtime-revolution.278305.n4.nabble.com/Detecting-key-and-mouse-actions-in-the-background-tp4688595p4688609.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode