【问题标题】:Replace Left and Right Click for Alt+1 and Alt+2 (Autohotkey)替换 Alt+1 和 Alt+2 的左右单击(自动热键)
【发布时间】:2015-12-06 22:03:23
【问题描述】:

我想在按住 Alt 键 + 1 时发送单击,然后仍然按住 alt 键发送右键单击当按下 2

我的代码

!q::

Send {LButton Down}

KeyWait q

Send {LButton Up}

Return

!w::

Send {RButton Down}

KeyWait w

Send {RButton Up}

Return

这个想法是始终按下 ALT 键,

示例:

!:: { q::
Send {LButton Down}

KeyWait q 

Send {LButton Up}

w:: 

Send {RButton Down} 

KeyWait w 

Send {RButton Up} 

KeyWait ! 

Return 

}

请帮帮我

【问题讨论】:

  • 第二个代码不起作用
  • 为什么不用 Alt+1 “启动”脚本,做你的事情,然后等待“只是”2(不是 Alt+2)继续脚本。您可以测试下一个输入,如果它不是数字(即您开始做其他事情),请跳出脚本。或者,如果您想使用 Alt+2,您可以先测试 Alt(Down)的键状态。

标签: keyboard keyboard-shortcuts autohotkey


【解决方案1】:

这就是你要找的吗?

!1::Click

!2::Click Right

【讨论】:

  • 不错,但按住点击?并且 [按住 alt] + [1] (发送点击)并仍然按住 alt,按 2 发送点击右 :( 可能是不可能的
【解决方案2】:

我测试了一些代码,得出了这个结论。
你应该避免使用alt键原因(你可以测试它)它会导致右键菜单消失(在没有运行任何ahk应用程序的情况下右键单击桌面。然后按alt,你会看到菜单消失。)
所以在这里我使用 Ctrl 键。

您唯一需要添加的是$ 前缀。下同:

$^1::
    send, {lbutton down}
    keywait, 1
    send, {lbutton up}
return

$^2::
    send, {rbutton down}
    keywait, 2
    send, {rbutton up}
return

它带有Ctrl 键,您不能使用Alt 键,因为它会禁用飞出菜单。您可以使用! alt 键代替 ctrl 键,但您必须先释放 alt 然后释放 2 以防止该菜单消失。

我认为你想要的是这样的。我弄清楚为什么它会重复发送并处理它。但它也不起作用。也许 alt 键正在自动发送(我的意思自然是它的行为是这样的)。

$ALT::
    send, {alt down}
    keywait, ALT
return

$ALT UP::
    send, {alt up}
return

$!1::
    send, {lbutton down}
    keywait, 1
    send, {lbutton up}
return

$!2::
    send, {rbutton down}
    keywait, 2
    send, {rbutton up}
return

另一种解决方案是使用键代替修饰符:

$1::
    if GetKeyState("z", "p") {
        send, {lbutton down}
        keywait, 1
        send, {lbutton up}
    }
    else {
        SetKeyDelay, -1
        Send {Blind}{1 DownTemp}
    }
return

$1 up::
    SetKeyDelay, -1
    Send {Blind}{1 Up}
return

$2::
    if GetKeyState("z", "p") {
        send, {rbutton down}
        keywait, 2
        send, {rbutton up}
    }
    else {
        SetKeyDelay, -1
        Send {Blind}{2 DownTemp}
    }
return

$2 up::
    SetKeyDelay, -1
    Send {Blind}{2 Up}
return

您可以使用任何键来代替"z"z 就像 alt 键。

【讨论】:

  • 非常感谢,第一个代码完美运行,如果将“^”替换为“!”不行,第二个代码出现上下文菜单有问题
  • @dcaro 您更喜欢哪个键来代替 alt?
  • 我现在将您的脚本与 Win 键一起使用,我更喜欢按位置或 Ctrl Right 的 Win 键
  • @dcaro 我添加了一个新的解决方案。您可以使用alt 上方的键(这里是z,实际上是在我的键盘中),因为它是alt 键。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-06
  • 2019-08-07
相关资源
最近更新 更多