On 11/03/2011 00:58, Justin Ezequiel wrote:
Greetings,

We have an old barcode program (MSDOS and source code unavailable.)
I've figured out how to populate the fields (by hacking into one of
the program's resource files.)
However, we still need to hit the following function keys in sequence.
F5, F2, F7
Is there a way to pipe said keys into the program?

I know it's not really a python problem but I got nowhere else to go.
I've tried other barcode solutions but none give the same output.

One (hacky) solution is to use the sendkeys module:

    http://www.rutherfurd.net/python/sendkeys/

First enumerate the windows and get the title and handle of each:

    import win32gui

    def enum_windows(accept=None):
        def callback(handle, data):
            title = win32gui.GetWindowText(handle)
            windows.append((title, handle))
        windows = []
        win32gui.EnumWindows(callback, None)
        return windows

Identify the target window's handle by its title and give that window
the input focus:

    win32gui.SetForegroundWindow(handle)

Then use the sendkeys module to simulate the keypresses.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to