为什么visual studio在autohotkey之前捕捉关键事件? [英] Why is visual studio catching key events before autohotkey?

查看:16
本文介绍了为什么visual studio在autohotkey之前捕捉关键事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近切换到 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.

我没有重新学习所有的热键,而是编写了一个自动热键脚本,在 CtrlAlt 时将 Dvorak 布局转换回 QWERTY>Win 键与其他键一起按下.除了 Visual Studio '08,它在我尝试过的任何地方都能很好地工作.似乎在 autohotkey 可以翻译它们之前就已经捕获了击键.

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 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.似乎仅适用于 vs 08 + vista.今晚要尝试全新安装 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在autohotkey之前捕捉关键事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