intercept key press

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
tbrahmer
Newbie
Posts: 15
Joined: Thu May 06, 2010 10:14 pm

intercept key press

Post by tbrahmer » Fri Jun 25, 2010 7:08 pm

I've been playing around with the OnEvent>KEY_DOWN command. I have a question for the experts around here...

What I am trying to accomplish is this: I am filling in information on an Emulator screen connected to an AS400. I have an OnEvent>KEY_DOWN waiting for the Enter key to be pressed. The Enter key in the emulator program submits the screen information to the AS400 and updates, etc.

I am trying to see if there is a way to get the text on the screen when the 'Enter' key is pressed, but before the screen submits/changes. My event captures the key press, but my 'GetWindowTextEx' command is grabbing the text from the next screen (the screen displayed after enter is pressed).

I'm not sure if this is possible, but was wondering if there is a way to intercept that enter key being pressed, get the screen text, then send that enter key to the emulator program? Or another creative way?

Thanks for any help!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Mon Jun 28, 2010 9:49 am

Tricky. I think what I would do is get the text on the screen BEFORE the enter key is pressed. If that sounds odd consider a continuous loop that keeps grabbing the text from the screen UNTIL the enter key is pressed. The last capture is going to be the screen pretty much as it is at the point the Enter key was pressed.

If you try and capture the screen WHEN (after) the enter key is pressed you are likely to do it too late, and get the next screen.

Your success may depend on how quickly the screen refreshes after Enter is pressed and also how quickly the person can type and hit Enter.

Frankly, I would say it is impossible to ensure 100% accuracy here. Your solution is likely to get the next page while mine may miss some of the most recent updates especially if the user is fast. Experiment with the tightness of the loop.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

tbrahmer
Newbie
Posts: 15
Joined: Thu May 06, 2010 10:14 pm

Post by tbrahmer » Mon Jun 28, 2010 3:23 pm

Thanks Marcus - this morning I was able to get this working flawlessly by using a different route. This is a perfect example of using macros/scripting available in different applications to help get the desired end results with Macro Sheduler.

The emulator program supports its own macros - so I made one that fires every time you hit 'enter'. It copies the screen to the clipboard and then sends 'Enter' to the host. Works perfectly. Also did one that prints the screen to a file before sending 'Enter' to the host. Also works perfectly.

Now with my desired screen data in the clipboard or in a file, I am easily able to get what I need with macro scheduler.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts