当键盘布局随 MSKLC 更改时,键盘快捷键无效

当键盘布局随 MSKLC 更改时,键盘快捷键无效

在 Windows 10 中,我使用Microsoft 键盘布局创建器改变我的键盘布局,这样一半的键都会改变位置。

但是现在,我软件中的所有键盘快捷键都不起作用。例如,现在在键所在的位置P,有O。在 Eclipse 中,当我按 Ctrl+O 打开方法时,Eclipse 认为我按的是 Ctrl+P,因此它会提示我打印对话框。

我在 MS 网站上读到过这样的内容:

https://msdn.microsoft.com/en-us/library/windows/desktop/gg153546(v=vs.85).aspx

另外,避免使用 WM_CHAR 来实现键盘快捷键。相反,使用 WM_KEYDOWN 消息;或者更好的方法是使用加速器表。加速器表将在下一主题“加速器表”中描述。

因此,当我更改键盘布局时,我会更改每个键的字符,但我不会更改虚拟键代码,所以这很混乱。IME(输入法)也是如此,例如 Microsoft Pinyin。现在,使用新的键盘布局,我无法使用 转到下一页,,也无法使用 转到上一页.

现在它变得可以理解,但仍然不合理。

我认为一定有一个解决方案,因为我认为我和任何想要使用 Dvorak 或 AZERTY 或任何其他键盘布局的用户面临同样的问题。

我们怎样才能解决这个问题?

答案1

我在这里发现了另一个非常相关的问题:

如何在 Microsoft 键盘布局创建器中恢复 Ctrl+<key> 功能?

,其中有一个完美的答案。我将尝试详细阐述它,并将其作为副本放在这里。

答案提到通过.klc直接在文本编辑器中编辑文件来更改每个键的 VK 代码,这是我从未想过的,很棒的设计。它还包含一个博客链接,展示了如何做到这一点:

www.sensefulsolutions.com/2010/08/how-to-fix-keyboard-shortcuts-in-klc-eg.html

所以我们这样说吧:

Windows 中每个应用程序中的快捷键并非直接绑定到每个键的字符输出。它们绑定到每个键的虚拟键码。键的扫描码是特定于硬件的。驱动程序将这些代码转换为虚拟键码,然后操作系统接收 VK 代码来执行任务。

当我们在 MSKLC 中编辑键盘布局时,VK 代码默认不会更改。但您可以打开文件.klc进行编辑。

典型的.klc文件如下:

KBD WT_VK_CN    "WindThunder VK code changed - Simplified Chinese"

COPYRIGHT   "(c) 2017 WindThunder Studio"

COMPANY "WindThunder Studio"

LOCALENAME  "zh-CN"

LOCALEID    "00000804"

VERSION 1.0

SHIFTSTATE

0   //Column 4
1   //Column 5 : Shft
2   //Column 6 :       Ctrl
6   //Column 7 :       Ctrl Alt
7   //Column 8 : Shft  Ctrl Alt

LAYOUT      ;an extra '@' at the end is a dead key

//SC    VK_     Cap   0     1        2   6       7
//----------------------------------------------------------------------------------------------------------------------------

