Double-tap keypress hook Thread last updated on 2006-10-18 05:23:38

Posted by member 71746 on 2006-10-18 02:22:40

Avast ye!

So I've an interesting little goal here... I'd like a way to exectute !bangs by using a double-tap of a given key instead of a key combination.

examples:
1. bring up the litestep menu by double-tapping F5 instead of hitting win-F5..
2. toggle visibility of one/all interface element(s)
3. toggle z-order of one/all interface element(s) - always hug desktop / always on top

Could a module be created to cater to such an odd specification? Seems like it'd be useful in lots of ways.

Posted by member 212670 on 2006-10-18 05:23:38 link

Here's a really crude way you could do it:
*NetLoadModule typein-991019
*NetLoadModule mzscript-1.0-rc2

PressDelay 0.25 ;how fast the key needs to be double clicked (ex: 0.25 is 1/4 of a second)

*Hotkey .None s !keypress ;key to be double clicked (ex: s)

*Script bang !keypress
*Script exec !varset timestamp1 %{second}.%{milli}
*Script exec !ifExist [timestamp2] [!action][!varset timestamp2 %{second}.%{milli}]
*Script exec !TypeIn "^_s^_" ;needs to match hotkey's key. remove/add "^_" if problems - see typein readme
*Script ~bang

*Script bang !action
*Script exec !If ["%#%{timestamp1}-%{timestamp2}%#" < "$PressDelay$"] [!alert "double click"] ;action for double click
*Script exec !varremove timestamp2
*Script ~bang

I think the best solution would come from outside of Litestep, though, unless someone knows a better way to capture key presses.