Double Click - KeyWait
There are at least three ways to perform an action based on multiple presses of the same key. This method relies on the KeyWait command.
~$lbutton:: ;*1 { keywait, lbutton ;*2 keywait, lbutton, d t.3 ;*3 if (!errorlevel) ;*4 { msgbox, You double clicked! ;*5 } } return /* 1 A hotkey using the left mouse button. 2 Keywait stops code execution until the key has been released. 3 keywait waits 333ms for the key to be pressed. If the key is pressed in that time it sets the errorlevel var to 1, otherwise errorlevel to 0. 4 Checks if errorlevel evaluates to true (1) or false (0). If false it runs any code belonging to the If statement. 5 Message box is only displayed if the key is pressed and released twice in the allotted time. */ |
This is a simple 'double click' example. If you want to work with more than just two presses/courses of action then a different method would probably be better.