how to use console/windows app without focus on it? - c#

im going to create a KEylog application that enables me to write all data typed(keys pressed) on a text file/database how can i do this without focus on the windows app/console app?
for a reason , for all you to know, this is for my PC and im not trying to hack an account.
just for me to know what they are doing on my computer.

Find an example written in .NET here:
Processing Global Mouse and Keyboard Hooks in C#
This class allows you to tap keyboard and mouse and/or to detect their
activity even when an application runs in the background or does not
have any user interface at all.

Related

C# - Force using XP style alt-tab switcher

I would like to ask if anyone would know a way how to force the old XP version of Alt-Tab dialog when inside my C# app.
There is definitely a way how to capture keyboard keys, for example here Global keyboard capture in C# application.
There could be a way to capture alt-tab with KeyPress or KeyDown and then send alt-alt-tab which would show the old version, but that is not a preferable way.
So how to force windows from C# to show the old alt-tab dialogue from the app? Is it even possible?
Thanks in advance.

Control OS Mouse Event using Windows Form - C#

The program I am trying to do is to simulate the mouse event of a operating system using keyboard with Windows Form. Right now I am able to change the cursor and do different actions like mouse clicking inside the Form (when the Form is on the Top).
The problem is I would like to extend it to the whole Operating System, which means even if my Windows Form is not at the top, I am still able to control my cursor and do all sorts of mouse event on other applications while the Form is running. How should I do to implement this ?
You might want to look at this library Global System Hooks in .NET which uses global system hooks to detect all mouse and keyboard events include those outside of your application.
You can synthesize OS-wide keystrokes, mouse motions, and button clicks using the Win32 SendInput() API. You can call it from C# using P/Invoke. Sample code can be found here: SendInput on PInvoke.net.
I remember back in the day I used the SendInput (and a screenshot API) to create a Minesweeper bot in C# (2.0 I think). It could solve an Expert puzzle in about one second. I wish I still had the source code to sample here, but I don't.
EDIT: It appears someone has already created a nice .NET warpper for the SendInput(): Windows Input Simulator on CodePlex.

Creating a Process in the background that will listen to keyboard

I have a project that runs in the background in a different process, I want it to be able to react to keyboard everywhere, for example I run the project, and afterwards I do other stuff in the computer such as browsing, facebook, watching movies etc.., and every time I press F9 I want my project to show up. Same as how you press a combination of keys to invoke Babylon... I want to implement it in C#, I have no idea how to begin.
You can register a hotkey with the RegisterHotKey API function. You can see an example of its usage from C# here.
I think you need to write a system-wide keyboard hook, check here for details:
https://stackoverflow.com/a/1764434/559144
How do I grab events for all applications? An example system-wide hook.

Capture event for fingerprint reader in no active application

I have an application that validates users through a fingerprint reader. The validation is done in a method that i subscribed to manage the event, it looks like this.
FingerprintVerificationControl.OnComplete+=new DPFP.Gui.Verification.VerificationControl._OnComplete(FingerprintVerificationControl_OnComplete);
Everything goes well while i'm woriking with the application, i mean, when it has the focus, but, i have put it in the system tray using a notifyicon control and associating it with a contextmenu control to restore and close the app; so when it is in the system tray (is not the active application) i have no response from the fingerprint to manage the validation; the event of read the finger of the user does not fires.
My question is, what is the best way to manage that? Is it possible?. I found that i can do it if i make a windows service, other sites say that with Win32 API, others have examples but with keyboard events like presss key and so on. Any idea? any idea would be thank.
I have found that making a Windows Service is the best way to do stuff like that. However I don't any about the windows32 API cause I've been able to do everything I can without it.
As for the keyboard events, I have tried those and have found that they only work when the application has focus therefore, they are unusable. And services are just useful in general. You can try to talk to your application from your service via the local network so you don't have to rework the entire application.
I hope this is helpful.

How to Receive click location from another process with C#?

My C# application needs to receive a click position from another process, I then need to show on my app. But I don't know how I would implement it.
Could someone help me figure out how to do this?
Thanks so much
What you need is called a "Hook". Windows allows you to hook both the keyboard and mouse events. Basically windows works by injecting the appropriate movements and clicks of the mouse (and keys typed) into the application that has focus.
However using the hook, you receive all of the events, not just those relevant to your app. Once you have the hook established you can then do what you want with the information.
Note that you are going down to the windows OS and if you do the wrong thing here, you can leak the handles and you can also cause windows to get into a bad state.
There is a great tutorial here from MS Technet that describes how to do this in C#.

Categories