0
votes

I want to configure autohotkey in the following way:

Capslock::Esc

Capslock & C::
Run, www.stackoverflow.com
return

So if I just press Capslock it treated like if I would have pressed Esc. If I on the other hand press both Capslock and c, it call the function that opens the browser with www.stackoverflow.com.

At the moment the remapped seems to break when I have the other function in the script. When I press capslock now it toggles it for a short time, so the key alone does effectively nothing. I don't get my Esc.

Pressing capslocks + A on the other hand activates capslock and produces a real A.

Is there an easy way to fix this?

1
I added one more shortcut line on the bottom and it works fine (F10::MsgBox try me out). Maybe the problem is that your rest of the code causes some troubles?DrOmader
@cajmer: Are you sure that you get a real Esc? I added a bit more information about what the code does on my end. And no I don't have any additional lines in my script.Christian
You're right, I didn't get correct Esc. I focused more on "other function" - my bad. Anyway, I've submitted an answer that should meet your needs.DrOmader

1 Answers

1
votes

Check out this code:

inProcess = 0

Capslock::
    Gui, 93:+Owner ; prevent display of taskbar button
    Gui, 93:Show, y-99999 NA, Enable nav-hotkeys
    inProcess = 1
    KeyWait, Capslock ; wait until the Capslock button is released
    Gui, 93:Cancel
    if (inProcess == 1){
        Send, {Esc}
    }
Return

#IfWinExist, Enable nav-hotkeys
    *c::
    Run, www.stackoverflow.com
    inProcess = 0
    return
#IfWinExist, ; end context-sensitive block

I've modified an answer available here: http://www.autohotkey.com/board/topic/56428-problem-rebinding-ctrl-to-capslock-using/