English 中文(简体)
AutoHotKey key SEQUENCE, not just single-key hotkey
原标题:

I m not stupid... really. How do you map a key SEQUENCE (ie: Ctrl + Q , F) in AutoHotKey.

I ve got Ctrl + Q down:

^q::

I ve even got F:

f::

The examples in the help files even show how to do two keystrokes in a row:

Numpad0 & Numpad1::

But it just will not work with:

^q & f ::

Or any of these either:

LCtrl & q & f::
^q & ^f::
^q^f::
^qf::

How do I accomplish a Key SEQUENCE triggering something, when one of those keys is the Ctrl key? I looked into using a HOTSTRING instead, but couldn t work out how to include the Ctrl character, in that context!

最佳回答

Alright; The answer seems to be:

^q::
Input Key, L1
if Key=f
...some code here...
return
问题回答

In case someone s looking for a similar thing, but actually want CtrlQ + CtrlF and only if Ctrl is held throughout (so, to some, this might seem like CtrlQ + F), then here s how to do that:

$Ctrl::Send {Ctrl Down}
$Ctrl UP::
    ChordIsBroken := True
    Send {Ctrl Up}
    Return
^q::
    ChordIsBroken := False
    Input, OutputVar, L1 M
    If (!ChordIsBroken && Asc(OutputVar) = 6)
    {
        MsgBox "Hello, World!"
    }
    Else
    {
        SendInput %OutputVar%
    }
    Return

See https://superuser.com/a/725303/145431 for my explanation.

Or you can do it like this:

q & f::
    if GetKeyState("Control") {
        ; Do something
        return
    }
    return

I think this is a bit more readable than using Input Key, L1 as in above.

This catches CTRL+F. If Q is held down at that moment, your code fires.

^f::
    If GetKeyState("q", "p") {
        MsgBox test
    } Else {
        Send ^f
    }
return




相关问题
How to go to an error using only the keyboard in Eclipse?

Let s say I have a file with 10 lines and I have a problem with the name of the package (or something) and the cursor is on the last line of the text. How can I go directly to that line to see what ...

Switching focus between editor and terminal in Kate

When working in Unix with various programming languages I often use Kate as my primary editor. It has a really nice function of being able to open a built-in terminal window which is quite useful. ...

Shortcuts to change the active tab in my application

My application has a main window that contain a TabControl with about 7 TabItems. Inside each tabItem I put a UserControl. I would like that (no matter the active tab, or control) when the user press ...

Keyboard shortcut to build only startup project?

I ve tried to find a keyboard shortcut to build only the startup project In VS2008. I only found a configurable shortcut to build the project which is currently viewed, which isn t as good. Any ...

Custom Emacs key bindings are not working

The key bindings I ve defined in my .emacs file aren t working. Here s the file: ;init modes (menu-bar-mode 0) (tool-bar-mode 0) (cua-mode) (column-number-mode) (fset perl-mode cperl-mode) (cperl-...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

热门标签