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:
Changing my OS to windows 7: I don't want to lower my OS version
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
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.
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
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.
Related
Is it possible to work at Raspberry Pi Pico using Windows 10? My question specified is: do I have to install any Linux distro, for example Raspbian, to be able to work at it? Do I also need to use SD card to work with it?
Just want to receive feedback, cause I'm confused and also kinda new to embedded systems
I may share my experience so far, I'm not an expert and this list does not claim to be complete at all.
The pi pico can be programmed by using
Picomite Basic (found here: https://geoffg.net/picomite.html) which doesnt need anything installed on the PC except a terminal program (I am using Tera Term)
MicroPython (never used it myself, afaik Thonny - found here: https://thonny.org/ is the preferred IDE )
C/C++/ASM This is what I am using, the SDK is available for Windows, Linux and Raspbian (MacOS maybe too?), an excellent guide on how to install it and how to use it is found here: https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
Arduino The Pico can even be used as an arduino device too, a good point to start is here: https://github.com/earlephilhower/arduino-pico
Keep in mind, that the interpreted languages (basic and python) are easier to handle (no big SDK or framework need to be installed on the PC, copying code to the pico is a relative easy step) but at a cost of speed. If you need a lot of cpu power, compiled languages are by far the better choice
To answer your questions, yes, no, and no. You should be able to get going on Windows 10 with just the raspberry pi pico and a micro USB to USB cable.
I got started with mine this weekend - seeing the on-board LED blink finally made me so happy.
The official getting started guide pointed me at this script for getting started on Windows.
It set up docs, examples, visual studio code, and more for me. Between its README and chapter 9 of the getting started guide ("Building on MS Windows"), I was able to get my little light blinking :)
Good luck to you on your embedded journey!
As an alternative, an in addition to #Tommylee2k's helpful insights, you can develop and run Python software for a Pico with absolutely no software needing to be installed on a Windows PC.
At its most basic level, you press the BOOTSEL switch and insert the Pico's USB cable into your PC, and the few MB of space on the Pico appear in your Windows File Explorer as a USB disk drive.
You then write your microPython software using any text editor you prefer. All these general purpose modules are available. And all these Pico-specific modules are available.
You then copy (drag and drop) your Python script to the Pico disk drive and save it as main.py.
The Pico will then run that script on every subsequent power-up. Of course you can re-attach the Pico to your PC and edit the file at a later date.
That is adequate and simple enough. If you want a REPL and friendly editor and console logging and other developer-friendly features, you can install Thonny for free and code more effectively but it is not actually absolutely necessary. It's a bit like driving a car without ABS, without an automatic gearbox and without aircon - it can get you from A to B without problems but there are easier and more comfortable methods.
I stumbled upon fancy ASCII BEL in a book. Then I (Briefly) read the article on ASCII BEl on Wikipedia, and did know that it produces a noise(alert noise).
Tried in python(3), tried in C, didn't work.
Probably people don't need the bell these days or something.
It is seldom in use now and many consoles are not supporting it. In case you are interested in the history of it, I found this from Microsoft:
A long time ago, all PC computers shared a common 8254 programable interval timer chip for the generation of primitive sounds. The Beep function was written specifically to emit a beep on that piece of hardware.
On these older systems, muting and volume controls have no effect on Beep; you would still hear the tone. To silence the tone, you used the following commands:
net stop beep
sc config beep start= disabled
Since then, sound cards have become standard equipment on almost all PC computers. As sound cards became more common, manufacturers began to remove the old timer chip from computers. The chips were also excluded from the design of server computers. The result is that Beep did not work on all computers without the chip. This was okay because most developers had moved on to calling the MessageBeep function that uses whatever is the default sound device instead of the 8254 chip.
Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.
I have two computers; one MacBook Pro and one desktop PC running Windows. For various reasons I prefer writing code on the MacBook, while I keep the desktop PC mostly for gaming and entertainment purposes.
Since I've gotten so used to programming on an OSX keyboard layout, I often find it cumbersome to start working on something while I'm on my Windows computer. And since I'm ridiculously lazy I also find it cumbersome to get my laptop out of my bag so I can switch to using that instead. This usually results in me not bothering to do much work while I'm on my desktop (which depressingly enough is most of my evenings).
I guess I'm looking for a way to quickly enable an OSX keyboard layout in Windows. I'd also like to run Ubuntu in a VM on Windows, and use the OSX keyboard there as well.
Possible?
You can use Microsoft Keyboard Layout Creator to create a custom keyboard layout on Windows that mirrors the Mac OS one.
Ubuntu has an infinitely flexible and impossibly complicated keyboard layout system called XKB, which has limited documentation. Ubuntu probably already has all the data for the Mac keyboard layout you want stored among the hundreds of files in /usr/share/X11/xkb/, but figuring out how to load it will drive you crazy. You might have luck asking about this on Ask Ubuntu or the Unix stack exchange.
You could have a look at Synergy, using your Mac keyboard on both the PC and Mac.
i want to create a virtual monitor. The way this would work is that the virtual monitor would appear in a window on my desktop. As far as Windows knows it is just another monitor.
It occurs to me that it would, as a practical matter, have to be done as video card driver (i.e. rather than the video going out a wire to an LCD panel, it would go into another window on the desktop).
Does what i'm describing sound, technically, possible? (from a DDK point of view)
Note: i can't use a virtual pc, because no virtual PC has resolutions high enough for my needs. Also because it's not what i asked for.
Note: My reasons are unimportant, but i can make some up:
i want to test my application under high-dpi settings (288dpi)
i want to create a monitor that my iPad can VNC to
the family TV runs on the main monitor
the hijacker is monitoring the bus, and he'll blow it up if he suspects we're getting the passengers off
i'm trying to expand the limits of human knowledge and understanding, for the good of all man-kind
I'd say it's definitely possible, since that's what virtualization tools do for their guest utilities, but I wouldn't be able to tell you how in details. I'd suggest looking at the VirtualBox guest driver code as a starting point:
http://www.virtualbox.org/browser/trunk/src/VBox/Additions/WINNT/Graphics
(This is released under GPL as far as I'm aware.)
It's definitely possible, see for example the UltraVNC mirror driver. But I don't know of any virtual video driver that makes source code available.
I have been searching for something similar and I found a nice solution: spacedesk. You can download it here: http://spacedesk.ph/
In windows, it installs an extra monitor, which you can open in a browser or a viewer. Enjoy!
Don't know about Windows, but for X (Linux) there is Xvfb (X Virtual Frame Buffer), which is quite a useful thing.
I have an extremely simple application running off a series of deprecated scanners that picks up a barcode scan off a serial port and sends back to the scanner an ok that it received the scan. Based on that, the scanner flashes green and the user knows they can continue.
I like this model over my understanding of a keyboard wedge because if something happens to the application picking up the scan (the application hangs, the form with the focus gets changed, the PC hangs, the PC can't keep up picking up the scans), the person holding the scan gun will know there is a problem because they won't receive the green flash and they won't be able to continue scanning.
I'm looking at adding some scanners and it seems many people are using barcode scanners that effectively act as keyboard wedges. Some of these scanners have ranges that exceed 100 feet, implying people are using them far away from the PC (as my users are). So I'm wondering if I'm missing something regarding the keyboard wedge model. Is there some mechanism I'm missing to ensure that a scan decoded by a scanner acting as a keyboard wedge actually reaches the application running on the PC? A full-blown hand-held computer running something like Windows Mobile seems like massive overkill for just wanting to ensure my user is not scanning data that isn't going into the application and so does even a mid-range scanner with a keypad and screen, but is the latter the entry point for any sort of programmatibility of the scanner?
You are correct- there isn't a feedback loop to the scanner when running as a wedge. We use wedge scanners a lot, and in a modern environment (ie, Windows, multiple apps, etc), focus, "dropped scans", etc, are all real problems.
We're in the middle of switching over to a different way. If you have your choice of hardware, many new USB barcode scanners have the ability to operate in a serial emulation mode that allows the same kind of interaction you describe (where you can prevent a second scan until the host has ACK'd the first, or you can beep/flash something on the scanner as an ACK). Also, there's a USB HID POS (point of sale) mode that some higher-end USB scanners support that gives you an even greater degree of flexibility, with the added bonus of "driver free" installation (it looks like a generic HID device to the system, like a joystick or keyboard, but with 2-way comm ability). The downside of POS mode is that it's a little harder than serial programming, but there are abstraction layers available for different platforms.
RF mobile computers with built in scanners, like the Symbol MC9090-G, are by far the most flexible and what we use the most. As for wedges, depending on the distance from the PC and factory environment - we have used visual feedback via the PC screen and audio via the PC speakers. The users listen for the audio feedback after each scan and when they don't hear it they look back to the PC screen for visual feedback as to the problem. Not perfect but it has worked well.