Home > Software engineering >  How to simulate raw input (WM_INPUT message
How to simulate raw input (WM_INPUT message

Time:09-22

Currently have an application is to use the rawinput handle mouse and keyboard, I want to simulate the WM_INPUT mouse messages sent, but no response, is excuse me this does not support across processes to send, if injected into the target process?

CodePudding user response:

https://www.cnblogs.com/songr/p/5467007.html

CodePudding user response:

Your code?

CodePudding user response:

WM_INPUT response is as follows: simulate a (lParam HRAWINPUT)
 case WM_INPUT: 
{
UINT dwSize;
GetRawInputData (lParam HRAWINPUT, RID_INPUT, NULL, & amp; DwSize, sizeof (the RAWINPUTHEADER));
LPBYTE LPB=new BYTE [dwSize];
If (LPB==NULL)
{
return 0;
}

If (GetRawInputData (lParam HRAWINPUT, RID_INPUT, LPB, & amp; DwSize, sizeof (the RAWINPUTHEADER))!=
DwSize)
OutputDebugString (TEXT (" GetRawInputData doesn 't return correct size! \ n "));

The RAWINPUT * raw=(*) the RAWINPUT LPB;

If (raw - & gt; The header. DwType==RIM_TYPEKEYBOARD)
{
If (raw - & gt; Data. The rid_device_info_keyboard. Message==WM_KEYDOWN)
{
if (! IsInKeys (raw - & gt; Data. The rid_device_info_keyboard. VKey))
{
Char keytext [10]={0};
BYTE state [256]={0};

//is obtained by the virtual keyboard code name
ToAscii (raw - & gt; Data. The rid_device_info_keyboard. VKey, raw - & gt; Data. The rid_device_info_keyboard. MakeCode state, (LPWORD) keytext, 0);
Char buf [10]={0};
String s="keyboard press the virtual key code:" + string (keytext);
MessageBoxA (NULL, s.c _str (), "keyboard", MB_OK);
}
}

If (raw - & gt; Data. The rid_device_info_keyboard. Message==WM_KEYUP)
{
Erasekey (raw - & gt; Data. The rid_device_info_keyboard. VKey);
}
}
The delete [] LPB;
return 0;
}//end case WM_INPUT
https://msdn.microsoft.com/en-us/library/ms645590 (vs. 85). Aspx

CodePudding user response:

refer to the second floor schlafenhamster response:
your code?
SendMessage is simple

CodePudding user response:

reference schlafenhamster reply: 3/f
WM_INPUT response is as follows: simulate a (lParam HRAWINPUT)
 case WM_INPUT: 
{
UINT dwSize;
GetRawInputData (lParam HRAWINPUT, RID_INPUT, NULL, & amp; DwSize, sizeof (the RAWINPUTHEADER));
LPBYTE LPB=new BYTE [dwSize];
If (LPB==NULL)
{
return 0;
}

If (GetRawInputData (lParam HRAWINPUT, RID_INPUT, LPB, & amp; DwSize, sizeof (the RAWINPUTHEADER))!=
DwSize)
OutputDebugString (TEXT (" GetRawInputData doesn 't return correct size! \ n "));

The RAWINPUT * raw=(*) the RAWINPUT LPB;

If (raw - & gt; The header. DwType==RIM_TYPEKEYBOARD)
{
If (raw - & gt; Data. The rid_device_info_keyboard. Message==WM_KEYDOWN)
{
if (! IsInKeys (raw - & gt; Data. The rid_device_info_keyboard. VKey))
{
Char keytext [10]={0};
BYTE state [256]={0};

//is obtained by the virtual keyboard code name
ToAscii (raw - & gt; Data. The rid_device_info_keyboard. VKey, raw - & gt; Data. The rid_device_info_keyboard. MakeCode state, (LPWORD) keytext, 0);
Char buf [10]={0};
String s="keyboard press the virtual key code:" + string (keytext);
MessageBoxA (NULL, s.c _str (), "keyboard", MB_OK);
}
}

If (raw - & gt; Data. The rid_device_info_keyboard. Message==WM_KEYUP)
{
Erasekey (raw - & gt; Data. The rid_device_info_keyboard. VKey);
}
}
The delete [] LPB;
return 0;
}//end case WM_INPUT
https://msdn.microsoft.com/en-us/library/ms645590 (vs. 85). Aspx
this is just deal with their own WM_INPUT I tried to use the structure of the message to the target application SendMessage is not working

CodePudding user response:

"I tried to use the structure of the message to the target application SendMessage bad use,"
Take a look at your code

CodePudding user response:

May simulate a "(lParam HRAWINPUT)" is not the same address space

CodePudding user response:



refer to 6th floor schlafenhamster response:
"I tried to use the structure of the message to the target application SendMessage bad use,"
Take a look at your code

My approach is to creative a dialog box procedure, and then the WM_INPUT you register, and then received the news, SendMessage directly to another target program

CodePudding user response:

"SendMessage directly to another target program"
Must be in another target programs, simulating a (lParam HRAWINPUT)

CodePudding user response:

references 9 f schlafenhamster response:
"SendMessage directly to another target program"
Must be in another target programs, simulating a (HRAWINPUT) lParam

Is this brother, another program is u3d brothers made of 3 d scene, we want to do test automation to him, by injecting hooks that his internal handling of the mouse is made of raw input receive the mouse message, so there is no effect, we use SendMessage what brother I didn't quite understand your meaning

CodePudding user response:

The address of the variable can't spread to another target program, so need to apply in another target programs a piece of memory (lParam HRAWINPUT), the content is copied to the
Another target program, SendMessage again

CodePudding user response:



11 references schlafenhamster response:
the address of the variable can't spread to another target program, so need to apply in another target programs a piece of memory (lParam HRAWINPUT), the content is copied to the
Another object program, then SendMessage

https://stackoverflow.com/questions/12590145/how-to-simulate-raw-input-send-a-wm-input-message-to-an-application-the-right this method? Still say after my goal injection process, in his a internal structure, then SendMessage

CodePudding user response:

Refer to
 
Void CRemoteListCtrlDlg: : RemoteHeaderItem (HWND HWND)
{
//GetItemCount
Int nHeaderCount=: : SendMessage (hWnd HDM_GETITEMCOUNT, 0, 0); nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related