Highlighted
Absent Member.
Absent Member.
1548 views

[archive] Responding To Every Key Entered

[Migrated content. Thread originally posted on 28 July 2003]

I am having a problem trying to have a program respond to every key tapped. I have a POS application where every key on the keyboard could translate to a POS function. The exception keys are not an issue however the not exception keys are. I have a 1 character automatic entry field that advances on the key to the next control.

I have 2 problems:
1) How can i ensure that entry field remains the active field on the screen.

2) I have some edit keys that do not allow me to map them to exception/termination keys. For example the left and right arrows. In my program in the before program section i have 2 lines:
SET ENVIRONMENT "KEYSTROKE" TO "TERMINATE=116 kr".
SET ENVIRONMENT "KEYSTROKE" TO "TERMINATE=117 kl".
But this does not seem to effect these keys. I have done this on unix systems under earlier runtime versions but not in acu 6.0 using windows 98. Any ideas???
0 Likes
5 Replies
Highlighted
Absent Member.
Absent Member.

RE: [archive] Responding To Every Key Entered

Hi msix,
did you consider using w$getc?
We often use this library routine to avoid the standard i/o
behavior.
Anyway if you use Win as client, you can't be sure that the focus
is on your program, at least without using some Api.

hope this helps
ciao
Luca
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Responding To Every Key Entered

Thanks Luca. I did try using the w$getc. I think this would work for me if i was only accepting input from the keyboard but there are also a couple active x controls in this app which also create input so it gets a little messy trying to accept the form and use the w$getc at the same time.

The main problem now is that the keystroke entries which turn these editting functions off does not work. I know i have used these keystroke entries in our apps on a unix server under a previous version and they work fine. I wonder if there would be some windows api calls i could use to turn off these editting keys.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Responding To Every Key Entered

I run the following code on xp, works fine. Very similar circumstances...I can't use w$getc because it blocks threads and other unpleasant things. Try dropping down to a 2 digit termination code. You have to type keystroke entries exactly right or they won't work.

Also, dont forget to push and pop your keyboard stack as appropriate. (call "C$KEYMAP" using "1".) You may have reached the limit of allowable entries (unlikely, but possible).

set environment "Keystroke" to "Terminate=54 kl".
set environment "Keystroke" to "Terminate=55 kr".
set environment "Keystroke" to "Terminate=13 ^M".

Merlin
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Responding To Every Key Entered

Hi MerlinM:

I had tried 2 digit with the same response. So I copied and pasted the actual lines from your post with the same results. The following is from an email that acu's support emailed me:

>
Our runtime does not capture all of Microsoft's keystrokes, that is why you can't just assign them a value with the keystroke variable and capture them that way. The reason for this is varied, some of the keys Microsoft doesn't make transparent for developers (you have to go through the Microsoft dll, or just aren't available, like the 'windows' key), and some of them haven't been of an interest to our customers and so haven't been included in the runtime's notice.

The keystrokes that you can capture through the runtime are listed in the User's Guide in the section on the Keyboard interface (section 4.3 I believe). If it is not on this list, then you have to use an outside source to capture the keystroke. Gisle demonstrated the method for doing this with the setnumlock program I sent. However, doing a complete keyboard key-capture would, I assume, take further work by someone like Gisle who is familiar with working with Microsoft's dlls and it's functions.
>

Just wondering if the application where this works for you is a gui application using the windows api or if it is more of a character based application. Also wondering what version of the runtime.
0 Likes
Highlighted
Absent Member.
Absent Member.

RE: [archive] Responding To Every Key Entered

I ran a little test and found out that you can set termination codes for left and right but they do not work for graphical accepts. If you do a vanilla character accept, (accept xyz on exception continue), the termination codes for left and right work ok. Otherwise (accept entry-field-based-screen on exception continue) they don't 😞

Try out the following program to see. uncomment the first accept and replace with the second one and see.


Merlin


WORKING-STORAGE SECTION.

01 Field1 pic x(10).
01 Field2 pic x(10).

01 CRT-STATUS IS SPECIAL-NAMES CRT STATUS PIC 9(3).
88 CRT-UP-KEY VALUE 52.
88 CRT-DOWN-KEY VALUE 53.
88 CRT-LEFT-KEY VALUE 54.
88 CRT-RIGHT-KEY VALUE 55.
88 CRT-ESC-KEY VALUE 27.

SCREEN SECTION.
01 Main-Screen.
05 entry-field using Field1.
05 entry-field using Field2 line + 1.

PROCEDURE DIVISION.

main.
set environment "Keystroke" to "Terminate=52 ku".
set environment "Keystroke" to "Terminate=53 kd".
set environment "Keystroke" to "Terminate=54 kl".
set environment "Keystroke" to "Terminate=55 kr".
display "ESC to EXIT" line 11 pos 32

perform Accept-Screen until CRT-ESC-KEY.

goback.

Accept-Screen.
display Main-Screen.
accept Main-Screen on exception continue.
|accept Field1 line 1 pos 20 on exception continue.

evaluate true
when CRT-UP-KEY display "UP " line 12 pos 39
when CRT-DOWN-KEY display "DOWN " line 12 pos 39
when CRT-LEFT-KEY display "LEFT " line 12 pos 39
when CRT-RIGHT-KEY display "RIGHT " line 12 pos 39
end-evaluate.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.