主要AHK脚本
github上的ahk脚本(实时更新): https://github.com/ngp320/my-ahk-scripts
;====安装使用介绍=
1 下载最新的 AutoHotkey (百度 或者 google)
2 运行 AHK Script Manager.ahk (也可以 右键 → 发送到桌面快捷方式)
3 推荐, 放入开机自启动:
①右键 AHK Script Manager.ahk → 发送到桌面快捷方式
②复制桌面快捷方式
③粘贴到 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\ 即可
p.s. 推荐给notepad++ 加一个ahk格式的语法高亮 AutoHotkey syntax highlighting in Notepad++
1 指定程序之间 的 快捷键切换,如果没打开则打开,如果打开了就切换到该程序。
非常好用,用起来很方便,用得最多的之一
;========================特殊功能区5: 程序切换区============================== ; #NoTrayIcon ;不显示托盘图标 ; Function to run a program or activate an already running instance RunOrActivateProgram(Program, WorkingDir="", WindowSize=""){ SplitPath Program, ExeFile Process, Exist, %ExeFile% PID = %ErrorLevel% if (PID = 0) { Run, %Program%, %WorkingDir%, %WindowSize% }else{ WinActivate, ahk_pid %PID% } } ;打开or切换谷歌浏览器 Alt+Z !z:: RunOrActivateProgram("C:\Program Files (x86)\Google\Chrome\Application\chrome.exe") return ;打开or切换notepad++ Alt+X !x:: RunOrActivateProgram("C:\Program Files\Notepad++\notepad++.exe") return ;打开or切换eclipse Alt+C !c:: RunOrActivateProgram("D:\0Software\eclipse\eclipse.exe") return ;打开or切换Typora ;之前只有Typora不灵,这种方式就可以诶 =。= 哇。。。知乎万岁 !v:: ;Alt+V DetectHiddenWindows, On SetTitleMatchMode, 2 WinGet, winid, ID, Typora ;MsgBox,%winid% SetTitleMatchMode, 1 If (winid) { WinWait, ahk_id %winid% WinShow WinActivate ControlFocus, EditComponent2, A ControlSetText, EditComponent2,, A }else{ ; RunOrActivateProgram("D:\Program Files\AliWangWang\AliIM.exe") RunOrActivateProgram("C:\Program Files\Typora\Typora.exe") } DetectHiddenWindows, Off return 2 notepad++快速打开文件(批量打开的话,选中文件夹再win+e)
一键拷贝文件路径
改成任何一种编辑器也行,修改这一段:
C:\Program Files\Notepad++\notepad++.exe
;=====================特殊功能区3: 复制/打开 文件路径区====================== ;#NoTrayIcon ;不显示托盘图标 Explorer_GetSelection(hwnd="") ;函数 { WinGet, process, processName, % "ahk_id" hwnd := hwnd? hwnd:WinExist("A") WinGetClass class, ahk_id %hwnd% if (process != "explorer.exe") return if (class ~= "Progman|WorkerW") { ControlGet, files, List, Selected Col1, SysListView321, ahk_class %class% Loop, Parse, files, `n, `r ToReturn .= A_Desktop "\" A_LoopField "`n" } else if (class ~= "(Cabinet|Explore)WClass") { for window in ComObjCreate("Shell.Application").Windows { try{ if (window.hwnd==hwnd) sel := window.Document.SelectedItems }catch e { continue } } for item in sel ToReturn .= item.path "`n" } return Trim(ToReturn,"`n") } ;[Win] + Z ;一键拷贝文件路径 ; #Z:: clipboard := % Explorer_GetSelection(hwnd) ;调用了 函数 Tooltip,%clipboard% ;在鼠标右侧显示【拷贝的文件路径】 Sleep,800 Tooltip, return ;一键用notepad++[打开选中的文件]or[选中文件夹]的所有子文件 ;路径中有空格就会很糟糕 【解决策略:加双引号就好,win自身的Program files也是有空格的】 ;[Win] + E #E:: path :=% Explorer_GetSelection(hwnd) ;调用了 函数 Software = C:\Program Files\Notepad++\notepad++.exe Run, %Software% "%path%" return 3 app-给potplayer发送Enter键
#NoTrayIcon ;不显示托盘图标 DetectHiddenWindows, On SetTitleMatchMode, 2 SetCapsLockState, AlwaysOff ;禁用CapsLock Return ;用一次CapsLock后,再用Alt+Tab切换 #IfWinExist ahk_exe PotPlayerMini64.exe ;~ 表示不影响原有按键 ;$ 表示,在Send包含自身时,用$可以防止重复自调用死循环 ~CapsLock:: { PotPlayer_id := WinExist("ahk_exe PotPlayerMini64.exe") WinGet, acive_id, ID, A ;获得当前窗口ID ;msgBox, %PotPlayer_id% ;msgBox, %acive_id% WinActivate,PotPlayer ;激活 PotPlayer_id ControlSend, ,{Space},ahk_id %PotPlayer_id% ;发送按键到PotPlayer64 WinActivate,ahk_id %acive_id% ;返回原来的窗口 return } #IfWinExist 4 Ctrl + C / V 增强, 显示复制或者剪切的内容
;==================================默认功能区2: CtrlC增强区====================================== #NoTrayIcon ;不显示托盘图标 ;显示 复制和剪切的内容 ~^x:: ~^c:: ;~ 表示次热键并不屏蔽按键原有功能 Sleep, 100 ;等待0.1s 强制机械等待剪贴板出现内容 ;clip:=clipboard StringLeft,clipboard_left,clipboard,500 Tooltip,%clipboard_left% ;在鼠标右侧显示clip(clipboard内容) Sleep,800 Tooltip, Return 5 每app-每日chrome书签备份
#NoTrayIcon ;不显示托盘图标 FormatTime, CurrentDateTime,, yyy-MM-dd_HH-mm-ss FileCreateDir, F:\0Software\chrome_bookmarks_backup FileCopy, C:\Users\ngp\AppData\Local\Google\Chrome\User Data\Default\Bookmarks, D:\00Software\chrome_bookmarks_backup\%CurrentDateTime%-Bookmarks_backup, 0 return 6 发送当前格式化时间
;===============================特殊功能区4: 特殊热字串区=================================== #NoTrayIcon ;不显示托盘图标 ;功能: 发送当前日期 ;简介: 利用剪贴板和正则匹配,在选中文本的行首加上注释符号 ;操作: 输入nnow+[一个空格] ;原因: Hexo经常要输入格式化的日期 ;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| :?:nnow:: ; 【?号表示在单词中也会替换,e.g. Vnnow → V2019.....】 FormatTime, CurrentDateTime,, yyy/MM/dd HH:mm Send %CurrentDateTime% return ::ppic:: FormatTime, CurrentDateTime,, yyy-MM-dd- Send %CurrentDateTime% tooltip, 2019-xx-xx-文章名|图片集名-图片序号 ;在鼠标右侧显示clipboard内容 sleep,2000 ;显示800ms tooltip, return 7 pro-禁用Numlock
;===============================默认功能区1: 键盘锁定区========================================== #NoTrayIcon ;不显示托盘图标 ;Set Lock keys permanently SetNumlockState, AlwaysOff ;on在笔记本上是mjkluio789是否变小键盘0~9,pc是永远开启小键盘功能(小键盘灯永远亮) Return 8 pro-禁用CapsLock LWin 慎重使用
;===============================默认功能区1: 键盘锁定区========================================== #NoTrayIcon ;不显示托盘图标 ;Set Lock keys permanently SetCapsLockState, AlwaysOff ;禁用CapsLock Return ; 屏蔽按下windows键弹出菜单功能 LWin::return 9 搜狗输入法快捷切换中英文, (配合loop可以设置成每2分钟自动切换为英文输入法)
; #NoTrayIcon ;不显示托盘图标 ;功能:输入法状态提示 ;f3强制中文 f4强制英文小写 ;环境:win10+搜狗输入法,输入法状态切换用默认的shift键。 ;作者:kazhafeizhale ;时间:2018年9月8日 ;参考来源 https://www.autoahk.com/archives/3278 ;如果安装有Snipaste,需要禁用f1以外的快捷键 #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. ; #Warn ; Enable warnings to assist with detecting common errors. SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #SingleInstance force ;startuplnk := A_StartMenu . "\Programs\Startup\自动化集合.lnk" ; Menu, Tray, Add, 开机启动,AutoStart ; if(FileExist(startuplnk)) ; Menu, Tray, Check, 开机启动 ; return ; AutoStart: ; if(FileExist(startuplnk)) ; FileDelete, % startuplnk ; else ; FileCreateShortcut, % A_ScriptFullpath, % startuplnk ; Menu, Tray, ToggleCheck, 开机启动 ; return XButton1::^c XButton2::^v F3:: SetCapsLockState,off switchime(0) switchime() return F4:: SetCapsLockState,off switchime(0) return ;capslock强制英文大写 ; CapsLock:: ; SetCapsLockState,on ; return switchime(ime := "A") { if (ime = 1){ DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,"00000804", UInt, 1)) }else if (ime = 0) { DllCall("SendMessage", UInt, WinActive("A"), UInt, 80, UInt, 1, UInt, DllCall("LoadKeyboardLayout", Str,, UInt, 1)) }else if (ime = "A") { ;ime_status:=DllCall("GetKeyboardLayout","int",0,UInt) Send, #{Space} } }