2013-03-18 331 views
1

有人可以幫助我使用AutoHotKey宏,當按下鼠標右鍵並按下Q按鈕並釋放鼠標右鍵時,Q按鈕被按下並釋放?AutoHotKey點擊鼠標右鍵也可以獲得一個鍵盤按鈕

編輯:
解釋,想象一下,我正在玩一個遊戲,當我點擊鼠標右鍵按下(然後我拿着它),我需要Q鍵自動按下鍵盤,所以我會得到一個當時在遊戲中跳躍(或蹲伏),當我釋放鼠標右鍵(鼠標按鈕)時,我會再次按下Q自動按鈕。 我正在嘗試寫腳本,我無法使它工作。

這是我想出了迄今:

RButton:: 
    If !Toggler { 
    Send, {RButton Down} q 
    Return 
    } 
    Send {RButton Up} q 
    Return 
+0

你能嘗試重寫你的問題,因爲它不是很清楚你想要的! Q按鈕意味着什麼?這是一個帶Q的軟件按鈕嗎?或者你的意思是Q鍵? – 2013-03-18 10:01:49

+0

我加了一些解釋 – CamSpy 2013-03-18 12:42:00

回答

2

確定它看起來像要切換行爲。

#SingleInstance Force 
#installKeybdHook 
#Persistent 
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible 

#IfWinActive, Title of your game as found by AHK Windows Spy 
    RButton:: 
     If (Toggler := !Toggler) 
     { 
      ToolTip, RButton Down 
      Send, {RButton Down} q 
      Return 
     } 
     ToolTip, RButton Up   
     Send {RButton Up} q 
    Return 
#IfWinActive 
Return 

*x:: 
ExitApp 

更新

讀你的文字(和忽略要切換行爲腳本)後,我認爲,你想要這個! RightClick將發送RightClick Down + q,然後一無所獲,直到你放開RightClick,然後發送RightClick Up + q。我添加了工具提示,所以你可以看到腳本是否被#IfWinActive正確激活。

#SingleInstance Force 
#installKeybdHook 
#Persistent 
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible 

#IfWinActive, Title of your game as found by AHK Windows Spy 

RButton:: 
    ToolTip, RButton Down + q 
    Send, {RButton Down} q 
Return 

RButton Up:: 
    ToolTip, RButton Up + q 
    Send, {RButton Up} q 
Return 

#IfWinActive 
Return 

*x:: 
ExitApp 

如果這確實是你想要的,那麼最終的解決方案將非常接近Armin的原始提示!

更新2,替代方式

#SingleInstance Force 
#installKeybdHook 
#Persistent 
SetTitleMatchMode, 2 ; Make search title in #IfWinActive more flexible 

#IfWinActive, Title of your game as found by AHK Windows Spy 
    *~RButton:: ; ~ passes Rbutton through 
     ToolTip, RButton Down + q 
     Send, q 
     KeyWait, RButton ; Wait for RButton to be released 
     ToolTip, RButton Up + q 
     Send, q 
    Return 
#IfWinActive 
Return 

*x:: 
ExitApp 
+0

謝謝,我會盡快回家。順便說一句,應該添加什麼,所以這個腳本只會在特定的遊戲中有效,所以我可以添加文件路徑或其他東西? – CamSpy 2013-03-18 14:26:04

+0

是的,更新後的腳本看起來更正確。我會嘗試一下並告知它是如何發生的。再次感謝 – CamSpy 2013-03-18 14:57:42

+0

我現在使用腳本的第二個變體,而一切按預期工作,有一個不愉快的事情 - 有時一個白色的小白色矩形,黑色的白色文本「RButton Up + q」變得可見在遊戲中的地方,它開始惹惱:)有什麼,我應該關閉在AutoHotKey或這是腳本相關? – CamSpy 2013-03-18 20:27:19

1

您可以使用後綴up機智熱鍵。當你釋放鍵h

h up:: 
    ; your code 
return 

將觸發。你可以使用任何熱鍵,包括鼠標。

您可以使用Send命令發送按鍵。

+0

我認爲它應該用兩個冒號讀'h up ::'。 – 2013-03-18 10:03:35

+0

Tnx,這是一個錯字。 – 2013-03-18 10:04:36

相關問題