您可以修复我的Ctrl + Left Ctrl + Shift + Left脚本吗?

时间:2018-11-12 09:07:29

标签: windows autohotkey auto

只是有点不像我想要的那样。它工作正常,但是如果我要按住功能,它将执行一次操作并添加数字,而不是重复执行该功能。我想要一些方法来加快Ctrl +向左键,Ctrl + Shift +向左键,Ctrl +向右键和Ctrl + Shift +向右键的处理,以便更快地处理文本。 https://www.youtube.com/watch?v=VNRCQx0eWA0 您可以在此处查看我所指的内容以及出了什么问题的示例。我已在视频标题中标记了错误。

script.ahk脚本内容

^1::
Send ^{Left Down}^{Left Down}
return
^2::
Send ^{Left Down}^{Left Down}^{Left Down}
return
^3::
Send ^{Left Down}^{Left Down}^{Left Down}^{Left Down}
return
^4::
Send ^{Left Down}^{Left Down}^{Left Down}^{Left Down}^{Left Down}
return
^5::
Send ^{Left Down}^{Left Down}^{Left Down}^{Left Down}^{Left Down}^{Left Down}
return
^6::
Send ^{Right Down}^{Right Down}
return
^7::
Send ^{Right Down}^{Right Down}^{Right Down}
return
^8::
Send ^{Right Down}^{Right Down}^{Right Down}^{Right Down}
return
^9::
Send ^{Right Down}^{Right Down}^{Right Down}^{Right Down}^{Right Down}
return
^0::
Send ^{Right Down}^{Right Down}^{Right Down}^{Right Down}^{Right Down}^{Right Down}
return
^+1::
Send ^+{Left Down}^+{Left Down}
return
^+2::
Send ^+{Left Down}^+{Left Down}^+{Left Down}
return
^+3::
Send ^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}
return
^+4::
Send ^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}
return
^+5::
Send ^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}^+{Left Down}
return
^+6::
Send ^+{Right Down}^+{Right Down}
return
^+7::
Send ^+{Right Down}^+{Right Down}^+{Right Down}
return
^+8::
Send ^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}
return
^+9::
Send ^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}
return
^+0::
Send ^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}^+{Right Down}
return
#q::exitApp

2 个答案:

答案 0 :(得分:1)

Keys := ["1","2","3","4","5","6","7","8","9","0"]
for each, key in Keys
{
    Hotkey, ^%key%, Ctrl_Key, On 
    Hotkey, ^+%key%, Ctrl_Key, On
}
return

Ctrl_Key:
    last_Key := ""
    Index := ""
    last_Key := SubStr(A_ThisHotkey, 0)
    If (last_Key = 0)
        Index = 5
    else
    If (last_Key < 6)
        Index := last_Key + 1
    else
        Index := last_Key - 4
    Loop %Index%
    {
        If (last_Key < 6) and (last_Key > 0)
        {
            If GetKeyState("Shift","P")
                Send +^{Left}
            else
                Send ^{Left}
        }
        else
        {
            If GetKeyState("Shift","P")
                Send +^{Right}
            else
                Send ^{Right}
        }
    }
    ; Don't repeat the action before key is released: 
    KeyWait, %last_Key%
return

请参阅文档中的For-LoopHotkeySubStr,并随时询问您是否不懂。

答案 1 :(得分:0)

从所有命令中删除down。正确的语法是:

^1::
    send ^{left}
return

要重复,您可以在方括号内写一个数字,例如重复选择5次:

^+5::
    send ^+{right 5}
return