Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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}.)

share|improve this answer
    
Thanks, this is exactly what I wanted! –  oggmonster Sep 2 '11 at 7:31

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
share|improve this answer
    
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 '11 at 21:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.