|
-
Oct 23rd, 2007, 04:00 AM
#1
Thread Starter
Fanatic Member
Detect Keystroke & Mouse Movement
hi guys help please..I want to create a windows application that would detect if there is any activity in my computer like keystroke & mouse movement but i want the windows application to be hidden...Can you give me guys an idea on how to do this? like what should I use to detect the mouse movement or keystroke. Thanks in advance guys!
-
Oct 23rd, 2007, 08:42 AM
#2
Re: Detect Keystroke & Mouse Movement
Are you writing a keylogger program?
-
Oct 23rd, 2007, 06:39 PM
#3
Thread Starter
Fanatic Member
Re: Detect Keystroke & Mouse Movement
Nope. Take note...I just want to detect if there is any activity, I dont say that I want to get the characters/keys that have been pressed. actually, what im trying to do here is that, I want my windows application to detect any activity(mouse movement or keystroke) in my computer and if there are no any activities in span of time it will automatically lock my workstation. Hope you get my point. Dont worry im not on to something that would harm my user.
-
Oct 23rd, 2007, 07:28 PM
#4
Re: Detect Keystroke & Mouse Movement
you can use GetLastInputInfo API to get the time since the last input (keyboard/mouse) was received by Windows. Use a timer and call this function to get the user idle time (in milliseconds)
This code was copied from Experts-exchange at this link
http://www.experts-exchange.com/Prog..._21504813.html
Code:
using System;
using System.Runtime.InteropServices;
namespace OperatingSystem.API
{
public class Idle
{
[DllImport("User32.dll")]
private static extern bool GetLastInputInfo(
ref LASTINPUTINFO lastInput);
[StructLayout(LayoutKind.Sequential)]
public struct LASTINPUTINFO
{
public Int32 cbSize;
public Int32 dwTime;
}
public int IdleTime
{
get
{
LASTINPUTINFO lastInput = new LASTINPUTINFO();
lastInput.cbSize = Marshal.SizeOf(lastInput);
int idle = 0;
if (GetLastInputInfo(ref lastInput))
idle = (Environment.TickCount - lastInput.dwTime) / 1000;
return idle;
}
}
}
}
-
Oct 23rd, 2007, 07:50 PM
#5
Thread Starter
Fanatic Member
Re: Detect Keystroke & Mouse Movement
Thanks for that Stanav! I'll give it a try..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|