【问题标题】:Can I make this AutoHotKey qwerty-half keyboard script work with caps-lock on?我可以让这个 AutoHotKey qwerty-half 键盘脚本在大写锁定的情况下工作吗?
【发布时间】:2017-05-24 22:42:24
【问题描述】:

我在https://autohotkey.com/board/topic/1257-half-qwerty-one-handed-typing/找到了这个脚本

此脚本的作用是将空格键重新映射为修饰符。当保持空间时,键盘是倒置的,g 和 h 之间的对称线。因此,e 会变成 i,b 会变成 n,p 会变成 q,以此类推。如果按下并释放空格键而不按任何其他键,则发送一个空格。诸如 shift 或 control 之类的修饰键可以与 Half-qwerty 结合使用。

问题是,当大写锁定打开时,它不适用于大写字母。

任何帮助都会很棒!

;QWERTY half-keyboard emulator

mirror_1 = 0
mirror_2 = 9
mirror_3 = 8
mirror_4 = 7
mirror_5 = 6
mirror_q = p
mirror_w = o
mirror_e = i
mirror_r = u
mirror_t = y
mirror_a = `;
mirror_s = l
mirror_d = k
mirror_f = j
mirror_g = h
mirror_z = /
mirror_x = .
mirror_c = ,
mirror_v = m
mirror_b = n
mirror_6 = 5
mirror_7 = 4
mirror_8 = 3
mirror_9 = 2
mirror_0 = 1
mirror_y = t
mirror_u = r
mirror_i = e
mirror_o = w
mirror_p = q
mirror_h = g
mirror_j = f
mirror_k = d
mirror_l = s
mirror_n = b
mirror_m = v


;This key may help, as the space-on-up may get annoying, especially if you type fast.
Control & Space::Suspend

;These keys are optional, but they may help if you are typing on the left-hand side.

CapsLock::Send, {BackSpace}
+Capslock::Capslock
;Capslock is backspace and Shift+Capslock works for Capslock.

Space & `::Send, {-}  

Space & CapsLock::Send, {Enter}

If spacebar didn't modify anything, send a real space keystroke upon release.
space::
Send {space}
return

space & 1::
space & 2::
space & 3::
space & 4::
space & 5::
space & q::
space & w::
space & e::
space & r::
space & t::
space & a::
space & s::
space & d::
space & f::
space & g::
space & z::
space & x::
space & c::
space & v::
space & b::
space & `;::
space & ,::
space & .::
space & /::
space & 6::
space & 7::
space & 8::
space & 9::
space & 0::
space & y::
space & u::
space & i::
space & o::
space & p::
space & h::
space & j::
space & k::
space & l::
space & n::
space & m::
;Determine the mirror key, if there is one:
if A_ThisHotkey = space & `;
   MirrorKey = a
else if A_ThisHotkey = space & ,
   MirrorKey = c
else if A_ThisHotkey = space & .
   MirrorKey = x
else if A_ThisHotkey = space & /
   MirrorKey = z
else  ; To avoid runtime errors due to invalid var names, do this part last.
{
   StringRight, ThisKey, A_ThisHotkey, 1
   StringTrimRight, MirrorKey, mirror_%ThisKey%, 0  ; Retrieve "array" element.
   if MirrorKey =  ; No mirror, script probably needs adjustment.
      return
}


Modifiers =
GetKeyState, state1, LWin
GetKeyState, state2, RWin
state = %state1%%state2%
if state <> UU  ; At least one Windows key is down.
   Modifiers = %Modifiers%#
GetKeyState, state1, Control
if state1 = D
   Modifiers = %Modifiers%^
GetKeyState, state1, Alt
if state1 = D
   Modifiers = %Modifiers%!
GetKeyState, state1, Shift
if state1 = D
   Modifiers = %Modifiers%+
Send %Modifiers%{%MirrorKey%}
return

注意 AutoHotKey 变量名不区分大小写。

【问题讨论】:

    标签: keyboard autohotkey


    【解决方案1】:
    ; Associative array that mirrors the left and right side of the keyboard.
    keyA    :=  {"1" : "0"
                ,"2" : "9"
                ,"3" : "8"
                ,"4" : "7"
                ,"5" : "6"
                ,"q" : "p"
                ,"w" : "o"
                ,"e" : "i"
                ,"r" : "u"
                ,"t" : "y"
                ,"a" : ";"
                ,"s" : "l"
                ,"d" : "k"
                ,"f" : "j"
                ,"g" : "h"
                ,"z" : "/"
                ,"x" : "."
                ,"c" : ","
                ,"v" : "m"
                ,"b" : "n"
                ,"0" : "1"
                ,"9" : "2"
                ,"8" : "3"
                ,"7" : "4"
                ,"6" : "5"
                ,"p" : "q"
                ,"o" : "w"
                ,"i" : "e"
                ,"u" : "r"
                ,"y" : "t"
                ,";" : "a"
                ,"l" : "s"
                ,"k" : "d"
                ,"j" : "f"
                ,"h" : "g"
                ,"/" : "z"
                ,"." : "x"
                ,"," : "c"
                ,"m" : "v"
                ,"n" : "b"}
    
    ; Make Hotkeys
    for index, value in keyA
        Hotkey, % "$*" index, FlipFlop, On
    return
    
    ; Disables space from being sent if it's held down for more than 300ms
    $*Space::
        KeyWait, Space, T0.3
        if (ErrorLevel = 1)
            KeyWait, Space
        Else
            Send, {Space}
    return
    
    ; Removes the hook and wildcard modifiers
    FlipFlop:
        StringReplace, hk, A_ThisHotkey, % "$*"
        ; If space is held
        if GetKeyState("Space", "P")
            ; Send the mirror of the keys along with any held modifiers
            Send, % "{Blind}" keyA[hk]
        Else
            ; Send the actual key pressed along with modifiers
            Send, % "{Blind}" hk
    return
    

    【讨论】:

      【解决方案2】:

      使用关联数组代替mirror_a 等,并包括大写字母。

      【讨论】:

        猜你喜欢
        • 2021-07-09
        • 2011-01-15
        • 2018-03-28
        • 1970-01-01
        • 2010-09-05
        • 2017-11-06
        • 1970-01-01
        • 2012-01-25
        • 1970-01-01
        相关资源
        最近更新 更多