0

I'm trying to write a bot for a game. The huge problem I'm running into for months now is keyboard simulation
My operation system is windows 10. On that OS when trying to simulate key press via code, windows 10 adds to the request a flag. This flag indicates that this key press came from a program, and not from the hardware.
That way games can check the user input and filter all of the key simulated presses

My game does that, So I have been trying to find a way to pass that.

VirtualBox
The first solution is to run the game from a virtual box. Then running the bot program from the host. When focusing on the VirtualBox the program is being able to simulate the keyboard with no problem. (That is because VirtualBox does the hard word of "fooling" the OS that the key simulation came from the hardware)

This way works pretty well, but the main disadvantage is that running the game on VM is super slow, the game flips a lot. I have tried multiple tutorials on how to get the best gaming results on VM but nothing really worked..

Real keyboard simulation
That idea came to me lately. I wonder if I can somehow fool my PC to think the key press came from the hardware.
Maybe using male to male USB cable and connect the PC to itself, then do real keyboard simulation (sending keyboard requests from one side of the USB and get it through the other).
Or maybe some other way to achieve that?

What I don't want
There are some solutions that will probably work, but I don't want to try:

  1. Changing my OS to windows 7: I don't want to lower my OS version
  2. Dual boot of windows 7: I have tried before dual boots for linux, it was hideous to make it work

The question is, do you have any idea how to simulate keyboard on such way that Windows 10 won't add the "rat" flag

UdiM
  • 480
  • 3
  • 19

4 Answers4

2

Option 1

Windows driver is exactly what you need. In your windows driver, create an keyboard HID device, then send your keys though this HID device.

  • Pros:
    • Total software
  • Cons:
    • Complicated
    • Windows driver should be signed (you must pay for it), or you must set your windows 10 to Test Mode to load driver

Option 2

Use Arduino to send your keys. ref to https://www.arduino.cc/reference/en/language/functions/usb/keyboard/

  • Pros
    • Easy to learn
  • Cons
    • Hardware is required.
Jks Liu
  • 457
  • 2
  • 12
  • Option 1: Can I write driver to the current OS? I have seen videos which ran the custom OS on VM Option 2: I got the hardware =) maybe ill choose that way – UdiM Aug 12 '20 at 09:12
  • Yes. Driver bugs may cause BSOD. I recommend that writing you driver in one system, but testing (debug) your driver in another system (like a VM). – Jks Liu Aug 12 '20 at 09:17
0

you need driver level key simulation.
because some games made by D3D game engine will blocks system level simulation like winAPI or pykeyboard.

I used use the driver level key simulation to cheat in games, like lol, cs, pubg...

so , if u use python, u can use keyboard, mouse, ctypes, etc.
if u are win32 platform, u can use winio and pydamo.

they all are driver level simulation.

ps: If your game blocks one solution, please try another one.


keyboard
ctypes simulation

bode liang
  • 119
  • 3
0

Considerations about other solutions here:

I tested most of the solutions (python libraries, mostly):

keyboard

ctypes simulation

However, only two seem to work. It is by simulating a virtual environment or using an Arduino.

Both solutions require much effort in terms of installation and programming (maybe you can get the Arduino code, but, you will have to deal with Arduino code)

Solution:

A possible workaround I tested and worked quite well is using keyboard software such as Hyperx NGENUITY to save a macro. The macro is associated with the button in the keyboard software that the keyboard hardware executes. This way, the keyboard will work as an Arduino.

0

I had no success using WshShell.SendKeys, different python/pip approaches, MacroRecorder etc. for the software I tried to inject with keystrokes. What I did find successful was:

https://github.com/oblitum/Interception
https://github.com/oblitum/interception/releases/tag/v1.0.1
http://www.microsoft.com/en-us/download/details.aspx?id=11800

There is/was an example x2y in the Interception, which I adjusted by first figuring out the device by printing the device-int after interception wait_for had it set. Than just hardcoded device to that number and you can easily send stroke-structs as per the example. GL!

P.S. What shit is this: Your post appears to contain code that is not properly formatted as code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.

nudeln
  • 11
  • 2