Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
格式化代码
增加 CapsLockX_ConfigGet
移除 #NoEnv
使用 CLX + = 键计算表达式
恢复 ActiveBlinkingWindow方式切换窗口
启用JS表达式计算服务,并以$符号作为模块加载器
恢复ToolTip字体设定:黑体
修复OneNote把笔记时间显式填充到标题功能(Alt + t)
  • Loading branch information
snomiao committed Apr 11, 2021
1 parent 26b7836 commit 4630ce4
Show file tree
Hide file tree
Showing 9 changed files with 415 additions and 181 deletions.
14 changes: 11 additions & 3 deletions Core/CapslockX-Config.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (!!CapsLockXConfigPath){
}
CapsLockX_ConfigSet(field, varName, setValue, comment := ""){
if(!CapsLockXConfigPath){
MsgBox, 配置文件目录设定异常
MsgBox, 配置文件目录设定异常,请检查模块静态变量是否使用配置。
return
}
content := setValue
Expand All @@ -56,10 +56,18 @@ CapsLockX_ConfigSet(field, varName, setValue, comment := ""){
IniWrite, %content%, %CapsLockXConfigPath%, %field%, %varName%
return content
}

CapsLockX_ConfigGet(field, varName, defaultValue){
if(!CapsLockXConfigPath){
MsgBox, 配置文件目录设定异常,请检查模块静态变量是否使用配置。
return
}
IniRead, %varName%, %CapsLockXConfigPath%, %field%, %varName%, %defaultValue%
content := %varName% ; 千层套路XD
return content
}
CapsLockX_Config(field, varName, defaultValue, comment := ""){
if(!CapsLockXConfigPath){
MsgBox, 配置文件目录设定异常
MsgBox, 配置文件目录设定异常,请检查模块静态变量是否使用配置。
return
}
IniRead, %varName%, %CapsLockXConfigPath%, %field%, %varName%, %defaultValue%
Expand Down
2 changes: 1 addition & 1 deletion Core/CapslockX-Core.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Process Priority, , High ; 脚本高优先级
SetTitleMatchMode RegEx
#SingleInstance Force ; 跳过对话框并自动替换旧实例(在启动成功后有效)
#NoEnv ; 不检查空变量是否为环境变量
; #NoEnv ; 不检查空变量是否为环境变量
#Persistent
#MaxHotkeysPerInterval 1000 ; 时间内按键最大次数(通常是一直按着键触发的。。)
#InstallMouseHook ; 安装鼠标钩子
Expand Down
12 changes: 6 additions & 6 deletions Modules/03-虚拟桌面增强.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ Return
8:: SwitchToDesktop(8)
9:: SwitchToDesktop(9)
0:: SwitchToDesktop(10)
-:: SwitchToDesktop(11)
=:: SwitchToDesktop(12)
; -:: SwitchToDesktop(11)
; =:: SwitchToDesktop(12)

; Move the current window to the X-th desktop
+1:: MoveActiveWindowToDesktop(1)
Expand All @@ -70,8 +70,8 @@ Return
+8:: MoveActiveWindowToDesktop(8)
+9:: MoveActiveWindowToDesktop(9)
+0:: MoveActiveWindowToDesktop(10)
+-:: MoveActiveWindowToDesktop(11)
+=:: MoveActiveWindowToDesktop(12)
; +-:: MoveActiveWindowToDesktop(11)
; +=:: MoveActiveWindowToDesktop(12)
; Move the ALL visible window to the X-th desktop
!+1:: MoveAllVisibleWindowToDesktop(1)
!+2:: MoveAllVisibleWindowToDesktop(2)
Expand All @@ -83,8 +83,8 @@ Return
!+8:: MoveAllVisibleWindowToDesktop(8)
!+9:: MoveAllVisibleWindowToDesktop(9)
!+0:: MoveAllVisibleWindowToDesktop(10)
!+-:: MoveAllVisibleWindowToDesktop(11)
!+=:: MoveAllVisibleWindowToDesktop(12)
; !+-:: MoveAllVisibleWindowToDesktop(11)
; !+=:: MoveAllVisibleWindowToDesktop(12)

; API definitions
/*
Expand Down
102 changes: 102 additions & 0 deletions Modules/ActiveBlinkingWindow.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
; ========== CapsLockX ==========
; Note:Save as UTF-8 with BOM please
; 名称:快速切换最近的窗口
; 作者:snomiao ([email protected])
; 支持:https://github.com/snomiao/CapsLockX
; 版本:v2021.01.24
; 版权:Copyright © 2017-2021 Snowstar Laboratory. All Rights Reserved.
; 许可证 LICENCE: GNU GPLv3 ( https://www.gnu.org/licenses/gpl-3.0.html )
; ========== CapsLockX ==========
;
; MAIN REFERENCE:
; [Find the blinking window on the taskbar - Ask for Help - AutoHotkey Community]( https://autohotkey.com/board/topic/54990-find-the-blinking-window-on-the-taskbar/ )

; **************************************
; *** Switch to Last Flashing Window ***
; **************************************
; set trigger for flashing window

; InitFlashingWinTrigger
global lastFlashWinIDs := []
global winMousePoses := {}
global T窗口增强_鼠标位置记忆 := CapsLockX_Config("窗口增强", "鼠标位置记忆", 1)

Gui +LastFound
hWnd := WinExist() , DllCall( "RegisterShellHookWindow", UInt, hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

#If CapsLockXMode

*!z:: ActivateLastFlashWindow()
*z:: SendEvent {Blind}!{Esc}

#if

ReverseArray(oArray){
Array := Object()
For i,v in oArray
Array[oArray.Length()-i+1] := v
Return Array
}

arrayDistinctKeepTheLastOne(arr){ ; Hash O(n)
hash := {}, newArr := []
rarr := ReverseArray(arr)
for e, v in rarr
if (!hash.Haskey(v))
hash[(v)] := 1, newArr.push(v)
return ReverseArray(newArr)
}

ShellMessage( wParam,lParam ){
HSHELL_FLASH := 0x8006 ; 0x8006 is 32774 as shown in Spy!
if (wParam = HSHELL_FLASH){
global lastFlashWinIDs
hWnd := lParam
lastFlashWinIDs.Push(hWnd)
lastFlashWinIDs := arrayDistinctKeepTheLastOne(lastFlashWinIDs)
; lastFlashWinIDs.__Set(hWnd)
; WinGetTitle, this_title, ahk_id %hWnd%
; TrayTip, blinking, %this_title% is blinking
}
}
; activate
MousePosBackup(){
if(!T窗口增强_鼠标位置记忆)
return
CoordMode, Mouse, Screen
MouseGetPos, X, Y, hWnd, hWndCtrl
winMousePoses[hWnd] := [X, Y, hWndCtrl]
}
MousePosRestore(hWnd:=0){
if(!T窗口增强_鼠标位置记忆)
return
if(!hWnd)
WinGet, hWnd, id, A
if(winMousePoses[hWnd]){
X := winMousePoses[hWnd][1]
Y := winMousePoses[hWnd][2]
CoordMode, Mouse, Screen
; ToolTip, hwnd %hWnd%, %X%, %Y%
MouseMove, %X%, %Y%, 0
}
}

ActivateLastFlashWindow(){
MousePosBackup()
While % lastFlashWinIDs.Count(){
hWnd := WinExist("ahk_id " lastFlashWinIDs.Pop())
if (hWnd){
WinActivate, ahk_id %hWnd%
WinGetTitle, this_title, ahk_id %hWnd%
TrayTip, switched, switched to blinking %this_title%
MousePosRestore(hWnd)
Return
}
}
SendEvent {Blind}!{Esc}
Sleep 64
MousePosRestore()
}
Loading

0 comments on commit 4630ce4

Please sign in to comment.