Created
June 8, 2022 01:36
-
-
Save ZhouMoon/8dc279b25cc171a66ded1c71e78c7fae to your computer and use it in GitHub Desktop.
AutoHotKey 代码片断分享
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; 快捷键 | |
| ; Google Chrome | |
| Esc & g:: | |
| Activate_Class.chrome() | |
| Return | |
| ;飞书 | |
| Esc & 1:: | |
| Activate_Class.feiShu() | |
| return | |
| ;VS Code | |
| Esc & 4:: | |
| Activate_Class.vsCode() | |
| return | |
| ;有道词典 | |
| Esc & 5:: | |
| Activate_Class.youDao() | |
| return | |
| ; Windows Terminal | |
| Esc & 8:: | |
| Activate_Class.terminal() | |
| return | |
| ; 程序激活class | |
| class Activate_Class{ | |
| chrome(){ | |
| ; Send #1 | |
| IfWinNotExist ahk_exe chrome.exe | |
| { | |
| Send {Blind}{LWin Down}1{LWin Up} | |
| } | |
| Else IfWinNotActive ahk_exe chrome.exe | |
| { | |
| ; #WinActivateForce | |
| ; GroupActivate, CHROME_GROUP, r | |
| ; return | |
| ; Send #1 | |
| ; 支持正则匹配Title | |
| ; 我不想查询所有桌面的窗口, 这里用了off | |
| DetectHiddenWindows, off | |
| SetTitleMatchMode RegEx | |
| chromeID := WinExist("- Google Chrome$") | |
| #WinActivateForce | |
| WinActivate ahk_id %chromeID% | |
| } | |
| Else | |
| { | |
| ; #WinActivateForce | |
| ; GroupActivate, CHROME_GROUP, r | |
| ; return | |
| ; WinMinimize | |
| ; send {CtrlDown}{ShiftDown}{a}{CtrlUp}{ShiftUp} | |
| send ^+a | |
| } | |
| return | |
| } | |
| ; | |
| ; 飞书 | |
| feiShu(){ | |
| IfWinNotExist ahk_exe Feishu.exe | |
| { | |
| Run C:\Users\moon\AppData\Local\Feishu\app\Feishu.exe | |
| } | |
| Else IfWinNotActive ahk_exe Feishu.exe | |
| { | |
| ; 支持正则匹配Title | |
| SetTitleMatchMode RegEx | |
| UniqueID := WinExist("^飞书$") | |
| #WinActivateForce | |
| WinActivate ahk_id %UniqueID% | |
| } | |
| Else | |
| { | |
| WinMinimize | |
| } | |
| return | |
| } | |
| ; vsCode | |
| vsCode(){ | |
| IfWinNotExist ahk_exe Code.exe | |
| { | |
| Send !{Space} | |
| Sleep, 300 | |
| SendInput, vsc | |
| Sleep, 300 | |
| Send {Enter} | |
| } | |
| Else IfWinNotActive ahk_exe Code.exe | |
| { | |
| ; 支持正则匹配Title | |
| SetTitleMatchMode RegEx | |
| VS_CODE_ID := WinExist(".- Visual Studio Code") | |
| ; #WinActivateForce | |
| WinActivate ahk_id %VS_CODE_ID% | |
| } | |
| Else | |
| { | |
| WinMinimize | |
| } | |
| return | |
| } | |
| ; | |
| ; 有道词典 | |
| youDao(){ | |
| IfWinNotExist ahk_class YodaoMainWndClass | |
| { | |
| Run D:\Program Files\Dict\Application\YodaoDict.exe | |
| } | |
| Else IfWinNotActive ahk_class YodaoMainWndClass | |
| { | |
| WinActivate | |
| } | |
| Else | |
| { | |
| ; WinClose | |
| WinMinimize | |
| } | |
| return | |
| } | |
| ; | |
| ; Terminal | |
| terminal(){ | |
| IfWinNotExist ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
| { | |
| Send !{Space} | |
| Sleep, 300 | |
| SendInput, 终端 | |
| Sleep, 300 | |
| Send {Enter} | |
| Sleep, 300 | |
| Send {Enter} | |
| } | |
| Else IfWinNotActive ahk_class CASCADIA_HOSTING_WINDOW_CLASS | |
| { | |
| WinActivate | |
| } | |
| Else | |
| { | |
| WinMinimize | |
| } | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment