views:

143

answers:

2

I recently switched to the dvorak keyboard layout as a bit of an experiment. One of the most difficult parts of the transition has been dealing with hot-keys. Most hot-keys are designed with qwerty in mind and, to make matters worse, hot-keys seem to be extremely muscle memory bound.

Rather than relearn all the hot-keys, I've written an autohotkey script to translate the dvorak layout back to qwerty when the ctrl, alt, or win keys are pressed in conjunction with other keys. It works beautifully every where I've tried except visual studio 08. It seems key strokes are being caught before autohotkey can translate them.

Why is this happening and how do I fix this?

Below is an excerpt (from the start) of my script:

; control + letter
^;::^z
^q::^x
^j::^c
^k::^v

Update: The script works fine on Win7 with ahk, vs08, and coderush freshly installed. The machine I'm having trouble with is running vista. Any thoughts on how to further diagnose?

Update 2: The script works fine with Vista and 2010 beta 2. Seems to be something with just vs 08 + vista. Gonna try a fresh install of vs08 tonight.

+1  A: 

This phrase in the small print sounds relevant:

If SendMode is used in the auto-execute section (top part of the script), it affects all remappings. However, since remapping uses Send {Blind} and since the SendPlay mode does not fully support {Blind}, some remappings might not function properly in SendPlay mode (especially Control, Shift, Alt, and Win). To work around this, avoid SendPlay in auto-execute section when you have remappings; then use the command SendPlay vs. Send in other places throughout the script. Alternatively, you could translate your remappings into hotkeys (as described below) that explicitly call SendEvent vs. Send.

Hans Passant
I believe my script already uses "hot-keys" and not the send commands. I've included an excerpt. Does this seem relevant given that? I'll read the full small print in a bit.
TheDeeno
Putting the script in "Send Event" mode doesn't seem to work. To the up voters: Have u confirmed this works? I'm likely missing something.
TheDeeno
Actually putting the script in any of the four "send" modes doesn't help. :(
TheDeeno
+3  A: 

Aha! I've figured it out. If ahk and the target app are not running under the same privileges (or user) ahk won't intercept/simulate keyboard events properly. In my case, visual studio was run with administrator (elevated) privileges while the ahk script was run as the currently logged on user.

Either of the following solved the problem:

  • Running both vs and ahk as the current user
  • Compiling the script and running both vs and the compiled app as administrator
TheDeeno
Compiling and running as admin worked perfectly!
MEMark