Invalid Handle Exception from GetRawInputData
up vote
-2
down vote
favorite
I am using the User32 SendMessage
function to send raw keyboard input to my API.
The function that intercepts the SendMessage
call is the WndProc
function. This function runs the Win32 GetRawInputData
function to get the data buffer from the IntPtr handle from the lParam from the message recieved by the SendMessage
function.
When I run the GetRawInputData
functionm I get the following error:
>>> 6:System.ComponentModel.Win32Exception (0x80004005): The handle
is invalid
How can I fix this?
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# winapi hook handle low-level
|
show 3 more comments
up vote
-2
down vote
favorite
I am using the User32 SendMessage
function to send raw keyboard input to my API.
The function that intercepts the SendMessage
call is the WndProc
function. This function runs the Win32 GetRawInputData
function to get the data buffer from the IntPtr handle from the lParam from the message recieved by the SendMessage
function.
When I run the GetRawInputData
functionm I get the following error:
>>> 6:System.ComponentModel.Win32Exception (0x80004005): The handle
is invalid
How can I fix this?
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# winapi hook handle low-level
GetRawInputData expects a handle to aRAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot sendWM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.
– IInspectable
Nov 22 at 6:52
@IInspectable I have changed the struct toRAWINPUT
but can't figure out how to pass as a handle instead of a pointer
– SillySam
Nov 22 at 7:26
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consumingWM_INPUT
messages only. SendingWM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?
– IInspectable
Nov 22 at 7:30
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
It's unclear why you believe that sending aWM_INPUT
message were part of blocking input.
– IInspectable
Nov 22 at 10:35
|
show 3 more comments
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I am using the User32 SendMessage
function to send raw keyboard input to my API.
The function that intercepts the SendMessage
call is the WndProc
function. This function runs the Win32 GetRawInputData
function to get the data buffer from the IntPtr handle from the lParam from the message recieved by the SendMessage
function.
When I run the GetRawInputData
functionm I get the following error:
>>> 6:System.ComponentModel.Win32Exception (0x80004005): The handle
is invalid
How can I fix this?
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# winapi hook handle low-level
I am using the User32 SendMessage
function to send raw keyboard input to my API.
The function that intercepts the SendMessage
call is the WndProc
function. This function runs the Win32 GetRawInputData
function to get the data buffer from the IntPtr handle from the lParam from the message recieved by the SendMessage
function.
When I run the GetRawInputData
functionm I get the following error:
>>> 6:System.ComponentModel.Win32Exception (0x80004005): The handle
is invalid
How can I fix this?
Hook
//^ DLL Imports, SetWindowsHookEx, etc^
public int HookProc(int Code, int wParam, ref CWPRETSTRUCT lParam) {
if (Code >= 0) {
// Block
Rawkeyboard lParamKeyboard = new Rawkeyboard();
int result = SendMessage(Handle, 0x00FF, wParam, ref lParamKeyboard ); // Send to API
if (result == 1) {
return 1;
}
}
// Allow
return CallNextHookEx(Handle, Code, wParam, ref lParam);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawkeyboard {
public ushort Makecode; // Scan code from the key depression
public ushort Flags; // One or more of RI_KEY_MAKE, RI_KEY_BREAK, RI_KEY_E0, RI_KEY_E1
private readonly ushort Reserved; // Always 0
public ushort VKey; // Virtual Key Code
public uint Message; // Corresponding Windows message for exmaple (WM_KEYDOWN, WM_SYASKEYDOWN etc)
public uint ExtraInformation; // The device-specific addition information for the event (seems to always be zero for keyboards)
public override string ToString() {
return string.Format("Rawkeyboardn Makecode: {0}n Makecode(hex) : {0:X}n Flags: {1}n Reserved: {2}n VKeyName: {3}n Message: {4}n ExtraInformation {5}n",
Makecode, Flags, Reserved, VKey, Message, ExtraInformation);
}
}
[StructLayout(LayoutKind.Sequential)]
public struct CWPRETSTRUCT {
IntPtr lResult;
IntPtr lParam;
IntPtr wParam;
uint message;
IntPtr hWnd;
}
API
protected override void WndProc(ref Message message){
switch (message.Msg){
// Message Received!
case 0x00FF:{
bool result = false;
hdevice = message.LParam;
if (_deviceList.Count == 0) return false;
var dwSize = 0;
Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, IntPtr.Zero, ref dwSize, Marshal.SizeOf(typeof(Rawinputheader)));
if (dwSize != Win32.GetRawInputData(hdevice, DataCommand.RID_INPUT, out _rawBuffer, ref dwSize, Marshal.SizeOf(typeof (Rawinputheader)))){
if (result == -1) { var code = Marshal.GetLastWin32Error(); var error = new Win32Exception(code); Debug.WriteLine(code + ":" + error.ToString()); }
Debug.WriteLine("Error getting the rawinput buffer");
result = false;
}
else{
// Do checks here
result = true;
}
message.Result = (IntPtr)Convert.ToInt32(result);
}
break;
}
base.WndProc(ref message);
}
[StructLayout(LayoutKind.Sequential)]
public struct Rawinputheader
{
public uint dwType; // Type of raw input (RIM_TYPEHID 2, RIM_TYPEKEYBOARD 1, RIM_TYPEMOUSE 0)
public uint dwSize; // Size in bytes of the entire input packet of data. This includes RAWINPUT plus possible extra input reports in the RAWHID variable length array.
public IntPtr hDevice; // A handle to the device generating the raw input data.
public IntPtr wParam; // RIM_INPUT 0 if input occurred while application was in the foreground else RIM_INPUTSINK 1 if it was not.
public override string ToString()
{
return string.Format("RawInputHeadern dwType : {0}n dwSize : {1}n hDevice : {2}n wParam : {3}", dwType, dwSize, hDevice, wParam);
}
}
c# winapi hook handle low-level
c# winapi hook handle low-level
asked Nov 22 at 5:21
SillySam
526
526
GetRawInputData expects a handle to aRAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot sendWM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.
– IInspectable
Nov 22 at 6:52
@IInspectable I have changed the struct toRAWINPUT
but can't figure out how to pass as a handle instead of a pointer
– SillySam
Nov 22 at 7:26
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consumingWM_INPUT
messages only. SendingWM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?
– IInspectable
Nov 22 at 7:30
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
It's unclear why you believe that sending aWM_INPUT
message were part of blocking input.
– IInspectable
Nov 22 at 10:35
|
show 3 more comments
GetRawInputData expects a handle to aRAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot sendWM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.
– IInspectable
Nov 22 at 6:52
@IInspectable I have changed the struct toRAWINPUT
but can't figure out how to pass as a handle instead of a pointer
– SillySam
Nov 22 at 7:26
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consumingWM_INPUT
messages only. SendingWM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?
– IInspectable
Nov 22 at 7:30
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
It's unclear why you believe that sending aWM_INPUT
message were part of blocking input.
– IInspectable
Nov 22 at 10:35
GetRawInputData expects a handle to a
RAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot send WM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.– IInspectable
Nov 22 at 6:52
GetRawInputData expects a handle to a
RAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot send WM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.– IInspectable
Nov 22 at 6:52
@IInspectable I have changed the struct to
RAWINPUT
but can't figure out how to pass as a handle instead of a pointer– SillySam
Nov 22 at 7:26
@IInspectable I have changed the struct to
RAWINPUT
but can't figure out how to pass as a handle instead of a pointer– SillySam
Nov 22 at 7:26
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consuming
WM_INPUT
messages only. Sending WM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?– IInspectable
Nov 22 at 7:30
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consuming
WM_INPUT
messages only. Sending WM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?– IInspectable
Nov 22 at 7:30
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
It's unclear why you believe that sending a
WM_INPUT
message were part of blocking input.– IInspectable
Nov 22 at 10:35
It's unclear why you believe that sending a
WM_INPUT
message were part of blocking input.– IInspectable
Nov 22 at 10:35
|
show 3 more comments
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424342%2finvalid-handle-exception-from-getrawinputdata%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53424342%2finvalid-handle-exception-from-getrawinputdata%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
GetRawInputData expects a handle to a
RAWINPUT
structure, whereas the code is passing a pointer. How the handle is constructed is an undocumented implementation detail. You cannot sendWM_INPUT
messages. Which doesn't make much sense anyway, outside of testing.– IInspectable
Nov 22 at 6:52
@IInspectable I have changed the struct to
RAWINPUT
but can't figure out how to pass as a handle instead of a pointer– SillySam
Nov 22 at 7:26
Of course not, because it is an undocumented implementation detail of the system. You don't need to know, how to construct a handle, because the system does that, provided that you use the API the way it's intended to be used, i.e. consuming
WM_INPUT
messages only. SendingWM_INPUT
messages is not supported. What problem are you trying to solve, that requires you to fake input?– IInspectable
Nov 22 at 7:30
@IInspectable I have a RFID card scanner that acts as a keyboard. I need to get its output and stop it from continuing to display in Windows. The API can figure out what device is inputting data but cannot block it so thats why I'm trying to use a hook. I've honestly been stuck on this issue for a week and its driving my head in, any help will be very appreciated!
– SillySam
Nov 22 at 10:24
It's unclear why you believe that sending a
WM_INPUT
message were part of blocking input.– IInspectable
Nov 22 at 10:35