02  1           1   007b    1       -1  -1      -1      // LEFT CURLY BRACKET, DIGIT ONE, <none>, <none>, <none>
03  2           1   005b    2       -1  00b7    -1      // LEFT SQUARE BRACKET, DIGIT TWO, <none>, MIDDLE DOT, <none>
04  3           1   0028    3       -1  20ac    -1      // LEFT PARENTHESIS, DIGIT THREE, <none>, EURO SIGN, <none>
05  4           1   003c    4       -1  -1      -1      // LESS-THAN SIGN, DIGIT FOUR, <none>, <none>, <none>
06  5           1   002f    5       -1  -1      -1      // SOLIDUS, DIGIT FIVE, <none>, <none>, <none>
07  OEM_7       0   0027    0022    -1  00a8@   -1      // APOSTROPHE, QUOTATION MARK, <none>, DIAERESIS, <none>
08  6           1   005c    6       -1  00ac    -1      // REVERSE SOLIDUS, DIGIT SIX, <none>, NOT SIGN, <none>
09  7           1   003e    7       -1  -1      -1      // GREATER-THAN SIGN, DIGIT SEVEN, <none>, <none>, <none>
0a  8           1   0029    8       -1  -1      -1      // RIGHT PARENTHESIS, DIGIT EIGHT, <none>, <none>, <none>
0b  9           1   005d    9       -1  -1      -1      // RIGHT SQUARE BRACKET, DIGIT NINE, <none>, <none>, <none>
0c  0           1   007d    0       -1  00a1    -1      // RIGHT CURLY BRACKET, DIGIT ZERO, <none>, INVERTED EXCLAMATION MARK, <none>
0d  OEM_PLUS    0   003d    002b    -1  00bf    -1      // EQUALS SIGN, PLUS SIGN, <none>, INVERTED QUESTION MARK, <none>
10  Q           1   q       Q       -1  -1      -1      // LATIN SMALL LETTER Q, LATIN CAPITAL LETTER Q, <none>, <none>, <none>
11  W           1   w       W       -1  -1      -1      // LATIN SMALL LETTER W, LATIN CAPITAL LETTER W, <none>, <none>, <none>
12  E           1   e       E       -1  -1      -1      // LATIN SMALL LETTER E, LATIN CAPITAL LETTER E, <none>, <none>, <none>
13  R           1   r       R       -1  -1      -1      // LATIN SMALL LETTER R, LATIN CAPITAL LETTER R, <none>, <none>, <none>
14  T           1   t       T       -1  -1      -1      // LATIN SMALL LETTER T, LATIN CAPITAL LETTER T, <none>, <none>, <none>
15  OEM_6       0   0060    005e    -1  00b4@   -1      // GRAVE ACCENT, CIRCUMFLEX ACCENT, <none>, ACUTE ACCENT, <none>
16  Y           1   y       Y       -1  -1      -1      // LATIN SMALL LETTER Y, LATIN CAPITAL LETTER Y, <none>, <none>, <none>
17  U           1   u       U       -1  -1      -1      // LATIN SMALL LETTER U, LATIN CAPITAL LETTER U, <none>, <none>, <none>
18  I           1   i       I       -1  -1      -1      // LATIN SMALL LETTER I, LATIN CAPITAL LETTER I, <none>, <none>, <none>
19  O           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>
1a  P           1   p       P       -1  -1      -1      // LATIN SMALL LETTER P, LATIN CAPITAL LETTER P, <none>, <none>, <none>
1b  OEM_MINUS   0   0025    0040    -1  -1      -1      // PERCENT SIGN, COMMERCIAL AT, <none>, <none>, <none>
1e  A           1   a       A       -1  -1      -1      // LATIN SMALL LETTER A, LATIN CAPITAL LETTER A, <none>, <none>, <none>
1f  S           1   s       S       -1  -1      -1      // LATIN SMALL LETTER S, LATIN CAPITAL LETTER S, <none>, <none>, <none>
20  D           1   d       D       -1  -1      -1      // LATIN SMALL LETTER D, LATIN CAPITAL LETTER D, <none>, <none>, <none>
21  F           1   f       F       -1  -1      -1      // LATIN SMALL LETTER F, LATIN CAPITAL LETTER F, <none>, <none>, <none>
22  G           1   g       G       -1  -1      -1      // LATIN SMALL LETTER G, LATIN CAPITAL LETTER G, <none>, <none>, <none>
23  OEM_4       0   002d    005f    -1  -1      -1      // HYPHEN-MINUS, LOW LINE, <none>, <none>, <none>
24  H           1   h       H       -1  -1      -1      // LATIN SMALL LETTER H, LATIN CAPITAL LETTER H, <none>, <none>, <none>
25  J           1   j       J       -1  -1      -1      // LATIN SMALL LETTER J, LATIN CAPITAL LETTER J, <none>, <none>, <none>
26  K           1   k       K       -1  -1      -1      // LATIN SMALL LETTER K, LATIN CAPITAL LETTER K, <none>, <none>, <none>
27  L           1   l       L       -1  -1      -1      // LATIN SMALL LETTER L, LATIN CAPITAL LETTER L, <none>, <none>, <none>
28  OEM_1       4   003b    003a    -1  00f1    00d1    // SEMICOLON, COLON, <none>, LATIN SMALL LETTER N WITH TILDE, LATIN CAPITAL LETTER N WITH TILDE
29  OEM_2       0   003f    0021    -1  00ba    00aa    // QUESTION MARK, EXCLAMATION MARK, <none>, MASCULINE ORDINAL INDICATOR, FEMININE ORDINAL INDICATOR
2b  OEM_5       4   007c    0024    -1  00e7    00c7    // VERTICAL LINE, DOLLAR SIGN, <none>, LATIN SMALL LETTER C WITH CEDILLA, LATIN CAPITAL LETTER C WITH CEDILLA
2c  Z           1   z       Z       -1  -1      -1      // LATIN SMALL LETTER Z, LATIN CAPITAL LETTER Z, <none>, <none>, <none>
2d  X           1   x       X       -1  -1      -1      // LATIN SMALL LETTER X, LATIN CAPITAL LETTER X, <none>, <none>, <none>
2e  C           1   c       C       -1  -1      -1      // LATIN SMALL LETTER C, LATIN CAPITAL LETTER C, <none>, <none>, <none>
2f  V           1   v       V       -1  -1      -1      // LATIN SMALL LETTER V, LATIN CAPITAL LETTER V, <none>, <none>, <none>
30  B           1   b       B       -1  -1      -1      // LATIN SMALL LETTER B, LATIN CAPITAL LETTER B, <none>, <none>, <none>
31  OEM_3       0   007e    0026    -1  -1      -1      // TILDE, AMPERSAND, <none>, <none>, <none>
32  N           1   n       N       -1  -1      -1      // LATIN SMALL LETTER N, LATIN CAPITAL LETTER N, <none>, <none>, <none>
33  M           1   m       M       -1  -1      -1      // LATIN SMALL LETTER M, LATIN CAPITAL LETTER M, <none>, <none>, <none>
34  OEM_COMMA   0   002c    0023    -1  -1      -1      // COMMA, NUMBER SIGN, <none>, <none>, <none>
35  OEM_PERIOD  0   002e    002a    -1  -1      -1      // FULL STOP, ASTERISK, <none>, <none>, <none>
39  SPACE       0   0020    0020    -1  -1      -1      // SPACE, SPACE, <none>, <none>, <none>
53  DECIMAL     0   002e    002e    -1  -1      -1      // FULL STOP, FULL STOP, , , 


