autohotkey - Autohotkey - 在屏幕上的特定位置单击时发送键
问题描述
我正在尝试编写 AutoHotkey 代码,当在屏幕中的某个位置单击鼠标左键时发送空格键(范围如下所示)。如果在范围之外单击鼠标,则应导致默认行为。下面的代码不起作用。例如,如果我单击 ypos 小于 170 的应用程序的关闭按钮,则没有任何反应。请求帮助/输入。谢谢。
#IfWinActive ahk_class IrfanView
LButton::
MouseGetPos,xpos, ypos
If (ypos >170 and ypos <570)
{
Msgbox %ypos%
Send, {Space}
}
#IfWinActive
Return
解决方案
你几乎拥有它。
由于您正在处理鼠标左键单击,因此鼠标方面不会发生任何进一步的事情。
所以你必须像这样重新发出点击事件:
#IfWinActive ahk_class IrfanView
LButton::
MouseGetPos, xpos, ypos
If (ypos >170 and ypos <570) {
Msgbox %ypos%
Send, {Space}
}
Else {
Click
}
Return
另请注意,我删除了您的第二个#ifWinActive
这不应该在 return 语句之前发生。
如果您只是为 IrfanView 添加热键,则根本不需要该语句。如果像我一样,你在一个大脚本中为不同的窗口/程序捕获键,那么遵循这样的模式
#IfWinActive ahk_class CabinetWClass ;Windows Explorer
...keydefs here...
#IfWinActiveahk_class XLMAIN ;Excel
...keydefs here...
#IfWinActive ahk_exe OUTLOOK.exe ;Outlook
...keydefs here...
#IfWinActive ;Keys that work anywhere
...all other keydefs here...
推荐阅读
- web-services - WSDL 服务占位符解释
- oracle - ORA-20900: 目录 MY_DIR 不存在或没有权限
- reactjs - componentDidMount 和 componentDidUpdate 一起使用 useEffect 钩子
- ios - 无法将点击手势识别器添加到 SwiftUI MKMapView UIViewRepresentable
- reactjs - 没有重载将此调用与样式化组件匹配 (index.d.ts(2187, 9))
- ruby-on-rails - 必须使用 attr_encrypted 指定 iv 错误
- c# - 在.net项目中解析来自http post async的结果时出错
- reactive-programming - 打印以下 Mono 日志行的正确方法是什么
而不是 donOnsucess : subscribe() 反应式 - swiftui - 在 SwiftUI 中创建额外的选项卡
- html - 我的导航栏的 css 代码没有覆盖我的屏幕的整个宽度。它在边缘前约 10 个像素处停止