本文介绍了为什么Visual Studio在自动热键之前会捕获关键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,作为一项实验,我切换到了Dvorak键盘布局.过渡中最困难的部分之一是处理热键.大多数热键在设计时都考虑了QWERTY,更糟糕的是,热键似乎束缚了肌肉.

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.

我编写了一个自动热键脚本,当,或键.除了Visual Studio '08,它在我尝试过的所有地方都能正常工作.似乎击键是在自动热键可以翻译它们之前被捕获的.

Rather than relearn all the hot-keys, I've written an autohotkey script to translate the Dvorak layout back to QWERTY when the , , or keys are pressed in conjunction with other keys. It works beautifully everywhere I've tried, except Visual Studio '08. It seems keystrokes 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

更新:该脚本在带有ahk,vs08和全新安装的Coderush的Win7上可以正常工作.我遇到问题的机器正在运行Vista.对进一步诊断有何想法?

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?

更新2:该脚本可以在Vista和2010 beta 2上正常工作.今晚要尝试重新安装vs08.

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.

推荐答案

啊!我知道了.如果ahk和目标应用程序不在同一特权(或用户)下运行,则ahk将无法正确拦截/模拟键盘事件.就我而言,Visual Studio是使用管理员(提升的)特权运行的,而ahk脚本是以当前登录的用户身份运行的.

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:

  • 以当前用户身份同时运行vs和ahk
  • 编译脚本并以管理员身份运行vs和已编译的应用程序

这篇关于为什么Visual Studio在自动热键之前会捕获关键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 10:11