Trying to send keystrokes to NES emulator

srinathava at gmail.com srinathava at gmail.com
Thu Nov 30 21:41:57 EST 2006


Hi,

I am trying to send keystrokes to the NES emulator nester[1]. The idea
was to be able to use a standard NES controller whose "state" I can
read in using Python and then conveying that to the emulator.
Unfortunately, all the attempts I have made so far have failed. It
looks like the emulator is using some extremely low-level function to
read keystrokes and I cannot get in before it.

So far, I have tried the following functions from Python's win32api and
using ctypes:

1. SendInput
http://mail.python.org/pipermail/python-win32/2005-April/003131.html

2. keybd_event
    win32api.keybd_event(90, 0, 0, 0)
   This should have sent the 'z' key to the emulator which in Contra
makes the little guy shoot. However, the emulator just sits there.

3. SendKeys
import win32api
import win32com.client

shell = win32com.client.Dispatch("WScript.Shell")

shell.AppActivate("nester")
shell.SendKeys('s')

My suspicion is that nester is using something lower-level than where
these functions change stuff. I read about GetAsyncKeyState. However, I
couldn't figure out for the life of me how to force the return value of
the GetAsyncKeyState function.

I would really appreciate any help in this regard :)

Thanks!
Srinath (speaking only on behalf of myself)

PS: Does anyone know of a good way to play old NES games on the PC
using the classic NES controllers?

[1] http://nester.dranalli.com/




More information about the Python-list mailing list