Skip to content

Instantly share code, notes, and snippets.

@bestK

bestK/AutoHotkey Secret

Last active September 6, 2022 03:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bestK/8d9802cc55f46e5019bd26573f440608 to your computer and use it in GitHub Desktop.
Save bestK/8d9802cc55f46e5019bd26573f440608 to your computer and use it in GitHub Desktop.
AutoHotkey
;;;中文文档 https://wyagd001.github.io/zh-cn/docs/AutoHotkey.htm
;;; This script create by liu.kl
;Windows + I 打开 Idea
#I::
ifWinExist,ahk_exe idea64.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, C:\Program Files\JetBrains\IntelliJ IDEA 2021.2.3\bin\idea64.exe
Return
;Windows + T 打开 Notepad++
#T::
ifWinExist,ahk_exe notepad++.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, C:\Program Files\Notepad++\notepad++.exe
Return
;Windows + C 打开 Chrome
#C::
ifWinExist,ahk_exe chrome.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, C:\Program Files\Google\Chrome\Application\chrome.exe
Return
;Windows + P 打开 Postman
#P::
ifWinExist,ahk_exe Postman.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, C:\Users\WIN10\AppData\Local\Postman\app-9.14.0\Postman.exe
Return
;Windows + N 打开 Navicat for MySQL
#N::
ifWinExist,ahk_exe navicat.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, D:\navcat\Navicat Premium 15\navicat.exe
Return
;Windows + W 打开 微信
#W::
ifWinExist,ahk_exe WeChat.exe ;;;进程是否启动
winActivate ;;; 激活窗口
else
Run, C:\Program Files (x86)\Tencent\WeChat\WeChat.exe
Return
;按下ALT + ESC ,将窗口最小化
!Escape::
send, {lwin down}{down}
sleep 50
send, {lwin up}
return
;按下ALT + ` ,将窗口最大化
!`::
send, {lwin down}{up}
sleep 50
send, {lwin up}
return
; 获取窗体 class 信息
#g::
WinGetTitle, Title, A
msgbox,%title%
clipboard=%title%
return
;********************用Everything搜索选中文字***************************
!F::
send ^c
SplitPath, Clipboard, , , , OutNameNoExt ;
ifWinExist ahk_exe Everything.exe
{
WinActivate
ControlSetText, Edit1, %OutNameNoExt%, "Everything"
}
Else
{
Run D:\tools\Everything-1.4.1.1005.x86\Everything.exe -s "%OutnameNoExt%"
WinMaximize ahk_class EVERYTHING
}
Return
$F2:: AltTabMenu()
; F2 - IDEA 切换项目
AltTabMenu(){
list := ""
_IDEA_ :="idea" ;只显示IDEA
Menu, windows, Add
Menu, windows, deleteAll
WinGet, id, list
Loop, %id%
{
this_ID := id%A_Index%
WinGetTitle, title, ahk_id %this_ID%
If (title = "")
continue
If (!IsWindow(WinExist("ahk_id" . this_ID)))
continue
WinGet, Path, ProcessPath, ahk_id %this_ID%
if(!inStr(Path,_IDEA_))
continue
Menu, windows, Add, %title%, ActivateTitle
Try
Menu, windows, Icon, %title%, %Path%, , 0
Catch
Menu, windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
CoordMode, Mouse, Screen
MouseMove, (0.4*A_ScreenWidth), (0.35*A_ScreenHeight)
CoordMode, Menu, Screen
Xm := (0.25*A_ScreenWidth)
Ym := (0.25*A_ScreenHeight)
Menu, windows, Show, %Xm%, %Ym%
}
ActivateTitle:
SetTitleMatchMode 3
WinActivate, %A_ThisMenuItem%
return
;-----------------------------------------------------------------
; Check whether the target window is activation target
;-----------------------------------------------------------------
IsWindow(hWnd){
WinGet, dwStyle, Style, ahk_id %hWnd%
if ((dwStyle&0x08000000) || !(dwStyle&0x10000000)) {
return false
}
WinGet, dwExStyle, ExStyle, ahk_id %hWnd%
if (dwExStyle & 0x00000080) {
return falseR
}
WinGetClass, szClass, ahk_id %hWnd%
if (szClass = "TApplication") {
return false
}
return true
}
;press control+shift+r to reload
#5::
Msgbox, 是否确定重新加载当前脚本?
ifMsgBox, Yes
Reload
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment