Jump to content

hotKey pressed twice


Recommended Posts

How to set a hotkey to a key that is pressed twice within certain time frame? Like Google Desktop Search floating bar, pressing Ctrl twice activates it.

;The following code works but also take the z key away from other edit program such as notepad.
HotKeySet("z","zz")
While 1
    Sleep(100)
WEnd

Func zz()
    Sleep(100)
    For $i = 1 To 5
        Sleep(100)
        If _IsPressed("5A") Then ShellExecute("zz.txt")
    Next
;If @HotKeyPressed = "z" Then ShellExecute("zz.txt")
;If _IsPressed("5A") Then ShellExecute("zz.txt")
EndFunc

;Try to define Alt+z(pressed twice) but doesn't work.
HotKeySet("!z","zz")
While 1
    Sleep(100)
WEnd

Func zz()
    Sleep(100)
    For $i = 1 To 5
        Sleep(100)
        If _IsPressed("5A") Then ShellExecute("zz.txt")
    Next
EndFunc

;While using AutoHotKey is easy, but I hate its syntax especially so-called "two methods: traditional and expression" to define variable.
~!z::
if (A_PriorHotkey <> "~!z" or A_TimeSincePriorHotkey > 400)
{
; Too much time between presses, so this isn't a double-press.
;KeyWait, z
    return
}
;MsgBox You double-pressed the z key.
return
Edited by John C.
Link to comment
Share on other sites

Hi,

see my sig.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...