【问题标题】:autohotkey: simulate mouse press and holdautohotkey:模拟鼠标按住
【发布时间】:2019-12-07 11:19:16
【问题描述】:

使用自动热键,我正在尝试做:

  • 按住 LCtrl 和 LShift 的行为类似于按住 RCtrl + 鼠标左键
  • 释放 LCtrl 和 LShift 的行为就像释放 RCtrl + 鼠标左键

理想情况下,按键的顺序无关紧要。

我现在拥有的是:

LCtrl & LShift::
   If (A_PriorHotKey = A_ThisHotKey) ;these are built in variables
   return
   Send {RCtrl Down}
   MouseClick, left,,, 1, 0, D  ; Hold down the left mouse button.
return

LCtrl & LShift Up::
  Send {RCtrl Up}
  MouseClick, left,,, 1, 0, U  ; Release the mouse button.
return

虽然按下 ^LShift 确实模拟了按下 RCtrl 和左键单击,但释放 ^LShift大多数时没有任何作用。通常,即使我释放它们,RCtrl + 左键单击仍然被“按下”,我必须手动按下它们才能(激活和)停用它们。

【问题讨论】:

    标签: windows autohotkey


    【解决方案1】:

    试试这个

    LCtrl & LShift::
       Send {RCtrl Down}
       MouseClick, left,,, 1, 0, D  ; Hold down the left mouse button.   
       KeyWait, LCtrl               ; Wait for LCtrl to be released 
       Send {RCtrl Up}
       MouseClick, left,,, 1, 0, U  ; Release the mouse button.
    return
    

    编辑:

    要使其无论按什么顺序都可以正常工作,请尝试以下操作:

    LCtrl & LShift::
    LShift & LCtrl::
       Send {Blind}{Shift Up}
       Send {RCtrl Down}
       MouseClick, left,,, 1, 0, D  ; Hold down the left mouse button.   
       KeyWait, LCtrl               ; Wait for LCtrl to be released 
       Send {RCtrl Up}
       MouseClick, left,,, 1, 0, U  ; Release the mouse button.
    return
    

    【讨论】:

    • 这很好用。知道为什么我以前的脚本不起作用吗?
    • 另外,无论我按按键的顺序如何,我都可以让它工作吗?目前它只有在我先按 LCtrl 然后按 LShift 时才有效。
    • 尝试编辑后的答案。您之前的脚本不起作用,因为在释放 LShift 时仍按下 LCtrl。
    猜你喜欢
    • 2010-12-31
    • 2013-06-07
    • 2018-03-30
    • 2019-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多