Solved

MS-DOS hot keys

Posted on 2000-04-06
13
885 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Just about everyone has an old PC laying around.  Ask anyone in the IT industry, whether they are a professional or play in it as a hobby.  From outdated Desktops to cheap "throwaway" laptops, they are all around and not as hard to "fix up" as you m…
As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

12 Experts available now in Live!

Get 1:1 Help Now