sunshinekitty sunshinekitty - 1 year ago 164
Python Question

Python 3.3 Send Keys to Visual Boy Advance

Following along with ( I was able to load up a program, gain focus on the program, however I'm not able to send actual keys into the emulation, it's like it's sending to the window and not inside the emulation.

The bit of code that I am using goes like:

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

Which all works until I try and send {DOWN}, I have also tried "z" and it won't send inside of the window, even though it sends fine to any other application. Any ideas? Thanks in advance.


Problem was that SendKey isn't compatible with Direct Input, to get past this I used win32api's keybd_event for direct input


def press(*args):
    press, release
    eg press('x', 'y', 'z')
    for i in args:
        win32api.keybd_event(VK_CODE[i], 0, 0, 0)
        win32api.keybd_event(VK_CODE[i],0 ,win32con.KEYEVENTF_KEYUP ,0)