Detect scroll activity (when LC is not frontmost)

Mike Bonner bonnmike at gmail.com
Sun Dec 25 17:39:19 CET 2016


The script does an end run of the whole situation.  The os itself is
keeping track of the idle time between user events.  All the script does is
grab the current value. And since only HID (human interface devices) are
tracked, any mouse/keyboard activity in any app of the system will reset
the timer.  So technically no, the scroll won't "register" in the lc stack
(meaning it won't cause a handler to fire), but the OS does track HID
actions..  All the stack does is request the information from the os (in a
loop), that information being the time since the last user activity.



On Sun, Dec 25, 2016 at 9:29 AM, Richmond Mathewson <
richmondmathewson at gmail.com> wrote:

> Does that mean that if, say, I have a stack running your script in the
> stackScript
> and I'm scrolling a window in Firefox that that scrolling will register in
> the LC stack?
>
> The reason I am asking that question is because I don't quite understand
> how one effect a mouseUp
> while one is scrolling with one's mouse at the same time and the mouseUp
> not affecting the frontmost app.
>
> Richmond.
>
>
> On 12/25/16 5:56 pm, Mike Bonner wrote:
>
>> I have an answer..
>>
>> Heres a sample script:
>> local sRunning
>>
>> on mouseUp
>> if sRunning is empty then put false into sRunning
>> put not sRunning into sRunning
>> loopit
>> end mouseUp
>>
>> command loopit
>> if sRunning then
>> put the last word of (shell("ioreg -c IOHIDSystem |grep Idle")) into tIdle
>> put tIdle / 1000000000 into field 1
>> send "loopit" to me in 2 sec
>> end if
>> end loopit
>>
>> The script is in a button, and I have a single field on the card.  The
>> math
>> is done to convert to seconds of idle.
>>
>> The are only 2 disclaimers here.  First is that the value returned pre
>> 10.3
>> is hex so you'd have to handle that if you have an earlier osx.  10.3 and
>> after this solution should work fine.
>>
>> The second issue is is that on mac 10.12, the idle time won't update on
>> typing.  Its an osx issue for that specific version, but worst case you
>> already have a method to track keypresses.
>>
>> On Sun, Dec 25, 2016 at 8:21 AM, Paul Dupuis <paul at researchware.com>
>> wrote:
>>
>> On 12/25/2016 10:05 AM, Terry Vogelaar wrote:
>>>
>>>> So it starts to become clear that it might not be possible to do what I
>>>>
>>> want. Although I hope to be wrong about that.
>>>
>>> I think it is very unlikely you can do this in LC - without externals or
>>> LCB widgets from "infinite Livecode".
>>>
>>> The active mouse and keyboard drivers capture events from these devices
>>> and pass that information to the operating system, which massages the
>>> data and passed a higher level of events on to the active application,
>>> which looks for such events and handles them. In the case of the
>>> LiveCode engine - or any app built on the LC engine - that is executing
>>> applicable messages for your scripts to handle.
>>>
>>> Most productivity tracking software works by effectively inserting code
>>> into where the device drivers meet the operating system, so that mouse
>>> and keyboard events are captured by the productivity app's as well as
>>> being sent by the OS to the active application as normal.
>>>
>>> Using LCB and LC9.0 you might be able to write an LCB widget that does
>>> this, but I am not familiar enough with current OSX APIs for event
>>> capture or drivers under OSX to or the state of work in LC9.0 on
>>> integrating OS API calls to say for sure.
>>>
>>> You are unlikely to be able to do what you want in LiveCode script alone.
>>>
>>>
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>
>>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list