windows 如何将 AltGr 键全局映射到 Alt 键?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/229633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:35:55  来源:igfitidea点击:

How to globally map AltGr key to Alt key?

windowskeyboard-shortcutsautohotkey

提问by Tomas Sedovic

I want my AltGrkey to behave exactly like left Alt.
Usually, I do this kind of stuff with Autohotkey, but I'm open to different solutions.

我希望我的AltGr钥匙的行为与 left 完全一样Alt
通常,我用Autohotkey做这种事情,但我对不同的解决方案开放态度。

I tried this:

我试过这个:

LControl & RAlt::Alt

And Autohotkey displayed error about Altnot being recognized action.
Then I tried the following code:

并且 Autohotkey 显示有关Alt未被识别操作的错误。
然后我尝试了以下代码:

LControl & RAlt::
  Send {Alt down}
  KeyWait LCtrl
  KeyWait Ralt
  Send {Alt up}
return

which sort of works - I'm able to use the AltGrkey for accessing hotkeys, but it still behaves differently:
When I press and release the left Alt, the first menu item in the current program receives focus.
Pressing and releasing AltGrwith this script does nothing.

哪种工作方式 - 我可以使用该AltGr键访问热键,但它的行为仍然不同:
当我按下并释放 left 时Alt,当前程序中的第一个菜单项获得焦点。用这个脚本
按下和释放AltGr什么都不做。

Any ideas? Is this even possible with Autohotkey? (remapping right Ctrland Shiftto their left siblings was piece of cake)

有任何想法吗?Autohotkey 甚至可以做到这一点吗?(重新映射右侧CtrlShift左侧的兄弟姐妹是小菜一碟)



注意:我尝试在代码中切换AltAltLAltLAlt,但没有任何区别。

回答by Tomas Sedovic

Thank you all for answers. I was unable to solve this using AutoHotkey -- PhilLho's answer was close, but I really needed exatly the same behaviour as with left Altkey.

谢谢大家的回答。我无法使用 AutoHotkey 解决这个问题——PhilLho 的回答很接近,但我真的需要与左键完全相同的行为Alt

However, the registry thingactually worked as I needed.

但是,注册表实际上按我的需要工作。

Save this as AltGR_to_LeftAlt.regfile and run it:

将其另存为AltGR_to_LeftAlt.reg文件并运行它:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,38,00,38,e0,00,00,00,00

Or, there is a GUI tool that does this for you -- it's called SharpKeysand works peachy:
SharpKeys in action

或者,有一个 GUI 工具可以为您执行此操作——它被称为SharpKeys并且工作正常:
SharpKeys 在行动

Oh, and don't forget to reboot or log off -- it won't work until then!

哦,别忘了重新启动或注销——在那之前它不会工作!

回答by Ronald Blaschke

As pointed out by PhiLho, Windows provides a way to remap any key, through the registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout. A basic overview can be found at Scan Code Mapper for Windows. A better description is probably Answers to Scancode Mapping or Changing Key Values.

正如 PhiLho 所指出的,Windows 提供了一种通过注册表项重新映射任何键的方法HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout。可以在适用于 Windows 的扫描代码映射器中找到基本概述。更好的描述可能是对扫描码映射或更改键值的回答

I'm using this approach to put the Windows Keyon the Caps Lock, because my keyboard doesn't have a Windows Keyand I don't need the Caps Lock.

我用这个方法把Windows KeyCaps Lock的,因为我的键盘没有Windows Key,我不需要Caps Lock

回答by PhiLho

I got a decent behavior by combining two hotkeys:

通过结合两个热键,我得到了一个不错的行为:

LControl & RAlt::Send {Alt}
RAlt::Alt

The first one is for the standalone keypress (avoid to hold it down...), the second one to be used as combination (Alt+F, etc.).
It isn't perfect, you can't do a combination like Ctrl+Alt+T, but perhaps it is enough for your needs.

第一个用于独立按键(避免按住...),第二个用作组合(Alt+F等)。
它不是完美的,你不能做这样的组合Ctrl+ Alt+ T,但也许这是足以让你的需求。

Note that you can do a permanent remapping using the registry. See this forum postfor an example. Not sure that it applies to compound keys like this one, but I thought I should mention it...

请注意,您可以使用注册表进行永久重新映射。有关示例,请参阅此论坛帖子。不确定它是否适用于这样的复合键,但我想我应该提到它......

回答by Dave James Miller

This worked for me:

这对我有用:

LControl & *RAlt::Send {LAlt Down}
LControl & *RAlt Up::Send {LAlt Up}

And this for mapping it to the Windows key:

这用于将其映射到 Windows 键:

LControl & *RAlt::Send {LWin Down}
LControl & *RAlt Up::Send {LWin Up}

Registry modification using SharpKeys (see above) is more reliable though (if you have administrator access).

使用 SharpKeys(见上文)修改注册表更可靠(如果您有管理员访问权限)。

回答by pbies

If you want to map this key globally and with no need to restart system for every change (but once), you may need to write a keyboard filter driver for this purpose. Look here.

如果你想全局映射这个键并且不需要为每次更改(但一次)重新启动系统,你可能需要为此编写一个键盘过滤器驱动程序。看这里

回答by Brian Schmitt

In AHK, Can you do:

在 AHK,你能做到:

LControl & RAlt::!

Or

或者

<^>!::!

回答by Ashish Porwal

Windows Registry Editor Version 5.00

Windows 注册表编辑器 5.00 版

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,38,00,38,e0,00,00,00,00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout] "扫描码图"=hex:00,00,00,00,00,00,00,00,02,00,00,00,38,00,38,e0 ,00,00,00,00

  1. Save the above code in reg file
  2. Merge it in registry
  3. restart your pc
  4. now check
  1. 将以上代码保存在reg文件中
  2. 将其合并到注册表中
  3. 重启你的电脑
  4. 现在检查