3

I am new to batch files and I need to write one for a program that runs in DOS. One of the questions on the prompt requires a function key command (i.e. F1, F2, etc).

I've read an article that says you cannot send function keys or alt+key combinations in DOS. Although I have also read an article that says the "Special Extended Code" for function keys are as follows:

F1: 0;59
F2: 0;60
etc...

So my question is, can you send function key commands to DOS? If so, what is the best way to do this?

Oliver Salzburg
  • 89,072
  • 65
  • 269
  • 311
megantb
  • 31

1 Answers1

1

Here's the example from your link

@ECHO OFF
REM     Reassign F1 to list current directory
REM     Reassign F10 to give DOS version

ECHO ←[0;59;"DIR/w/p";13p
ECHO ←[0;68;"VER";13p

REM     Now Put a menu on the Screen in Bright Yellow
CLS
ECHO ←[1;33m
ECHO ←[12;20HF1                   List Current directory
ECHO ←[14;20HF10                  Print DOS Version Number

REM     Reset display to normal
ECHO ←[0m

(note ← stands for the Escape character, entered using Ctrl+P then Esc inside the DOS EDIT command or Windows command-prompt EDIT command)

You asked

So my question is, can you send function key commands to DOS?

If the example works, yes you can. You may in fact be running Windows and not DOS, which may change things. Can you explain what happened when you tried the batch file above?

When you write "send function key commands" you might have something different in mind. If so it would be useful for you to explain what you want to achieve in a little more detail.

If so, what is the best way to do this?

I don't know, but the method in the article seems reasonable (if limited in applicability).