2012-12-18

How to Create a Hotkey to Double Click Using AutoHotkey

Just created a hotkey to double-click so that I don't have to use the mouse! It is very much worth it and will speed up coding. There are other areas that I will be more productive in also. Just can't think of them right now.

I used an awesome program called AutoHotkey to achieve this and many other create keyboarding shortcuts/hotkeys/scripts. The following code basically says, "if ctrl is pressed twice consecutively in less than 500ms, then click two times at the caret position."


Ctrl::
    If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500) {
MouseGetPos X,Y
Send {Click  %A_CaretX%,%A_CaretY% 2} ; Moves the cursor
MouseMove (X),(Y) ; Moves back the cursor
    }
Return



  • Instead of using "%A_CaretX%,%A_CaretY%", it is possible to hardcode an x and y value to click on.
  • If you remove the line starting with MouseMove, then the cursor will move to the position the caret is at.


Let me know if this helps. =]

Disclaimer: I have not done an extensive test on all programs to see if this works. But, I know that it works in Notepad++, Eclipse, Notepad, and MS Word 2010. While typing this, the hotkey seems to return (aka double click) the top-left corner.

~ Simply Advanced ~



Post a Comment