473,322 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Getting time of last mouse click and keystroke?

Hello,

I'm writing a program (which will be running in the background 99% of
the time) and I want to be able to work out how long it has been since
the user last used the mouse and/or keyboard. I plan on using a Timer
to do the checking periodically, but I'm not sure how to get the time of
the last mouse click or keystroke.

Any suggestions? I've seen examples on keyboard loggers but they seem
to focus on capturing all keystrokes, and I'm only interested in their time.

Thanks in advance,

Gary
Mar 7 '06 #1
2 2776
Sounds like you'd need a static DateTime member somewhere that the
timer can see. For every keystroke or mouse movement, set the member
to DateTime.Now.

When your timer fires, you can take DateTime.Now and the static member
and do the math.

HTH
Andy

Mar 7 '06 #2
Andy wrote:
Sounds like you'd need a static DateTime member somewhere that the
timer can see. For every keystroke or mouse movement, set the member
to DateTime.Now.

When your timer fires, you can take DateTime.Now and the static member
and do the math.

HTH
Andy

Thanks for that. In the end I decided to go with GetLastInputInfo() in
user32.dll and forsake Windows 9x compatibility.

I did try what you suggested with some hooks to intecept all mouse and
key clicks, but my boss was worried that 'spyware detectors' might
interpret this as a fully fledgedkey logger - don't know how likely that
is though.

Cheers.
Mar 8 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne Wengert | last post by:
I want to get the decimal (integer) value of user keystrokes. I am using the following code. chrInput is the character entered (e.g. "M") and "keystroke is DIMed as Short keystroke =...
9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
2
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use...
3
by: TR | last post by:
Hi, We have some code that uses automation to create/manipulate word documents. This runs in a batch mode, generating dozens of documents in sequence. The code works great, but while the...
7
by: Tyron | last post by:
I need to know if the Left Button of the Mouse is clicked in the WM_NCMOUSEMOVE Notification but this Message doesnt contain the Mouse Button States as WM_MOUSEMOVE does. So how can I get them? ...
5
by: Don | last post by:
Is there a way to capture click events in the form designer? I'm trying to create a control similar to the TabControl (which seems to handle clicks in design mode) and would like to be able to...
3
by: OleJul | last post by:
I am at present working on integration of help functions in my Access data base. My intention is simply to make a right click on an object (including labels) to open a specific help topic. In a...
10
by: gentsquash | last post by:
Can javascript (easily) produce a click from the PC-speaker? This is the speaker that is (well, used to be) directly on the CPU-card and was -I believe- intended to give feedback to the typist,...
11
by: xenoix | last post by:
hey there, im reasonably new to C# and im currently writing a backup application which im using as a learning resource. My PC :- Visual Studio 2005 .NET Framework 2 Component Factory Krypton...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.