中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-18 16:23
47,814 topics / 349,908 posts / today 1 new / 48,259 members
DOS疑难解答 & 问题讨论 (解答室) » How to automatically turn on CapsLock in DOS
Printable Version  1,728 / 7
Floor1 hudisk Posted 2006-12-11 22:11
初级用户 Posts 13 Credits 34
How to automatically turn on Caps Lock in DOS? Num Lock can be configured in config.sys
Floor2 redtek Posted 2006-12-12 21:30
金牌会员 Posts 1,147 Credits 2,902
The following post has the tool you need (this tool is only a few KB in size), which is to turn on the caps lock state and turn off the caps lock state.

(The tool can be downloaded on the 9th floor of the following post)
(It also contains the source code)
(Tested under MS-DOS 6.22 version)

Turn on the caps lock key when starting
http://www.cn-dos.net/forum/viewthread.php?tid=23973&fpage=1&highlight=%E5%A4%A7%E5%86%99
Floor3 houfujin Posted 2006-12-29 11:12
新手上路 Posts 8 Credits 16
I wrote a program with QuickBASIC to control the on and off of the keyboard indicators.
Floor4 hebecoco Posted 2007-01-02 23:36
初级用户 Posts 25 Credits 63
40:17 byte Keyboard flag byte 0 (see KB FLAGS)
|7|6|5|4|3|2|1|0| keyboard flag byte 0
| | | | | | | `--- right shift key depressed
| | | | | | `---- left shift key depressed
| | | | | `----- CTRL key depressed
| | | | `------ ALT key depressed
| | | `------- scroll-lock is active
| | `-------- num-lock is active
| `--------- caps-lock is active
`---------- insert is active

You can just use pokeb(0x40,0x17,0x40)
Floor5 tantan2010 Posted 2007-01-05 10:38
新手上路 Posts 4 Credits 6
Floor6 lxmxn Posted 2007-01-06 13:46
版主 Posts 4,938 Credits 11,386
Originally posted by hebecoco at 2007-1-2 10:36:
40:17 byte Keyboard flag byte 0 (see KB FLAGS)
|7|6|5|4|3|2|1|0| keyboard flag byte 0
| | | | | | | `--- right shift key depressed
| | | | | | `---- left shift key depres ...


How to use this?
Floor7 redtek Posted 2007-01-06 22:52
金牌会员 Posts 1,147 Credits 2,902
At memory address 0040:0017, there is a byte that represents the current key state. This byte uses binary 1 or 0 to indicate the keyboard state.

0 means no on state, and 1 means on lock state.

If a key as shown in the information from Brother hebecoco on floor 4 is pressed, the shown address 0040:0017 will be rewritten by the interrupt routine to indicate the current key state.

Experiment:

Only the NumLock (numeric input state) light on the right small keyboard is on:
The 20H at memory address 0040:0017, converted to binary: 00100000
The 5th bit is 1 (true) indicating on, and the other bits are all 0.


-d 40:17
0040:0010 20-00 00 32 00 32 00 64 20
0040:0020 20 39 34 05 34 05 08 0E-30 0B 3A 27 31 02 37 08
0040:0030 0D 1C 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0040 AE 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 06 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 EC 71 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10

Then press the NumLock key on the right small keyboard again to turn off the numeric state (at this time the light is off)
00H in binary is: 00000000, all 0s, indicating not on.


-d 40:17
0040:0010 00-00 00 2E 00 2E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 37 08
0040:0030 0D 1C 61 1E 08 0E 64 20-20 39 33 04 30 0B 00 00
0040:0040 F2 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 10 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 A8 78 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10

Then press the CapsLock key on the left keyboard to start the uppercase state, then the following is 40H,
In binary: 01000000 The 6th bit is 1, indicating the uppercase on state.

-D 40:17
0040:0010 40-00 00 1E 00 1E 00 08 0E
0040:0020 08 0E 34 05 30 0B 3A 27-31 02 37 08 0D 1C 44 20
0040:0030 20 39 34 05 30 0B 3A 27-31 02 37 08 0D 1C 00 00
0040:0040 53 00 C3 00 00 00 00 00-00 03 50 00 40 1F 00 00
0040:0050 00 1A 00 00 00 00 00 00-00 00 00 00 00 00 00 00
0040:0060 07 06 00 D4 03 29 30 00-00 00 00 00 47 7E 08 00
0040:0070 00 00 00 00 00 00 08 00-14 14 14 14 01 01 01 01
0040:0080 1E 00 3E 00 31 08 00 60-F9 11 0B 00 50 01 00 00
0040:0090 00 00 00 00 00 00 10


So finally use Debug

E 40:17 40


(Invalid under Windows CMD, valid under MS-DOS)

This command can directly rewrite the keyboard representation state of the byte at memory address 0040:0017.
And set the keyboard to the uppercase lock state: the 6th bit of the binary is 1, indicating the on function, then 01000000 in hexadecimal (for easy reading) is 40, so fill 40 into that memory address~:)

Brother hebecoco on floor 4 gave "pokeb(0x40.0x17,0x40)" which is the operation method in high-level languages. According to Brother hebecoco's detailed explanation on floor 4, it can be completed in high-level languages like C that can write and operate memory~:)
Floor8 lxmxn Posted 2007-01-07 01:49
版主 Posts 4,938 Credits 11,386

  Powerful, learned it.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023