问题描述:

I've remapped some keys using Autohotkey, like this:

LWin::LAlt

LCtrl::LWin

LAlt::LCtrl

I'm using Windows 7 with the Romanian (Programmers) keyboard layout. If I want to type ă I hit RAlt + a, for example. It's called "Programmers" because it's a reqular US QWERTY layout with extras activated by RAlt.

However, if I run my Autohotkey script AND then I send a RAlt + a/s/t/i, the system goes bonkers. Even if I close Autohotkey it still behaves like that. I have to log off/reboot or hit magic key sequence to fix it (I still haven't figured out what sequence).

What I'm guessing happens is that Alt somehow gets stuck and every key I press is mixed up with Alt. Pressing Esc switches Windows, pressing F while in an application opens the File menu, etc.

Is this an Autohotkey bug or am I doing something wrong?

I've used SharpKeys in the past for this but due to some requirements - shared computer - I need something per user and that preferably can be turned off. Autohotkey would have been perfect for this.

Thank you.

Late edit - the solution was what 576i (first section + key mappings to replace the previous keyboard mapping I was using - I gave up Romanian Programmers)

; Remap Ctrl to Win, Win to Alt, Alt to Ctrl - credit to 579i

$*LWin::Send {LAlt Down}

$*LWin Up::Send {LAlt Up}

$*LCtrl::Send {LWin Down}

$*LCtrl Up::Send {LWin Up}

$*LAlt::Send {LControl Down}

$*LAlt Up::Send {LControl Up}

; Keyboard mappings for Romanian letters

; First of all - GTK Windows are special and need special treatment

#IfWinActive, ahk_class gdkWindowToplevel

>!a::SendInput {Control Down}{Shift Down}u0103{Control Up}{Shift Up}

>!+a::SendInput {Control Down}{Shift Down}u0102{Control Up}{Shift Up}

>!q::SendInput {Control Down}{Shift Down}u00E2{Control Up}{Shift Up}

>!+q::SendInput {Control Down}{Shift Down}u00C2{Control Up}{Shift Up}

>!i::SendInput {Control Down}{Shift Down}u00EE{Control Up}{Shift Up}

>!+i::SendInput {Control Down}{Shift Down}u00CE{Control Up}{Shift Up}

>!s::SendInput {Control Down}{Shift Down}u0219{Control Up}{Shift Up}

>!+s::SendInput {Control Down}{Shift Down}u0218{Control Up}{Shift Up}

>!t::SendInput {Control Down}{Shift Down}u021B{Control Up}{Shift Up}

>!+t::SendInput {Control Down}{Shift Down}u021A{Control Up}{Shift Up}

; Then regular windows

#IfWinActive

>!a::Send ă

>!+a::Send Ă

>!q::Send â

>!+q::Send Â

>!i::Send î

>!+i::Send Î

>!s::Send ș

>!+s::Send Ș

>!t::Send ț

>!+t::Send Ț

[Edited to include the GTK fix; this still doesn't work for console Windows and there are some weird glitches when pasting, sometimes Ctrl is interpreted as Alt]

网友答案:

If your right Alt key is an Alt-Gr key it will be intepreted as LControl & RAlt which triggers your script.

Also it looks like you got an endless loop there.

Look at this example, this should work better for you.

The $ before hotkeys prevents that the key you "Send" triggers the next hotkey. The * makes sure the key also works when pressed with other keys.

$*LWin::Send {LAlt Down}
$*LWin Up::Send {LAlt Up}

$*LCtrl::Send {LWin Down}
$*LCtrl Up::Send {LWin Up}

$*LAlt::Send {LControl Down}
$*LAlt Up::Send {LControl Up}

This remapping might still kill your Alt-Gr key if your keyboard drivers sends "LControl & RAlt" internally.

You can fix this creating a special hotkey either for Alt-Gr or - if the romanian keyboard has only a few Alt-Gr combinations, define those as hotkeys.

Example from the Autohotkey help file Hotkey page:

<^>!m::MsgBox You pressed AltGr+m.
<^<!m::MsgBox You pressed LeftControl+LeftAlt+m.
相关阅读:
Top