Solved

MS-DOS hot keys

Posted on 2000-04-06
13
887 Views
Last Modified: 2008-03-10
What's the easiest way to create a hot key for use in MS-DOS 6.22?  We want to be able to launch an application from anywhere in DOS.
0
Comment
Question by:bmcbrett
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 63

Expert Comment

by:SysExpert
ID: 2689786
This could be tricky, depending on how the DOS app works.
If this is a pure DOS environment, then the best thing would be a TSR ( terminate and stay resident ) program.
DOS is NOT designed for multitasking, so unless the app you are calling is a TSR, the chances are you wil crash DOS.
The other option is to use a batch file.
Much easier, and will always work at a command prompt.
I hope this helps.
0
 
LVL 1

Expert Comment

by:jbeaman
ID: 2690704
I used to remap any of my keyboard keys (including the function keys) by loading ansi.sys in the config.sys file, and then including a call to a batch file in the autoexec.bat.  This way, you can have any key on the keyboard do anything you want it to, and all that is resident in memory is ansi.sys.  Let me know if you need further details, and I will dig out my notes.

jbeaman
0
 

Author Comment

by:bmcbrett
ID: 2691144
jbeaman,

Yes we would like more info.  Any thing you can provide would be of help - direct email is brett@bmccomputers.com - I will still give answer points on site
0
 
LVL 1

Expert Comment

by:jbeaman
ID: 2691608
First, put the following line in your config.sys:
device=c:\dos\ansi.sys

Then, put the following lines in your autoexec.bat file towards the end:
prompt $e[0;68;"dir";13p
prompt $p$g

What this does is remaps the F10 key (ASCII value 68) to the dos command "dir" followed by a RETURN (13p).  So after rebooting the computer with these lines in place, you can now get a directory by pressing the F10 key.  All standard keys are covered by any ASCII table, and you should be able to find it fairly easy.  If not let me know.  The ASCII values for the function keys are as follows:

F1-F10  59-68
F11  113
F12  134

SHIFT F1-F10  84-93
SHIFT F11  135
SHIFT F12  136

CTRL F1-F10  94-103
CTRL F11  137
CTRL F12  138

ALT F1-F10  104-113
ALT F11  139
ALT F12  140

Let me know if this makes sense, and what you are trying to do.  I could possibly create the code myselft if you don't want to mess with it.

jbeaman
0
 
LVL 22

Expert Comment

by:cookre
ID: 2691771
Here's a utility that will do just what you want:

http://oak.oakland.edu/simtel.net/msdos/keyboard/bmp-20.zip
0
 

Author Comment

by:bmcbrett
ID: 2693154
jbeaman,

We're trying to follow your example above, with the following replacements: we are replacing "dir" with "inv", which is a batch file that we created and would like to run from anywhere.  We are also relacing the 68 with 104, for ALT-F1.  So the entire string is

PROMPT $E[0;104;"inv";13p

This is not working.  Does there need to be an end bracket?  What does the zero represent?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:bmcbrett
ID: 2693304
jbeaman,

We're trying to follow your example above, with the following replacements: we are replacing "dir" with "inv", which is a batch file that we created and would like to run from anywhere.  We are also relacing the 68 with 104, for ALT-F1.  So the entire string is

PROMPT $E[0;104;"inv";13p

This is not working.  Does there need to be an end bracket?  What does the zero represent?
0
 

Author Comment

by:bmcbrett
ID: 2693408
jbeaman,

OK, we have figured out the end bracket and zero questions.  Let me give you some more info on what we are trying to do with this.  We have a menu program that we use for our business during the day.  What we are trying to do is create a hot key to access a program that is not in the menu program, and then have it return us to the menu program when exiting the other.  We can type the line in at the command prompt, and it will work, but only at the command prompt.  It will not work if loading it in the autoexec.bat file either.  Hope this helps.  
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 2693894
Your menu program nay be preventing the use of  batch files or recursive batch files. This is not an easy subject and is very dependent on what type of menu program you are using. It may be able to modify the menu system to do what you need, but you will need to have knowledge of the menu system itself.
I hope this helps.
0
 
LVL 1

Expert Comment

by:jbeaman
ID: 2693999
What is the name of the batch file, and where is it located?  If it is in a directory that is not in the path, you will have to specify the pathname.  You will also most likely have to include the keyword "Call" in the prompt statement.  So, the stuff in quotes should look something like this:  "Call c:\mydir\mysubdir\mybatfile.bat".  Try that and let me know what happens.

jbeaman
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 2694091
You may need to put an "exit" command at the exit points of the batch file, in order to make the call command work properly.
0
 
LVL 9

Accepted Solution

by:
cymbolic earned 50 total points
ID: 2694409
Most of the menu programs in DOS worked by being invoked from a batch file, which they then rewrote with a new next line indicating which program or batch file to run next to the DOS operating system.  Then, when the menu program exits to DOS, DOS itself rereads the batch file that started the menu program, and executes the next line in the batch file.  The batch file is also updated to rerun itself when the menu called program is run by DOS, because the next line reruns the inital batch file, and the cycle starts again.

If this is the case with your menu system, because of a limitation in DOS (it is not recursive on batch files), once you execute a second batch file from within one batch file, DOS no longer remembers the original batch file, UNLESS you execute the second batch file using a CALL *.BAT syntax on the command line in the original batch file.

Now, this only works IF your Menu program itself rewrites the controlling batch file, and then exits to DOS, so DOS can continuing running at the next line of the batch file.

Since you have said you want this to run from any DOS program (I am presuming you mean outside of the menu system as well), the suggested technique of using ANSI.SYS will not work, since it merely substitutes another command line character string for the function key, merely saving you keystrokes IF YOU ARE ALREADY AT A DOS PROMPT.

This is not what you asked for.  The correct answer is, unless your hotkey program is a tsr, you can't do what you want to do in DOS.  If you are interested, I have a menu system that provides for limited hotkeys, but these only work while in the menu system, they would not work while in the middle of another DOS program, under DOS only TSR's will perform like what you want.
0
 
LVL 22

Expert Comment

by:cookre
ID: 2694889
Aw shucks, cymbolic, ya spoiled the fun of watching their journey of discovery.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now