Hack Forums
[C#] Physical keypress - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Physical keypress (/showthread.php?tid=6184546)



Physical keypress - agoSwitch - Dec 11, 2021

First post here. Hello!

I want to simulate physical keypresses (Windows). My application manage to synthesize keystrokes using classes like SendInput and Sendkeys but the keystrokes is registered as artificial by the os. I want the key presses made by my application to be identical to as when I press on my keyboard.

Any idea? Is this achievable using C#?


RE: Physical keypress - hazbot77 - Dec 19, 2021

I don't believe such a thing is possible. Why does it being artificial matter? Please include more detail in your thread.

EDIT - Apparently it is with a driver as said below


RE: Physical keypress - oje28830 - Dec 21, 2021

You'd need to write some code that communicates with the physical HID keyboard device driver. If you don't have experience with driver development or ways of communicating with one, this could be challenging to you.

Here's a beginning for you, it's a wrapper in .NET which makes life easier to communicate with USB, Serial Port and Hid devices.

https : // christianfindlay . com /2021/01/31/device-net-4/


RE: Physical keypress - Scapula™ - Dec 23, 2021

Bye bye LLMHF_INJECTED & LLMHF_LOWER_IL_INJECTED from MouseEvent/SendInput ;)
https://github.com/jasonpang/Interceptor


RE: Physical keypress - agoSwitch - Dec 24, 2021

(Dec 19, 2021 11:10 PM)hazbot77 Wrote:  I don't believe such a thing is possible. Why does it being artificial matter? Please include more detail in your thread.

EDIT - Apparently it is with a driver as said below

(Dec 21, 2021 09:25 AM)oje28830 Wrote:  You'd need to write some code that communicates with the physical HID keyboard device driver. If you don't have experience with driver development or ways of communicating with one, this could be challenging to you.

Here's a beginning for you, it's a wrapper in .NET which makes life easier to communicate with USB, Serial Port and Hid devices.

(Dec 23, 2021 08:47 AM)Scapula™ Wrote:  Bye bye LLMHF_INJECTED & LLMHF_LOWER_IL_INJECTED from MouseEvent/SendInput ;)

Thanks. I have already (by spending many hours on Google searches) achieved my goal but I appreciate your answers.

Merry Christmas!


RE: Physical keypress - oje28830 - Dec 24, 2021

(Dec 24, 2021 06:37 AM)agoSwitch Wrote:  Thanks. I have already (by spending many hours on Google searches) achieved my goal but I appreciate your answers.

Merry Christmas!

How did you achieve your goal? share it here with everyone so people can learn.


RE: Physical keypress - oje28830 - Dec 27, 2021

Btw, with SendInput you can mimic a physical keyboard or mouse event. Look at the INPUT_HARDWARE field within the INPUT structure that you're passing to the api.