AHK,按住按鈕

AHK,按住按鈕

我希望這是提問的正確地方。我希望 LButton 在點擊時正常執行,但希望 RButton 在按住時按下。範例:我向 LButton 發送垃圾郵件並進行輕度攻擊,但按住 LBUtton 1 秒鐘將執行 RBUtton(重度攻擊)。我搜尋了論壇,但大多數有關按住的請求不符合我的意圖。

謝謝你! (抱歉,我懶得在所有 168 頁中搜尋合適的標籤)

答案1

我不是 100% 確定你在追求什麼,像這樣的東西怎麼樣? ...

#SingleInstance, Force
#NoEnv
#NoTrayIcon
#Persistent 

; tilde allows LButton to click as normal vs. this routine capturing the click
; i.e., LButton will always click once prior to RButton click getting sent 1 sec later
~LButton::      
    StartTick:=A_TickCount
    While GetKeyState("LButton", "P") && ((A_TickCount-StartTick)<1000)      ; 1000ms hold-down requirement
        Sleep 10

    If GetKeyState("LButton", "P")  ; If LButton is still down after loop exits, send RButton
        SendInput, {RButton}
Return

相關內容