Re: send function keys to a legacy DOS program

2011-03-29 Thread Alexander Gattin
Hello,

On Sun, Mar 20, 2011 at 06:59:46PM -0700, Justin
Ezequiel wrote:
 On Mar 20, 7:30 am, Alexander Gattin
 xr...@yandex.ru wrote:
  You need to place 2 bytes into the circular buffer
  to simulate key press. Lower byte is ASCII code,
  higher byte is scan code (they are the same for
  functional keys, whe using default keycode set#1):
 
  F5: 0x3F 0x3F
  F2: 0x3C 0x3C
  F7: 0x41 0x41

I'm not sure regarding the ASCII part. I think it
might need to be set to 0x00 for all functional
keys instead of 0x3F/0x3C/0x41, but probably no
application actually cares.

Another thing is that you may need to send key
release after key press in order for the
application to trigger the F5/F2/F7 event. I'm not
sure what the scan codes for F5/F2/F7 releases
are, but think that they may be:

F5: 0xBF
F2: 0xBC
F7: 0xC1

-- 
With best regards,
xrgtn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-29 Thread Mel
Alexander Gattin wrote:
 Another thing is that you may need to send key
 release after key press in order for the
 application to trigger the F5/F2/F7 event. I'm not
 sure what the scan codes for F5/F2/F7 releases
 are, but think that they may be:

 F5: 0xBF
 F2: 0xBC
 F7: 0xC1

True.  The key-release codes are the key-press codes (the key numbers)
but with the high-order bit set.

Mel.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-29 Thread Justin Ezequiel
On Tue, Mar 29, 2011 at 9:59 PM, Alexander Gattin xr...@yandex.ru wrote:
 I'm not sure regarding the ASCII part. I think it
 might need to be set to 0x00 for all functional
 keys instead of 0x3F/0x3C/0x41, but probably no
 application actually cares.

 Another thing is that you may need to send key
 release after key press in order for the
 application to trigger the F5/F2/F7 event. I'm not
 sure what the scan codes for F5/F2/F7 releases
 are, but think that they may be:

 F5: 0xBF
 F2: 0xBC
 F7: 0xC1

 --
 With best regards,
 xrgtn


appreciate all the help.
unfortunately, my hard drive crashed and badly.
thus was unable to investigate this further.
as I was running out of time, we're now going for a reimplementation
of the legacy barcode program.
was fortunate to find an implementation that gives the same output
(we're testing thoroughly and we may have found a winner)

oh btw, it was a seagate  250GB drive for my dell laptop
may need to pay somebody to try to recover my personal files.
all work files are in version control so they're ok
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-20 Thread John Nagle

On 3/10/2011 4:58 PM, 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.


   Look into DOSbox.

http://www.dosbox.com

It's an open-source software emulator for an x86 machine running DOS.
So you can go into the emulator and connect to the keyboard or
screen from another program.

John Nagle

--
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-20 Thread LehH Sdsk8
On Mar 10, 9:58 pm, Justin Ezequiel justin.mailingli...@gmail.com
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.

You should try these links:
http://www.rhinocerus.net/forum/lang-asm-x86/254441-re-how-write-char-keyboard-buffer.html
http://bytes.com/topic/c/answers/212952-keyboard-buffer
http://bytes.com/topic/c/answers/747883-writing-into-keyboard-buffer-aix
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-20 Thread Justin Ezequiel
On Mar 20, 7:30 am, Alexander Gattin xr...@yandex.ru wrote:
 On Sun, Mar 20, 2011 at 12:52:28AM +0200,

 You need to place 2 bytes into the circular buffer
 to simulate key press. Lower byte is ASCII code,
 higher byte is scan code (they are the same for
 functional keys, whe using default keycode set#1):

 F5: 0x3F 0x3F
 F2: 0x3C 0x3C
 F7: 0x41 0x41

 --
 With best regards,
 xrgtn

looks promising. will give this a try. thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-19 Thread Alexander Gattin
Hello,

On Thu, Mar 10, 2011 at 04:58:53PM -0800, Justin
Ezequiel wrote:
 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?

It's a very old and good known trick IMO. You just
need to write keycodes to kbd ring buffer in BIOS
data area (I don't remember exact address,
soemewhere in 1st 4kbytes of PC memory), then wait
till the scancode gets consumed. I'd put scancode
feeding code into timer interrupt handler.

-- 
With best regards,
xrgtn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-19 Thread Alexander Gattin
On Sun, Mar 20, 2011 at 12:52:28AM +0200,
Alexander Gattin wrote:
 On Thu, Mar 10, 2011 at 04:58:53PM -0800, Justin
 Ezequiel wrote:
  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?
 
 It's a very old and good known trick IMO. You just
 need to write keycodes to kbd ring buffer in BIOS
 data area (I don't remember exact address,
 soemewhere in 1st 4kbytes of PC memory), then wait
 till the scancode gets consumed. I'd put scancode
 feeding code into timer interrupt handler.

Taken from RBIL/MEMORY.LST
(http://www.cs.cmu.edu/~ralf/interrupt-list/inter61c.zip):

K-M0040001A--
MEM 0040h:001Ah - KEYBOARD - POINTER TO NEXT CHARACTER IN KEYBOARD BUFFER
Size:   WORD
SeeAlso: MEM 0040h:001Ch,MEM 0040h:0080h,MEM 0040h:0082h,INT 16/AH=00h
K-M0040001C--
MEM 0040h:001Ch - KEYBOARD - POINTER TO FIRST FREE SLOT IN KEYBOARD BUFFER
Size:   WORD
SeeAlso: MEM 0040h:001Ah,MEM 0040h:001Eh,MEM 0040h:0080h,MEM 0040h:0082h
SeeAlso: INT 16/AH=00h
K-M0040001E--
MEM 0040h:001Eh - KEYBOARD - DEFAULT KEYBOARD CIRCULAR BUFFER
Size:   16 WORDs
SeeAlso: MEM 0040h:001Ah,MEM 0040h:001Ch,MEM 0040h:0080h,MEM 0040h:0082h
SeeAlso: INT 16/AH=00h,INT 16/AH=05h

Buffer is considered empty if
word[0x41A]==word[0x41C] IIRC.

You need to place 2 bytes into the circular buffer
to simulate key press. Lower byte is ASCII code,
higher byte is scan code (they are the same for
functional keys, whe using default keycode set#1):

F5: 0x3F 0x3F
F2: 0x3C 0x3C
F7: 0x41 0x41

-- 
With best regards,
xrgtn
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-11 Thread jr
On Mar 10, 7:58 pm, Justin Ezequiel justin.mailingli...@gmail.com
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?


Use expect on unix or pexpect if you're looking for the python
implementation.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-11 Thread Emile van Sebille

On 3/10/2011 4:58 PM Justin Ezequiel said...

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.



WSH sendkeys?

Emile


--
http://mail.python.org/mailman/listinfo/python-list


send function keys to a legacy DOS program

2011-03-10 Thread Justin Ezequiel
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.


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: send function keys to a legacy DOS program

2011-03-10 Thread MRAB

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