2015-04-03 56 views
0

我希望我的代碼能夠註冊,如果鼠標點擊,並做一些事情發生時,但也能夠如果鼠標被按下,則註冊並且如果情況如此,則不中斷鼠標被按下。例如,如果點擊鼠標,做一件事,如果鼠標按下,做正常的事情

If AutoCAD is open 
     If mbutton is clicked 
      click the escape key 
     If mbutton is held down 
      be able to use the mbutton held down as usual 
    End 

我已經嘗試了幾種不同的方法來做到這一點,但我沒有準確地做到這一點。我已經得到了「如果AutoCAD打開」,並單擊「退出鍵」部分,只是沒有「如果按下部分正常使用mbutton」

感謝您提供任何幫助!

+0

你爲什麼不向我們提供你已經得到的代碼? – Blauhirn 2015-04-03 14:48:07

回答

0

如果我理解你的權利,你正在尋找UP關鍵字:

這個字可以遵循熱鍵的名字在關鍵的釋放導致熱鍵 火,而不是當按鍵被按下時。

documentation

#if autocad() 
MButton Up:: 
send {escape} 
return 
#if 

autocad() { 
    return true 
} 
+0

這個腳本在按住MButton後仍然會發送Escape。 – 2015-04-03 18:32:23

+0

好吧,我以他想要的方式理解OP。你可能是對的。 – Blauhirn 2015-04-03 21:34:27

2

是有點一個棘手的。相應地更改#IfWinExist行。你可以調整持續時間,你會考慮「持有」MButton

SetTitleMatchMode, 2 

#IfWinExist AutoCAD 

~MButton:: 
    duration := 100 
    start := A_TickCount 

    While(GetKeyState("MButton")) 
    { 
     if ((A_TickCount - start) > duration) 
     { 
      KeyWait, MButton 
      Send {MButton Up} 
      Return 
     } 
    } 
    Send, {Escape} 
    Return 

#IfWinExist AutoCAD