使用 AutoHotKey 切换 Ctrl 和 Alt 而不会弄乱 Alt-Tab 切换器?

dav*_*gan 8 keyboard-shortcuts autohotkey alt-tab windows-xp

我想在 Windows XP 中切换 Ctrl 和 Alt 键。我创建了一个包含以下内容的 AutoHotKey 脚本:

LAlt::LCtrl
RAlt::RCtrl

LCtrl::LAlt
RCtrl::RAlt
Run Code Online (Sandbox Code Playgroud)

这有效,但唯一的问题是 Alt-Tab 切换器卡住了。当我释放 Alt-Tab 时,窗口切换器会一直保持,直到我按下另一个键或单击鼠标。

有谁知道如何解决这个问题?

小智 5

这对我有用:

; First, swap LAlt and Ctrl
LAlt::Ctrl

; This reverts the Alt+Tab behavior
^Tab::
    Send, {LAlt Down}{Tab}
    ReleaseLAlt(10000)

; The purpose of this function is to release the LAlt key
; Without this, the LAlt key will be stuck
ReleaseLAlt(timeout := "")
{
    startTime := A_Tickcount

    while (isaKeyPhysicallyDown("LAlt"))
    {
        if (timeout && A_Tickcount - startTime >= timeout)
            Send, {LAlt Up} ; Took too long

        sleep, 50
    }

    Send, {LAlt Up}
} 

isaKeyPhysicallyDown(Keys)
{
  if isobject(Keys)
  {
    for Index, Key in Keys
      if getkeystate(Key, "P")
        return key  
  }
  else if getkeystate(Keys, "P")
    return Keys ;keys!
  return 0
}
Run Code Online (Sandbox Code Playgroud)


mem*_*ems 4

我想切换 Alt 和 Ctrl,因为我目前是 Window 上的 Mac 用户(使用 PC 键盘)。Mac 上的所有热键:Cmd+n、Cmd+w ... -> PC:Ctrl+n、Ctrl+w 和 Cmd 与 Alt 键位置相同。

我找到了一个不完美的解决方案:

映射所有这样的字母:

LAlt & a::Send {LCtrl Down}{a}{LCtrl Up}
...
LAlt & z::Send {LCtrl Down}{z}{LCtrl Up}
LCtrl & a::Send {LAlt Down}{a}{LAlt Up}
...
LCtrl & z::Send {LAlt Down}{z}{LAlt Up}
Run Code Online (Sandbox Code Playgroud)

并且您将保持 Alt+Tab 和 AltGr 功能

这是我的完整实现(不完整):http://www.pastie.org/1660132