autohotkey - OneNote 在 AHK 之前拦截笔光标?
问题描述
手掌拒绝在我的笔记本电脑上是垃圾,所以我禁用了 HID 触摸屏以使其只有笔输入寄存器。因此,我使用 AHK 制作了一个脚本,该脚本将在用户按下后滚动页面ALT
,并在第二次按下时禁用滚动ALT
。
它工作得很好,除了在 OneNote(Win 10 应用程序)中,笔光标输入被 OneNote 劫持。例如,如果我创建一个ToolTip, %xPos% %yPos%
,那么当我的笔光标悬停在 OneNote 窗口上方的任何位置时,它不会更新。这之外的任何地方都可以正常工作。
如何让 AHK 在 OneNote 获取之前窃取笔光标输入?
isTabletMode := 1
penScrollActive := 0
#MaxThreadsPerHotkey 2 ; Allows a second instance to modify penScrollActive while PenScroll is looping.
$Alt::
; Check if PC is in tablet mode.
; 1 --> Tablet, 0 --> Desktop
RegRead, isTabletMode, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell,TabletMode
if(isTabletMode) {
if(penScrollActive) {
penScrollActive := 0 ; We are already scrolling, so turn it off.
}
else {
penScrollActive := 1 ; We are not scrolling yet, so turn on pen scrolling.
}
GoSub PenScroll
}
else ; If we aren't in tablet mode, then Alt should just send Alt
Send, {Alt}
return
PenScroll:
loop { ; For some reason, while() logic wasn't working, so this is a workaround. Breaks upon the conditional at bottom.
MouseGetPos, mouseX, mouseY
ToolTip, %mouseX% %mouseY% ; For debugging: Output what cursor pos registers as. (This isn't working in OneNote when using the pen input as a cursor (eg. hover) ).
Sleep, 20
MouseGetPos, mouseX_new, mouseY_new
if (mouseX_new - mouseX > 0) ; Horizontal scrolling
Send, {WheelLeft}
else if (mouseX_new - mouseX < 0)
Send, {WheelRight}
if (mouseY_new - mouseY > 0) ; Vertical scrolling
Send, {WheelUp}
else if (mouseY_new - mouseY < 0)
Send, {WheelDown}
if (penScrollActive = 0) ; Conditional to break out
break
}
return
; To Reload the script: Win+`
#`::Reload
Return
#If penScrollActive
LButton::Return
解决方案
您可以尝试的一件事是我的 AHK 的AutoHotInterception库。您安装一个自定义设备驱动程序,然后您可以在操作系统下方的驱动程序级别挂钩输入事件。
它支持“绝对”(类似图形平板电脑)鼠标输入
您想要“订阅模式”端点
推荐阅读
- lisp - 自动将矩形转换为已知度数的凹弧
- docker - 无法连接到 Docker 上托管的 MLFlow 模型
- python - Python中使用月份缩写的正则表达式
- python - 如何使用 for 循环提取 loan_price 低于 500 的贷款?
- interface - 为什么不能在接口上使用带有表达式的 C# 9
- python - 通过 Discord.py 获得角色
- https - HTTPS 代理服务
- java - 通过单选按钮从 Thymeleaf 获取输入,将包装对象中的列表返回给控制器
- javascript - 在节点中转换非统一时间戳?
- google-apps-script - Google Sheet 插件超时 ~ 45 秒?