Ignore mouse click and send keyboard. Login to an external application.

How to simulate keystrokes when the mouse is pressed in the old program. THE NOTE! The program may not know that the mouse is pressed.

I am experimenting with

 IntPtr module = LoadLibrary("user32.dll");
 _mouseHookHandle = (HookType.MouseLowLevel, _mouseDelegate, module, 0);

and check to return -1 from HookProc. But when I do this, it SendInputdoes not send my entry to the application. If I return the result from CallNextHookEx, it SendInputworks, but then the mouse click is sent to the outdated application.

Background

We have a program that is controlled by a special keyboard. When you press a key on the keyboard, it sends a sequence of ESC and letters. Then the program performs an operation based on placing the mouse over the screen.

I am developing an on-screen keyboard so that you can control the application without this special keyboard. The user selects a button on the keyboard screen with the mouse. Then the user moves the mouse over the object that he wants to send a commando, and then click again. But at the same time, a mouse click cannot be transferred to the program; the program performs another operation with a mouse click.

+3
source share
3 answers

As one of the possible ways, you can use simple SendMessage to send any window messages directly to the target window. It can be used with windows of an external application. (but you need to find the target window handle to use this function). This way you can send any keyboard and mouse events.

. , .. . , DLL .
, , -.

+2

, , SendKeys MouseClick script System.Windows.Form.SendKeys → Send ({KeyBoardKey})

: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx

0

, .

, . , , , API SendMessage().

, ESC ? , - .

HWND , , API FindWindow()/FindWindowEx(). , , .

, SendMessage() :

"SendMessage" (Vb.net)

0

All Articles