Jump to content

How to detect system inactivity?


seanhart
 Share

Recommended Posts

Isn't this kind of a neater solution?

idle_time.au3

Mapping every key and do the test with _IsPressed seems a bit messy to me. Ex. Would it cacth my activity,on a laptop, only using the fn+ keys?

Regards

Uten

that one only watches the mouse. mine watches the mouse and the keyboard. and cleaner??? cleaner how? unnecessary Call()'s, extra lines? i'll concede that his has better documentation, but other than that i don't see any advantage to his code over the code i posted, even if you ignore that it is just watching the mouse. i'm not trying to say anything about the other coder's ability or anything, back then there weren't dll calls, or IsPressed() (i don't think) for his script to have all of the same functionality. Sorry, i'm just not seeing how that would be a better solution to this issue. or cleaner.

Link to comment
Share on other sites

that one only watches the mouse. mine watches the mouse and the keyboard. and cleaner??? cleaner how? unnecessary Call()'s, extra lines? i'll concede that his has better documentation, but other than that i don't see any advantage to his code over the code i posted, even if you ignore that it is just watching the mouse. i'm not trying to say anything about the other coder's ability or anything, back then there weren't dll calls, or IsPressed() (i don't think) for his script to have all of the same functionality. Sorry, i'm just not seeing how that would be a better solution to this issue. or cleaner.

It's definitely simpler and it doesn't technically watch the keyboard although it does watch for cursor movement which will work most of the time, but it's not as comprehensive as cameronsdad's one.
Link to comment
Share on other sites

It's definitely simpler and it doesn't technically watch the keyboard although it does watch for cursor movement which will work most of the time, but it's not as comprehensive as cameronsdad's one.

sorry, didn't mean to get so defensive there, but my code contains a shorter version of code that does the same thing as the linked script as one of the activities it watches for, so i was kind of taken aback as to how that could be considered a better solution. i'm over it ;)

Link to comment
Share on other sites

I was just about to post my code for 'idle_time.au3', then I followed Valuater's link.

I didn't try Camron's code, but I know that mine doesn't check for Key Presses, so it is limited.

Anyway, I'm just glad to see someone posting a link to my code. ;)

Thanks,

Ian

"Blessed be the name of the Lord" - Job 1:21Check out Search IMF

Link to comment
Share on other sites

It does monitor keyboard activity with the code. Normal keyboard activity will move the caret from time to time.

$CPos2 = WinGetCaretPos()

I gues the cleaner part is a matter of taste. Doing 117 calls to _IsPressed just to se if there is a user pressent is..., hmm overkill?.

But by all means, camronsdad's sample does work. And I have to add it will work in special cases where idle_time.au3 does not. Hitting PgUp And PgDn reading the same page for a while while browsing would be one of those occations.

A mix of the two methodes would probably be the best solution?

Regards

Uten

Link to comment
Share on other sites

Out of curiosity I took a look at the code behind _IsPressed.

It's a DllCall wrapper around GetAsyncKeyState.

Now the thing that puzzles me is what I read about GetAsyncKeyState at MSDN.

Windows NT/2000/XP: The return value is zero for the following cases:

* The current desktop is not the active desktop

* The foreground thread belongs to another process and the desktop does not allow the hook or the journal record.

Do I misunderstand something or would there be (more and more as MS locks down the OS) cases (users) where the _IsPressed will not work as described in the autoit help file?

I assume the function WinGetCaretPos is a wrapper around the API function GetCaretPos whom, as I understand it, does not have the same limitations.

Regards

Uten

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...