WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Sending Keystrokes

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

SendKey to DOS App - Simple Script

Keywords:   sendkeysto DOS apps 

Here's a simple example of how to send keystrokes to a DOS application. For newer versions of WinBatch, make sure to use the SendkeysTo function, in which you specify the title of the DOS application to which you want to send keystrokes, and which will also activate the DOS window.
        Run("Command.com", "")
        ClipPut(StrCat("exit", Num2char(13)))
        WinActivate("COMM")
        SendKey("!{sp}EP")

Sending Keystrokes to DOS App - Discussion

Q:


I am Sending Keys to a DOS program. I don't know what it's doing.

Here's the command:
WinActivate(win) 
SendKeysTo(win,"^{end}RESIDENT~^{end}") 

What it does:
Sometimes it works perfectly.
Sometimes it types ESIDENT, losing the first letter.
Sometimes it types rESIDENT.


I can't seem to figure out why it works sometimes and sometimes doesn't. I'm guessing something with the
Ctrl-End combo. Please don't tell me it can't do that... I'll cry.


A: Winbatch sends "blind" to DOS windows. So you have to baby it. Try... WinActivate(win) TimeDelay(1) SendKey("^{end}") TimeDelay(1) SendKey("RESIDENT~") SendKey("^{end}") And see is that helps. Also try adding IntControl(35,200,0,0,0) to the top of the script.
Q: Hmmmm... still not working... next idea? Here's the script as I have it right now. IntControl(35,250,0,0,0) WinActivate(win) SendKeysTo(win,"SGP~O") SendKeysTo(win,"{enter 3}YN4N") SendKeysTo(win,"^{end}") TimeDelay(1) SendKeysTo(win,"RESIDENT~") TimeDelay(1) SendKeysTo(win,"^{end}") TimeDelay(1) SendKeysTo(win,"FILE~") TimeDelay(1) SendKeysTo(win,"^{end}") TimeDelay(1) SendKeysTo(win,"HOME OFFICE~") TimeDelay(1) SendKeysTo(win,"^{end}") TimeDelay(1) SendKeysTo(win,"{f10}") SendKeysTo(win,"{esc 4}ye")
A: Tbe SendKeysTo causes a lot of extra for for the poor dos window. Try.. IntControl(35,250,0,0,0) WinActivate(win) SendKey("SGP~O") SendKey("{enter 3}YN4N") SendKey("^{end}") TimeDelay(1) SendKey("RESIDENT~") TimeDelay(1) SendKey("^{end}") TimeDelay(1) SendKey("FILE~") TimeDelay(1) SendKey("^{end}") TimeDelay(1) SendKey("HOME OFFICE~") TimeDelay(1) SendKey("^{end}") TimeDelay(1) SendKey("{f10}") SendKey("{esc 4}ye")
Q: Still doesn't work... sometimes. I have a work around within the DOS program I am using. I am not using the !{end} or the ~ at all. I just fill up the field with spaces. It takes a little longer, but it works. Any other ideas? Thanks.
A: Another thing to consider when sending keystrokes to DOS boxes is to make sure the DOS box runs in a "window" (opposed to full screen). This is especially important for Win95/98 boxes. NT handles DOS boxes a bit better. Create or change the pif file for the DOS exe/bat to run. You can route normal ascii characters and the enter key via the clipboard. Try stuff like... stuff=strcat("SGP",@cr,"O",@cr,@cr,@cr,"YN4N",@cr,"RESIDENT",@cr) clipput(Stuff) SendKey("! ep")

Article ID:   W13828
Filename:   Send Keys to DOS Apps Considerations.txt
File Created: 2001:01:05:13:23:00
Last Updated: 2001:01:05:13:23:00