 |
|
 |
I've tried this and it just never seems to write anything to the logfile.. thoroughly dissapointed.
|
|
|
|
 |
|
 |
Why "�","ş" etc. not logging?
|
|
|
|
 |
|
 |
will use this to find out what I keep "fatfingering" that causes 'jump to next paragraph' - seemingly across all apps on toshiba laptop.
|
|
|
|
 |
|
 |
Thank you for the post and it's great.
Please help me to get unicode value of the current keyboard layout that user using.
Otherwise, logs are meaningless if the user use other keyboard layout than US.
|
|
|
|
 |
|
 |
Hi,
can i get the key stroke hit in ms word window. so that when ever user type a space bar aotomatically a pop winodow shd get displayed.
Regard
caveatashish@rediffmai.com
|
|
|
|
 |
|
 |
thanks for the code sir...
|
|
|
|
 |
|
 |
I am trying to find out if a user pressed a Textbox or not, so that I could draw something on the screen. Is it possible to find out once we click on a textbox we can get an event back stating it is a text box?
For example, I am clicking on a textbox in any application on the destop, I want to return true or false if that click is a textbox. If it is a textbox, it will allow me to draw a widget on that screen so that I can choose items on that widget and press enter so the contents will go back to that textbox. Similar to speech to text recognition programs and Tablet PC Handwriting.
Any ideas?
Microsoft Student Partner
|
|
|
|
 |
|
 |
First of all, good article!
this is almost solving what I have to do!
so How to log just the values of the keys pressed?
for instance...
by pressing CAPS LOCK, TAB, SHIFT...would not log anything
but pressing keys that represents A-Z, a-z, 0-9 and special characters would log EVERYTHING
thanks!
|
|
|
|
 |
|
 |
If you are responding to an input message and want to know what keys were pressed at the time that input was generated, then you want to use GetKeyState. You may use GetKeyState to query the state of the Alt key (VK_MENU)... That's because you want to know whether the Alt/SHIFT key was down when the user clicked the mouse or pressed the alphanumeric & special character key(s), not whether the key is down this very instant. Whether the user released the Alt key between the time they clicked and the time you processed the message is irrelevant.
What you do care about is; that the Alt key was down at the time of the A-Z, a-z, 0-9 key press
~Alexander Kent
|
|
|
|
 |
|
 |
thanks by answering man!
just one more thing:
I know that is necessary solve firstly the ALT/SHIFT key.
but how about kinds of keyboard?
would I have to take care for all kinds of keyboard?
thanks a million!
|
|
|
|
 |
|
 |
Is there a way to make the DOS box disappear? When I run the executable everything works but the DOS box is right there,
Great little program; thanks.
|
|
|
|
 |
|
 |
using System.Runtime.InteropServices;
=========
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName,string lpWindowName);
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
=========
IntPtr hWnd = FindWindow(null, "Window Title"); //put your console window title here
//set the title with Console.Title = "Window Title";
if(hWnd != IntPtr.Zero)
{
//Hide the window
ShowWindow(hWnd, 0); // 0 = SW_HIDE
//Show window again
//ShowWindow(hWnd, 1); //1 = SW_SHOWNORMA
}
|
|
|
|
 |
|
 |
Great article. Is it possible to exclude mouse button pressing logging like: R button L button?
|
|
|
|
 |
|
 |
of course it is....Peek the WM_LBUTTONDOWN / WM_LBUTTONUP or the WM_RBUTTONDOWN / WM_RBUTTONUP Windows Messages off of the windows message queue and rather than log them, pass them up the stack to Windows
Welcome my son...Welcome..to the Machine
|
|
|
|
 |
|
 |
An easy way of doing his is as follow:
we know that Enum.GetName(typeof(Keys), i) returns a string containing either the key or the button that was pressed. The keyBuffer string constatly adds the strings: keyBuffer += Enum.GetName(typeof(Keys), i); So all you have to do is check what the Enum.GetName(typeof(Keys), i) string is and you can filter any key!! You do end up with a long if function but this could be reduced by setting the Enum.GetName(typeof(Keys), i) string to a variable string. So your code could look as follows ( i agree it is ugly, but its easy):
if((GetAsyncKeyState(i) == -32767)&&(Enum.GetName(typeof(Keys), i)!= "LButton")&&Enum.GetName(typeof(Keys), i)!= "RButton"))
{
if(( Enum.GetName(typeof(Keys), i) != "ShiftKey")&&(Enum.GetName(typeof(Keys), i) != "LShiftKey")&&( Enum.GetName(typeof(Keys), i) != "RShiftKey"))
{
if (Enum.GetName(typeof(Keys), i) == "Space")
{
keyBuffer += " ";
}else
{
keyBuffer += Enum.GetName(typeof(Keys), i);
}
}
}
|
|
|
|
 |
