sharing mouse click and key press events through windows (or handles) - c#

I have 3, and sometimes more duplicates of an executable, and what I would like to do is to reduce workforce by sharing mouse click and key press events through all applications, with C#.
I am able to get handle's of executables, so ideas might be based on acquired handles.
Also I have done some work to ease my work, all applications are arranged at same coordinates, with the same window size. So basically transparent mouse and key clicks which will interact with all windows (the top window, as well as background windows) would do the trick.

You need to sned Windows Messages from one application to the other, but that involves security configuration.
Here you have how to do it:
Communication between applications via Windows Messages
Here you have comments about security issues, and ideas for alternative solutions
Sending, receiving and processing a windows message between windows applications

Stacking the windows isn't necessary. Once you have the handle to all the windows that you want to interact with, P/Invoke the SendMessage API to send your click to each window at it's target coordinates.
If I had the need for such a thing, I would put a picture box on a form and capture the image of one of the windows (so I can see what I'm clicking), then process the PictureBox.Click event to calculate the coordinates to use in the P/Invoke call(s).
There are several other tricks you could use to make your life easier and click-sharing utility better, but this will get you started.

Related

How to monitor different events in 3rd party applications

I am developing a C# application. I am looking for a way to monitor different events in 3rd party applications.
Example 1: Calculator is running, and I want to know when the user has clicked on "=" button.
Example 2: Skype is running and I want to monitor when the user hits the "Call" button.
Example 3: Word is running and I want to monitor when the user opens the "Font" drop down list.
I am not looking for simple Mouse or Keyboard events.
Take a look at EventSpy, Both of those seams to do what you need.
http://www.codeproject.com/Articles/11918/EventSpy
http://eventspy.codeplex.com/
You basically need to tap into the "Windows Messaging" loop. In order to properly filter the GAZILLION messages that come flying through you'll also need to be able to periodically scan through all of the active windows to see which ones (if any) are relevant to you.
Be aware that this whole subsystem of windows is a GIANT security hole. (I have not worked with it much since NT4 / W95/W98 days so they might have tried attempts to "secure" it since then so it might be even harder to get to than it used to be.
You're going to need a good ide / 3rd party tools to help you get started on your way to have some idea of what you're looking for.
In a "previous" life we used this basic technique to get ~4,000 workstations to install their own software, updates, patches, etc through monitoring for existence of certain windows, controls, etc and "injecting" messages into the Windows Messaging loop to control Application Setup Programs, configuration changes that were not stored in the registry, etc, etc...

C# - Transparent Window to defeat Keyloggers

How can I create a window which is fully apparent to the user but is not visible in screenshots. I know that this is possible since Neo SafeKeys (an onscreen keyboard to defeat keyloggers) does not appear in the screenshots taken by keylogging software I installed.
To give you an idea, the window is fully visible to the user, however when a screenshot is taken, the Neo SafeKeys window does not appear at all (as if it does not even exist).
Neo SafeKeys states that it uses an invisible protection layer above the window to protect against screenshots. I have searched all over the internet to see how can I reproduce this, to no avail. Does anybody know how this can be performed (windows which is visible to user but invisible in screenshots)?
What you can do is you can prevent the PrtScn key from doing anything when pressed. Take a look at this article while shows you how to do this.
What this article is doing is clearing out the clipboard. What you can do instead is capture the screen image and digitally remove your application, then put the revised image on the clipboard, thus giving the "Effect" of making your window transparent.
Also, you might want to look at this SO question which gives an alternative way to make your window just appear "blue", though its not easy to do.
Does anybody know how this can be performed (windows which is visible to user but invisible in screenshots)?
Use DirectX to render directly to the device.
In your C# application you can set up a global hook to monitor keyboard events. Then your application becomes the global handler for print screens. Now if another application managed screen prints natively, can't stop that, but anything running through windows, you can get at.
The WM_KEYBOARD_LL hook is one of the few global hooks that can be used in managed code because it doesn't require a DLL to be injected into every target.
For some code you can visit here:
Adam's Blog
Keep in mind that these are global hooks so you want to make sure nothing else (other applications) are effected. I've used these in the past as we hosted showing a power point in an application we worked on. Basically we didn't want the user to invoke any powerpoint menus or keyboard short cuts so we used a global hook. We always checked to see whether the users was in a certain area (screen) and in our application, otherwise we would effect other applications functionality (including our own!)
Microsoft Information:
Hooks Overview
There's this.....
visual cryptography
live example here
But this could be easily coded against by taking multiple screenshots and laying them overeachother and such...
If you are using Windows, and you can avoid that screenlogging happens, you can implement a nice solution like a virtual desktop to embed your process into it. When a process is running inside a virtual desktop it is possible to bypass an screenlogger tool that runs over win32 Api.
Check out this article so you can sneak a peek how to implement a nice solution to scape from screen and keyboard monitoring.
http://www.codeproject.com/Articles/7392/Lock-Windows-Desktop?fid=62485&select=3139662&fr=101#xx0xx

Capture all Windows 7 Touch events, not just on my form when it has focus

I have an application which has a form, but the fact that it has a form is irrelevant.
With this app, I need to listen to all Operating System level Touch events. Basically I need to capture that the screen has been touched no matter which form has focus, gather all the info like coordinates etc. and then do whatever with it.
I'll actually be sending it on to another app via a Windows Message but that's not relevant either. I just need to know how to listen and capture ALL OS level touch + drag events etc.
You can read HID data directly, using a Raw Input API and to parse it by yourself.
In general:
Find Hids and store preparsed data.
Register for input events
On WM_INPUT event parse buffer using HID API functions and preparsed data.
This link explains the topic of keyboard/mouse event hooks.
It is a rather advanced subject however, filled with lots of low-level interop. I'd avoid such a task and try to come up with a different solution for this. What is your final goal with this application?

C#: Record and Playback GUI Events

how can i record and playback mouse and keybaord events.
i need this to capture the user interactions with my application so that later on i can play to see what user did.
There are literally hundreds of keyboard / mouse automation apps out there:
http://www.nonags.com/nonags/auto.html
I recommend Do It Again - its free, easy to use and works well, although if I remember correctly it has a quirk where it doesn't work particularly well over a remote desktop connection.
UPDATE: Just re-read the question, I dont think what you want is the ability to record keyboard / mouse actions, as its not guarenteed that the application will "keep up" with the mouse clicks (windows could open in slightly different places, or there could be a slight delay etc...)
What you want is some screen capture software.
You should hook keyboard and mouse events, see Processing Global Mouse and Keyboard Hooks in C# , Low-Level Mouse Hook in C# or Processing Global Windows Mouse and Keyboard Hooks in C#

Emulate Key Presses On an App that takes no Win Messages

I want to send an Application Key Presses, To Automate some stuff that has to be done repeatedly and So I don't always have to cramp my fingers.
In C#, it's nice to use SendKeys.Send(), but this won't work because the Application doesn't take Windows Messages. SendKeys.SendWait() does nothing at all.
How would I STILL Simulate the Keyboard events?
Come To Think of It, I was going to use some P/Invoke to simulate Mouse Events too, but If it takes no messages, How Can I get around that?
EDIT - I can use mouse and keyboard to interact with the program, I just cannot manipulate it with Windows Messages sent from my own Code.
Have you tried AutoIt?
Is it a console app? If so, maybe you should be SendKeys'ing to the command shell instance it is running in.

Categories

Resources