2015-04-03 55 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