|
 |
You have:
if(GetAsyncKeyState(i) == -32767)
to determine if the key being checked has been pressed. Can you explain how this works?
What I've seen by way of documentation of the GetAsyncKeyState function talks about the most significant bit being set if the key is down at the instant that you check, and the least significant bit being set if the key you are testing has been pressed (and released) since the last time GetAsyncKeyState was called. Is this correct?
So are you checking for both the most significant and least significant bit being set (1000000000000001 = 32769 which overflows 32768 and is also equal to -32767 for 16 bit signed integers?
What I read indicates that the least significant bit is unreliable since in a preemptive multitasking environment, you may not be the last one to have called GetAsyncKeyState, and therefore the lsb may appear cleared even though the key was pressed (or release) since the last time YOU called GetAsyncKeyState.
I've played with using:
Convert.ToBoolean(GetAsyncKeyState(vKey) & 0x8000
to detect if the key is pressed, as I have seem some others do. This looks like it is clearing the least significant bit and only testing the most significant bit? So I think this only detects a keypress if the key is down at the instant that the test is performed. The result I've seen from this is that a keypress may be recorded multiple times if the key scanning routine executes more than once during the key press. Presumably, also, if the scan is performed infrequently enough, some key strokes would be missed. Does that sound right?
My approach has been to poll frequently, and maintain a previous state value for each key. Then I only record a key stroke when the key is down and the previous state was not down. I update the previous state as up or down right after this test to be prepared for the next iteration.
Can you compare the pros and cons of this approach vs your approach?
I am updating the state of modifier keys (Ctrl, Shift, Caps Lock, L-Win, R-Win) using this same methodology just before I scan for all of the keys, so that when a key is down, I can translate it based on the states of the modifier keys and log the appropriate value (such as or ).
Also, are there any reasons I shouldn't just log to a StreamWriter for a file stream and do a flush after each write? The idea is that ultimately, stream encryption will be 'stacked' onto the file stream that is being written to. Each key logging 'session' will start with an initialization header that contains a public key encrypted 'session' key that is used to encrypt the stream for that session. A reader app will have the private key to decrypt the session keys and subsequent decrypt and display the logged keystrokes.
Thanks,
DS
|
|
|
|
 |
|
 |
Why isn't it working when used as a Windows Service??
life is study!!!
|
|
|
|
 |
|
 |
Try and checkbox the Allow Service to Interact with dekstop under the LogOn Tab in your windows service in the MMC.
~Alexander Kent
|
|
|
|
 |
|
 |
I've been looking around for a while trying to find the answer to this one. How do incorporate the shift key so when its down it changes an 8 into a *. I thought about calling GetAsyncKeyState each time to check the shift key but that didn't work. I also made a bool variable and set it to true every time the shift key was pressed; the next key pressed after that was modified. Unfortunately that only works once because you have to set the bool variable back to false. Hopefully that makes sense. Anybody have any ideas? thanks
|
|
|
|
 |
|
 |
Hi,
I'm new at this section,
but I want to know how to get the typed strokes,
I see a piece of code, but what must I do? Do i have to get it implanted in the program? Or is it a command line function??
Greets Geppie
|
|
|
|
 |
|
 |
I'm interested in filtering all potential accelerators (e.g., alt+F, Ctrl+C) in an application; would this class intercept these keystrokes as well?
thanks,
ed
|
|
|
|
 |
|
 |
Can you please tell me, why the logfile "c:\logfile.txt" remains empty after the elapsed time?
I can see a message box at a fixed interval with all the key logged.
Thanks
|
|
|
|
 |
|
 |
(Preprocessor Directives) - The Logfile only gets dump when using a release build - Try a release build;
~Alexander Kent
|
|
|
|
 |
|
 |
Is there a way to get the name of the application in which typing is done.
|
|
|
|
 |
|
 |
// The foreground window has the keyboard focus
IntPtr hWnd = GetForeGroundWindow();
IntPtr lpdwProcessId = IntPtr.Zero;
// Get the process that spawned this window
GetWindowThreadProcessId(hWnd,ref lpdwProcessId);
// Get the module from the process id
ProcessModule module = Process.GetProcessById(
lpdwProcessId.ToInt32()).MainModule;
[DllImport("user32.dll")]
public static extern IntPtr GetForeGroundWindow();
[DllImport("user32.dll")]
public static extern int GetWindowThreadProcessId(IntPtr hwnd,ref IntPtr lpdwProcessId);
|
|
|
|
 |