Skip to content

Commit

Permalink
fix: try fix sendmode
Browse files Browse the repository at this point in the history
  • Loading branch information
snomiao committed Mar 11, 2022
1 parent ff85432 commit c94c56a
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 58 deletions.
10 changes: 5 additions & 5 deletions Core/CapslockX-Core.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ UpdateCapsLockXLight()
UpEdge := NowLightState && !LastLightState

if (T_UseScrollLockLight && GetKeyState("ScrollLock", "T") != NowLightState) {
SendEvent {ScrollLock}
Send {ScrollLock}
}
if (T_UseCursor) {
; Module
Expand Down Expand Up @@ -278,9 +278,9 @@ CapsLockX_Dn()
if (BypassCapsLockX) {
CapsLockX_上次触发键 := ""
; ToolTip, % first5char "_" 触发键
SendEvent {Blind}{%触发键% Down}
Send {Blind}{%触发键% Down}
KeyWait %触发键%
SendEvent {Blind}{%触发键% Up}
Send {Blind}{%触发键% Up}
Return
}
; 记录 CapsLockX 按住的时间
Expand All @@ -303,7 +303,7 @@ CapsLockX_Dn()
; 长按空格时保持原功能
; TODO: read system repeat interval
if ( A_TickCount - CapsLockPressTimestamp > 200) {
SendEvent, {Blind}{Space}
Send, {Blind}{Space}
}
} else {
if ( A_TickCount - CapsLockPressTimestamp > 1000) {
Expand Down Expand Up @@ -340,7 +340,7 @@ CapsLockX_Up()
}
}
if (CapsLockX_上次触发键 == "Space") {
SendEvent {Blind}{Space}
Send {Blind}{Space}
}
}
}
Expand Down
22 changes: 12 additions & 10 deletions Modules/01.1-插件-鼠标模拟.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ if (!CapsLockX) {
global TMouse_Disabled := CapsLockX_Config("TMouse", "Disabled", 0, "禁用模拟鼠标模块")
global TMouse_SendInput := CapsLockX_Config("TMouse", "SendInput", 1, "使用 SendInput 方法提高模拟鼠标点击、移动性能")
global TMouse_SendInputAPI := CapsLockX_Config("TMouse", "SendInputAPI", 1, "使用 Windows API 强势提升模拟鼠标移动性能")
global TMouse_SendInputScroll := CapsLockX_Config("TMouse", "TMouse_SendInputScroll", 0, "使用 Windows API 强势提升模拟鼠标滚轮性能(目前有bug不建议启用)")

global TMouse_StickyCursor := CapsLockX_Config("TMouse", "StickyCursor", 1, "启用自动粘附各种按钮,编辑框")
global TMouse_StopAtScreenEdge := CapsLockX_Config("TMouse", "StopAtScreenEdge", 1, "撞上屏幕边界后停止加速")

Expand All @@ -33,9 +35,9 @@ global 滚轮模拟 := new AccModel2D(Func("滚轮模拟"), 0.1, TMouse_DPIRatio
global 滚轮自动控制 := new AccModel2D(Func("滚轮自动控制"), 0.1, 10)
global 滚轮自动 := new AccModel2D(Func("滚轮自动"), 0, 1)

if (TMouse_SendInput)
if (TMouse_SendInput) {
SendMode Input

}
; 解决多屏 DPI 问题
DllCall("Shcore.dll\SetProcessDpiAwareness", "UInt", 2)

Expand Down Expand Up @@ -92,21 +94,21 @@ SendInput_MouseMsg32(dwFlag, mouseData := 0)
NumPut(dwFlag, sendData, 16, "UInt")
DllCall("SendInput", "UInt", 1, "Str", sendData, "UInt", 28)
}
ScrollMouse(dx, dy)
{
if (TMouse_SendInputAPI) {
SendInput_ScrollMouse(dx, dy)
} else {
PostMessage_ScrollMouse(dx, dy)
}
}
PostMessage_ScrollMouse(dx, dy)
{
WM_MOUSEWHEEL := 0x020A
WM_MOUSEWHEELH := 0x020E
_:= dy && PostMessageForScroll(WM_MOUSEWHEEL, -dy)
_:= dx && PostMessageForScroll(WM_MOUSEWHEELH, dx)
}
ScrollMouse(dx, dy)
{
if (TMouse_SendInputScroll) {
SendInput_ScrollMouse(dx, dy)
} else {
PostMessage_ScrollMouse(dx, dy)
}
}
SendInput_ScrollMouse(dx, dy)
{
; get cursor pos
Expand Down
28 changes: 14 additions & 14 deletions Modules/01.2-插件-编辑增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@ DisableLockWorkstation()

左方向键发送(n:=1){
loop %n%{
SendEvent {Blind}{Left}
Send {Blind}{Left}
}
}
右方向键发送(n:=1){
loop %n%{
SendEvent {Blind}{Right}
Send {Blind}{Right}
}
}
上翻页键发送(n:=1){
loop %n%{
SendEvent {Blind}{PgUp}
Send {Blind}{PgUp}
}
}
下翻页键发送(n:=1){
loop %n%{
SendEvent {Blind}{PgDn}
Send {Blind}{PgDn}
}
}
上方向键发送(n:=1)
{
; 在 OneNote 笔记内部直接 SendEvent 上下方向键无反应, 故特殊处理使用 ControlSend 。
; 在 OneNote 笔记内部直接 Send 上下方向键无反应, 故特殊处理使用 ControlSend 。
if (hWnd := WinActive(".*- OneNote ahk_class Framework\:\:CFrame ahk_exe ONENOTE.EXE")) {
ControlGetFocus, focusedClassNN, ahk_id %hWnd%
if (focusedClassNN == "OneNote`:`:DocumentCanvas1") {
Expand All @@ -74,12 +74,12 @@ DisableLockWorkstation()
}
}
loop %n%{
SendEvent {Blind}{up}
Send {Blind}{up}
}
}
下方向键发送(n:=1)
{
; 在 OneNote 笔记内部直接 SendEvent 上下方向键无反应, 故特殊处理使用 ControlSend 。
; 在 OneNote 笔记内部直接 Send 上下方向键无反应, 故特殊处理使用 ControlSend 。
if (hWnd := WinActive(".*- OneNote ahk_class Framework\:\:CFrame ahk_exe ONENOTE.EXE")) {
ControlGetFocus, focusedClassNN, ahk_id %hWnd%
if (focusedClassNN == "OneNote`:`:DocumentCanvas1") {
Expand All @@ -90,7 +90,7 @@ DisableLockWorkstation()
}
}
loop %n%{
SendEvent {Blind}{Down}
Send {Blind}{Down}
}
}

Expand All @@ -112,7 +112,7 @@ TurboTab(dx, dy, 状态)
return
}
loop %dy%{
SendEvent {Blind}{Tab}
Send {Blind}{Tab}
}
}

Expand All @@ -125,9 +125,9 @@ TurboTab(dx, dy, 状态)
; hl 选词
; 先按右再按左
if (dx > 0) {
SendEvent ^{Right}^+{Left}
Send ^{Right}^+{Left}
} else {
SendEvent ^{Left}^+{Right}
Send ^{Left}^+{Right}
}
return 方向键模拟.止动()
}
Expand All @@ -136,11 +136,11 @@ TurboTab(dx, dy, 状态)
; 先按下再按上
if (dy > 0) {
上方向键发送(1)
SendEvent {Home}+{End}
; SendEvent {End}+{Home}
Send {Home}+{End}
; Send {End}+{Home}
} else {
下方向键发送(1)
SendEvent {Home}+{End}
Send {Home}+{End}
}
return 方向键模拟.止动()
}
Expand Down
4 changes: 2 additions & 2 deletions Modules/CapsLockX-EnterWithoutBreak.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ return
; [[建议]增加backspace删除整行 · Issue #33 · snolab/CapsLockX]( https://github.com/snolab/CapsLockX/issues/33 )

; tested in vscode multiline mode
Enter:: SendEvent {End 2}{Enter} ; 行尾回车
BackSpace:: SendEvent {Home 2}{End}{Home 2}+{End 2}+{Right}{Delete} ; 删除整行
Enter:: Send {End 2}{Enter} ; 行尾回车
BackSpace:: Send {Home 2}{End}{Home 2}+{End 2}+{Right}{Delete} ; 删除整行
32 changes: 16 additions & 16 deletions Modules/应用-Anki增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,18 @@ AnkiUnlock(x)
在Anki学习界面(){
return !CapsLockXMode && (WinActive("Anki -.* ahk_class QWidget ahk_exe anki.exe") or WinActive("Anki - .*|.* - Anki ahk_class Qt5QWindowIcon ahk_exe anki.exe"))
}
$x:: SendEvent s ; study
$q:: SendEvent d ; quit
$c:: SendEvent a ; create
$x:: Send s ; study
$q:: Send d ; quit
$c:: Send a ; create

; 撤销
$5:: SendEvent ^z
$Numpad5:: SendEvent ^z
$5:: Send ^z
$Numpad5:: Send ^z

; 暂停卡片
$`:: SendEvent {Space}
$6:: SendEvent @
$Numpad6:: SendEvent @
$`:: Send {Space}
$6:: Send @
$Numpad6:: Send @

; 方向键控制
$w:: AnkiEnlock("w", "^z")
Expand Down Expand Up @@ -178,32 +178,32 @@ $!c::
TrayTip, CapsLockX, 没有获取到剪贴板的内容
Return
}
SendEvent ^v
Send ^v
Return

$!s:: SendEvent ^{Enter}
$!x:: SendEvent ^+x
$!s:: Send ^{Enter}
$!x:: Send ^+x

#if (WinExist("添加|Add ahk_class QWidget ahk_exe anki.exe") or WinExist("添加|Add ahk_class Qt5QWindowIcon ahk_exe anki.exe")) ;

$F1::
if (!CaptureScreenNoteAdd()) {
Return
}
SendEvent ^v
Send ^v
Sleep 200
SendEvent {Tab}
Send {Tab}
Return
$F2::
if (!CaptureScreenNoteAdd()) {
Return
}
SendEvent ^v
Send ^v
Sleep 200
SendEvent ^{Enter}
Send ^{Enter}
$F3::
if (!CaptureScreenNoteAdd()) {
Return
}
SendEvent ^+o
Send ^+o
Return
2 changes: 1 addition & 1 deletion Modules/应用-OneNote2016增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ F2:: SendEvent ^+t ; 重命名笔记
Clipboard := ""
SendEvent ^+a{AppsKey}l
ClipWait, 1
if(ErrorLevel)
if (ErrorLevel)
Return
Clipboard := Func("SafetyEvalJavascript").Call("``" Clipboard "``.match(/^(onenote:.*)$/mi)?.[0]||""""")
}
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ CapsLockX 是一款基于 AutoHotkey 的模块化热键脚本引擎。 让你可

<!-- culture badges -->

[![中文编程](https://github.com/Program-in-Chinese/overview/raw/master/%E4%B8%AD%E6%96%87%E7%BC%96%E7%A8%8B.svg)](https://github.com/Program-in-Chinese/overview)
[![中文编程](https://github.com/Program-in-Chinese/overview/raw/master/%E4%B8%AD%E6%96%87%E7%BC%96%E7%A8%8B.svg)](https://github.com/Program-in-Chinese/overview),
[![996.icu](https://img.shields.io/badge/link-996.icu-red.svg)](https://996.icu)

<!-- clicks / downloads -->

[![jsdelivr_NPM](https://data.jsdelivr.com/v1/package/npm/capslockx/badge)](https://www.jsdelivr.com/package/npm/capslockx)
[![jsdelivr_GITHUB](https://data.jsdelivr.com/v1/package/gh/snolab/capslockx/badge)](https://www.jsdelivr.com/package/gh/snolab/capslockx)
[![Downloads-From-GitHub-Releases](https://img.shields.io/github/downloads/snolab/CapsLockX/total.svg?style=flat-square&label=Downloads-From-GitHub-Releases)](https://github.com/snolab/CapsLockX/releases)
[![GitHub license](https://img.shields.io/github/license/snolab/CapsLockX)](https://github.com/snolab/CapsLockX/blob/master/LICENSE.md)
![GitHub top language](https://img.shields.io/github/languages/top/snolab/CapsLockX)
![GitHub commit activity](https://img.shields.io/github/commit-activity/m/snolab/CapsLockX)
[![GitHub stars](https://img.shields.io/github/stars/snolab/CapsLockX)](https://github.com/snolab/CapsLockX/stargazers)

<!-- build and publish status -->

[![GitHub version](https://badge.fury.io/gh/snolab%2FCapsLockX.svg)](https://badge.fury.io/gh/snolab%2FCapsLockX)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/snolab/CapsLockX)
[![gh-pages](https://github.com/snolab/CapsLockX/actions/workflows/gh-pages-release.yml/badge.svg)](https://github.com/snolab/CapsLockX/actions/workflows/gh-pages-release.yml)
![GitHub all releases](https://img.shields.io/github/downloads/snolab/CapsLockX/total)
[![jsdelivr_GITHUB](https://data.jsdelivr.com/v1/package/gh/snolab/capslockx/badge)](https://www.jsdelivr.com/package/gh/snolab/capslockx)

[![npm version](https://badge.fury.io/js/capslockx.svg)](https://badge.fury.io/js/capslockx)
[![npm](https://img.shields.io/npm/v/capslockx)](https://www.npmjs.com/capslockx)
[![npm publish](https://github.com/snolab/CapsLockX/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/snolab/CapsLockX/actions/workflows/npm-publish.yml)
![npm](https://img.shields.io/npm/dt/capslockx)
![jsDelivr hits (npm)](https://img.shields.io/jsdelivr/npm/hy/capslockx)

[![Chocolatey version](https://img.shields.io/chocolatey/v/capslockx)](https://community.chocolatey.org/packages/CapsLockX/)
[![Chocolatey](https://github.com/snolab/CapsLockX/actions/workflows/choco-push.yml/badge.svg)](https://github.com/snolab/CapsLockX/actions/workflows/choco-push.yml)
[![Chocolatey Publish](https://github.com/snolab/CapsLockX/actions/workflows/choco-push.yml/badge.svg)](https://github.com/snolab/CapsLockX/actions/workflows/choco-push.yml)
[![Chocolatey Downloads](https://img.shields.io/chocolatey/dt/CapsLockX)](https://community.chocolatey.org/packages/CapsLockX/)

<!-- [![Packages Test](https://github.com/snolab/CapsLockX/actions/workflows/package-test.yml/badge.svg)](https://github.com/snolab/CapsLockX/actions/workflows/package-test.yml) -->

Expand Down

0 comments on commit c94c56a

Please sign in to comment.