DEADKEY 00a8

0061    00e4    // a -> ä
0065    00eb    // e -> ë
0069    00ef    // i -> ï
006f    00f6    // o -> ö
0075    00fc    // u -> ü
0041    00c4    // A -> Ä
0045    00cb    // E -> Ë
0049    00cf    // I -> Ï
004f    00d6    // O -> Ö
0055    00dc    // U -> Ü
0079    00ff    // y -> ÿ
0020    00a8    //   -> ¨

DEADKEY 00b4

0061    00e1    // a -> á
0065    00e9    // e -> é
0069    00ed    // i -> í
006f    00f3    // o -> ó
0075    00fa    // u -> ú
0079    00fd    // y -> ý
0041    00c1    // A -> Á
0045    00c9    // E -> É
0049    00cd    // I -> Í
004f    00d3    // O -> Ó
0055    00da    // U -> Ú
0059    00dd    // Y -> Ý
0020    00b4    //   -> ´


KEYNAME

01  Esc
0e  Backspace
0f  Tab
1c  Enter
1d  Ctrl
2a  Shift
36  "Right Shift"
37  "Num *"
38  Alt
39  Space
3a  "Caps Lock"
3b  F1
3c  F2
3d  F3
3e  F4
3f  F5
40  F6
41  F7
42  F8
43  F9
44  F10
45  Pause
46  "Scroll Lock"
47  "Num 7"
48  "Num 8"
49  "Num 9"
4a  "Num -"
4b  "Num 4"
4c  "Num 5"
4d  "Num 6"
4e  "Num +"
4f  "Num 1"
50  "Num 2"
51  "Num 3"
52  "Num 0"
53  "Num Del"
54  "Sys Req"
57  F11
58  F12
7c  F13
7d  F14
7e  F15
7f  F16
80  F17
81  F18
82  F19
83  F20
84  F21
85  F22
86  F23
87  F24

KEYNAME_EXT

1c  "Num Enter"
1d  "Right Ctrl"
35  "Num /"
37  "Prnt Scrn"
38  "Right Alt"
45  "Num Lock"
46  Break
47  Home
48  Up
49  "Page Up"
4b  Left
4d  Right
4f  End
50  Down
51  "Page Down"
52  Insert
53  Delete
54  <00>
56  Help
5b  "Left Windows"
5c  "Right Windows"
5d  Application

KEYNAME_DEAD

00a8    "DIAERESIS"
00b4    "ACUTE ACCENT"


DESCRIPTIONS

0409    WindThunder VK code changed - Simplified Chinese

LANGUAGENAMES

0409    Chinese (People's Republic of China)

ENDKBD

参见包含 的行下方layout。您说的是一张表格,其中包含按键及其 VK 代码的映射行以及按下它们时获得的字符输出。我们想要做的是更改第二列,VK_以使其适应字符,或根据需要更改它们。验证错误(如果有)将在稍后显示,因此不要担心犯错。

在此更改版本之前,此行:

19  O           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>

曾是:

19  P           1   o       O       -1  -1      -1      // LATIN SMALL LETTER O, LATIN CAPITAL LETTER O, <none>, <none>, <none>

因此,在我的布局中的 位置O,它被解释为VK_P,这就是我得到打印提示的原因。

完整值列表VK_如下:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

相关内容