Skip to content

Commit

Permalink
fix: KeyWait错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
snomiao committed Apr 3, 2021
1 parent c969651 commit 29e5449
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 101 deletions.
2 changes: 1 addition & 1 deletion Core/CapslockX-Core.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ CapsLockX_Dn(){
CapsLockX_上次触发键 := ""
; ToolTip, % first5char "_" 触发键
SendEvent {%触发键% Down}
KeyWait %触发键%
KeyWait %触发键%, T5 ; wait for 5 seconds
SendEvent {%触发键% Up}
Return
}
Expand Down
2 changes: 1 addition & 1 deletion Modules/00-Help.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CapsLockX_ShowHelp(helpStr, inGlobal = 0, waitKey = "/"){
Gui, Add, Text,, %helpStr%
Gui, Show

KeyWait, %waitKey%
KeyWait, %waitKey%, T60 ; wait for 60 seconds
; Gui, Hide
Gui, Destroy
; ToolTip
Expand Down
4 changes: 2 additions & 2 deletions Modules/01.1-插件-鼠标模拟.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,12 @@ ScrollTicker(){

$*e::
SendEvent {LButton Down}
KeyWait, e
KeyWait, e, T60 ; wait for 60 seconds
Return
$*e Up:: SendEvent {LButton Up}
$*q::
SendEvent {RButton Down}
KeyWait, q
KeyWait, q, T60 ; wait for 60 seconds
Return
$*q Up:: SendEvent {RButton Up}
; 鼠标运动处理
Expand Down
10 changes: 0 additions & 10 deletions Modules/03.1-插件-窗口增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@ c:: ArrangeWindows(ARRANGE_SIDE_BY_SIDE|ARRANGE_MAXWINDOW)
; Send {AppsKey}i
Return

; WinTab 窗口切换
; \::
; Send {LAlt Down}{Tab Down}{Tab Up}
; KeyWait, \
; Return
; \ Up::
; Send {LAlt Down}{Tab Down}{Tab Up}
; KeyWait, \
; Return

; 切换当前窗口置顶并透明
+v::
WinSet, Transparent, 200, A
Expand Down
13 changes: 0 additions & 13 deletions Modules/SaladictTranslate.ahk

This file was deleted.

2 changes: 1 addition & 1 deletion Modules/应用-Anki增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AnkiEnlock(key, to){
}
Anki增强_Lock := 1
Send %to%
KeyWait, %key%
KeyWait, %key%, T60 ; wait for 60 seconds
}
AnkiUnlock(x){
Anki增强_Lock := 0
Expand Down
77 changes: 24 additions & 53 deletions Modules/应用-OneNote2016增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,17 @@ getAscStr(str){
Return out
}

; 快速添加事项清单
OpenToDoList_old(){
if !WinExist("TODO - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE")
Run "onenote:#TODO" ; 打开默认分区的 TODO 页面
WinWait TODO - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE
WinActivate ; Uses the last found window.
SendEvent ^{End}{Enter}
Return
}

; 打开快速笔记主页
OpenHomePage(){
SendEvent #n
; if !WinExist(".* - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE")
; WinWait .* - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE
; WinActivate ; Uses the last found window.
WinWaitActive .* - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE
WinWaitActive .* - OneNote ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE , , 5 ; wait for 5 seconds
if(ErrorLevel){
TrayTip, 错误, 未找到OneNote窗口
return
}
SendEvent !{Home}
SendEvent ^{Home}
; SendEvent ^{End}{Enter}
Expand All @@ -73,7 +67,12 @@ OpenHomePage(){

CopySearchResultSectionAndPagesThenPaste(){
CopySearchResultSectionAndPages()
WinWaitNotActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2
; WinWaitNotActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2
WinWaitActive ahk_class Framework`:`:CFrame ahk_exe ONENOTE.EXE , , 5 ; wait for 5 seconds
if(ErrorLevel){
TrayTip, 错误, 未找到OneNote窗口
return
}
SendEvent ^v
}

Expand Down Expand Up @@ -362,8 +361,18 @@ $!k::
; 输入搜索内容
ControlSetText, RICHEDIT60W1, %Clipboard%, A
ToolTip, 放开Alt键继续
KeyWait, Alt, D
KeyWait, Alt
KeyWait, Alt, D T60 ; wait for 60 seconds
if(ErrorLevel){
ToolTip
TrayTip, 错误, 超时未按下Alt
return
}
KeyWait, Alt, T60 ; wait for 60 seconds
if(ErrorLevel){
ToolTip
TrayTip, 错误, 超时未放开Alt
return
}
ToolTip
CopySearchResultSectionAndPagesThenPaste()
Return
Expand All @@ -373,44 +382,6 @@ $!+k::
SendEvent {Home}[[{End}]]
Return

; ; 将当前内容追加到相关页面
; $!+k::
; ; 复制当前内容
; Clipboard := ""
; SendEvent ^a^x{Left}{Enter}^k
; ClipWait, 2

; ; 可能新建一个页面
; WinWaitActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2
; ; 输入搜索内容
; ControlSetText, RICHEDIT60W1, %Clipboard%, A
; ; 等结果出来

; KeyWait, Alt ; 放开Alt确认

; SendEvent {Enter}
; WinWaitNotActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2

; ; ; (如果是新建生成的链接可能出bug不能直接点过去)
; ; Sleep, 1000
; ; ; 所以这里等新页面好了之后再来一次就能点进去了
; SendEvent ^a{Delete}{Left}{Enter}^k

; WinWaitActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2
; ; 输入搜索内容
; ControlSetText, RICHEDIT60W1, %Clipboard%, A
; ; 等结果出来
; KeyWait, Alt, D ; 按Alt确认
; SendEvent {Enter}
; WinWaitNotActive ahk_class NUIDialog ahk_exe ONENOTE.EXE,, 2
; SendEvent {Left}{Enter}
; ; 在新页面末尾追加粘贴内容
; SendEvent ^{Home}^{End}+{Tab}{Enter}^v
; KeyWait, Alt ; 放开Alt确认
; SendEvent !{Left}
; Return
; ; $!d:: altSend("dh")

; 大纲折叠展开
$!1:: SendEvent !+1
$!2:: SendEvent !+2
Expand Down Expand Up @@ -522,7 +493,7 @@ return
; ; 通常在弹起时触发
; Clipboard := ""
ClipWait, 2, 1 ; 2 secons
if ErrorLevel {
if(ErrorLevel){
TrayTip, error, The attempt 2 copy text onto the clipboard failed.
Return
}
Expand Down
16 changes: 0 additions & 16 deletions Modules/应用-TIM连接OneNote2016.ahk

This file was deleted.

8 changes: 4 additions & 4 deletions Modules/应用-mstsc远程桌面增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,17 @@ return

上次CtrlShiftAlt锁 := 1
ToolTip, 双击 LCtrl LAlt LShift 来最后置当前窗口(主要用于虚拟机和远程桌面)
KeyWait, LCtrl
KeyWait, LAlt
KeyWait, LShift
KeyWait, LCtrl, T5 ; wait for 5 seconds
KeyWait, LAlt, T5 ; wait for 5 seconds
KeyWait, LShift, T5 ; wait for 5 seconds
SetTimer, MSTSC_ENHANCE_RemoveToolTip, -1024
现在 := A_TickCount
间隔 := 现在 - 上次CtrlShiftAlt时刻
if(间隔 < 200){
setCurrentWindowAsBackground()
}else{
上次CtrlShiftAlt时刻 := 现在
}
SetTimer, MSTSC_ENHANCE_RemoveToolTip, -1024
上次CtrlShiftAlt锁 := 0
return

Expand Down

0 comments on commit 29e5449

Please sign in to comment.