3

I want to map control Ctrl+Left to Home and Ctrl+Right to End, and I'm using AutoHotkey, my script is simply this:

^Left::Home
^Right::End

However, when the Home and End keys are generated, they are interpreted at Ctrl+Home and Ctrl+End because I'm holding down the Ctrl key to generate them. How can I disable the Ctrl key or any modifier key when reassigning keys?

2 Answers 2

4

It looks like you can just use Send:

^Left::Send {Home}
^Right::Send {End}

;Doesn't work with Shift, so we can add that manually:

+^Left::Send +{Home}
+^Right::Send +{End}

;You can add any other modifier keys you need to work.

It appears using Send will temporarily release any modifier keys already held down, so that the output of Send won't be affected by them -- unless you specifically use {Blind} to preserve modifier keys already held down.

The a::b format is used to remap keys and preserves any modifiers held down. (It actually internally uses Send {Blind}.)

0
2

Try:

^Left::
KeyWait Control
Home
Return

^Right::
KeyWait Control
End
Return

If you just need any code for this and it doesn't need to be autohotkey, AuotIt should work:

HotKeySet("^{LEFT}", "Home")
HotKeySet("^{RIGHT}", "End")
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(100)
WEnd

Func Home()
    Send("{HOME}")
EndFunc

Func End()
    Send("{END}")
EndFunc

Func Terminate()
    Exit 0
EndFunc
1
  • I guess this could kinda work, it would be really nice if AutoHotkey could just somehow disable modifier keys temporarily; I want this short cut for text editing in particular IDEs so having to release Ctrl before the line is skipped will be a bit annoying when I'm selecting a line to copy: Shift+Ctrl+Left->Release Ctrl->Ctrl+C
    – oggmonster
    Sep 1, 2011 at 21:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .