6

This question was asked 3 years ago and the guy ended up with unsatisfying results.

See: https://www.reddit.com/r/learnpython/comments/22tke1/use_python_to_send_keystrokes_to_games_in_windows/

Also posted on this site (w/ less discussion): Use Python to send keystrokes to games in Windows?

My issue is the exact same as his was: My scripts can send keystrokes to everything (web browser, text doc, shell, etc.) except to a game window. Specifically it's a Gameboy Color Emulator named bgb that I'm using to play Pokemon Blue. I just want my code to be able to play the game.

I have tried the shell.SendKeys, api.keybd_event, and ctypes methods shown in the code in the links above. I've also tried pyautogui. All of these work to interact with most programs, just not the Emulator.

I even had the silly idea to use Windows On-Screen Keyboard and send mouse clicks to the coordinates of relevant buttons. While the mouse clicks worked on other applications, it would not actually click the On-Screen Keyboard.

Does anyone have any insight on this issue?

taras
  • 6,566
  • 10
  • 39
  • 50
Rey
  • 69
  • 2

1 Answers1

0

You can remote control BGB over TCP/IP.

Here are some examples:

BGB Link protocol documentation: https://bgb.bircd.org/bgblink.html

101 - joypad

Joypad change, for remote control of an emulator. The receiving end can choose to ignore joypad changes, or update its button state accordingly.

Any bits and fields other than the ones used for a purpose MUST be 0 when sending, and MUST be ignored when receiving.

b2=joypad change
  bit 0-2: button number
  bit 3: 1 if button is pressed, 0 if button is released
  bit 4-7: 0 (due to a bug in previous bgb versions, these bits can't be used in the future and must remain 0)
b3=0
b4=0
i1=0