Autohotkey 宏:尝试将 left-alt 重新映射为 left-win;通过切换从左赢到左赢

发布于 2024-12-05 17:06:49 字数 896 浏览 0 评论 0原文

我正在尝试在 AutoHotKey 中将 Left Alt 重新映射到 Left Win,将 Left Win 重新映射到 Left Alt。

但我还希望使用 Shift + F11 来切换这两个重新映射。

我知道我能做到:

LAlt::LWin  
LWin::LAlt

但我不知道切换开关。以下版本失败:

Shift & F11::
Hotkey, LAlt, Toggle
Hotkey, LWin, Toggle
return

当我按 Shift 和 F11 时,它会说:

---------------------------
test.ahk
---------------------------
Error:  Nonexistent hotkey.  The current thread will exit.

Specifically: LAlt

    Line#
    001: Return
    002: SetKeyDelay,-1
    002: Send,{Blind}{LAlt DownTemp}
    002: Return
    002: SetKeyDelay,-1
    002: Send,{Blind}{LAlt Up}
    002: Return
--->    006: Hotkey,LAlt,Toggle
    007: Hotkey,LWin,Toggle
    008: Return
    009: Exit
    010: Exit
    010: Exit

---------------------------
OK   
---------------------------

我已经挠头好几个小时了..任何输入将不胜感激!

I am trying to remap Left Alt to Left Win and Left Win to Left Alt in AutoHotKey.

But I also want to have Shift + F11 to toggle these two remaps.

I know I can do:

LAlt::LWin  
LWin::LAlt

but what I can't figure out is the toggle. The following version fails:

Shift & F11::
Hotkey, LAlt, Toggle
Hotkey, LWin, Toggle
return

When I press Shift and F11, it will say:

---------------------------
test.ahk
---------------------------
Error:  Nonexistent hotkey.  The current thread will exit.

Specifically: LAlt

    Line#
    001: Return
    002: SetKeyDelay,-1
    002: Send,{Blind}{LAlt DownTemp}
    002: Return
    002: SetKeyDelay,-1
    002: Send,{Blind}{LAlt Up}
    002: Return
--->    006: Hotkey,LAlt,Toggle
    007: Hotkey,LWin,Toggle
    008: Return
    009: Exit
    010: Exit
    010: Exit

---------------------------
OK   
---------------------------

I've been scratching my head for hours.. Any input will be greatly appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嘿嘿嘿 2024-12-12 17:06:49

我确信它比必要的更详细,但我刚刚尝试过这个脚本,它的作用类似于您所追求的。如果没有别的的话,它可能会让你朝着正确的方向前进。

#NoEnv
SendMode Input

IsRemapEnabled := false
SetRemapEnabled(false)

SetRemapEnabled(toEnabled) 
{
  global IsRemapEnabled := toEnabled
}

+F11::
  SetRemapEnabled(!IsRemapEnabled)
return

LAlt::
  if (IsRemapEnabled) 
  {
    Send,{LWin DOWN}
  } else 
  {
    Send,{LAlt DOWN}
  } 
return

LAlt up::

  if (IsRemapEnabled) 
  {
    Send,{LWin UP}
  } else 
  {
    Send,{LAlt UP}
  } 
return

LWin::
  if (IsRemapEnabled) 
  {
    Send,{LAlt DOWN}
  } else 
  {
    Send,{LWin DOWN}
  } 
return

LWin UP::
  if (IsRemapEnabled) 
  {
    Send,{LAlt UP}
  } else 
  {
    Send,{LWin UP}
  } 
return

I'm sure it is more verbose than necessary, but I just tried this script and it does something like what you're after. It might send you in the right direction, if nothing else.

#NoEnv
SendMode Input

IsRemapEnabled := false
SetRemapEnabled(false)

SetRemapEnabled(toEnabled) 
{
  global IsRemapEnabled := toEnabled
}

+F11::
  SetRemapEnabled(!IsRemapEnabled)
return

LAlt::
  if (IsRemapEnabled) 
  {
    Send,{LWin DOWN}
  } else 
  {
    Send,{LAlt DOWN}
  } 
return

LAlt up::

  if (IsRemapEnabled) 
  {
    Send,{LWin UP}
  } else 
  {
    Send,{LAlt UP}
  } 
return

LWin::
  if (IsRemapEnabled) 
  {
    Send,{LAlt DOWN}
  } else 
  {
    Send,{LWin DOWN}
  } 
return

LWin UP::
  if (IsRemapEnabled) 
  {
    Send,{LAlt UP}
  } else 
  {
    Send,{LWin UP}
  } 
return
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文