Created
December 22, 2024 00:40
-
-
Save yoonbae81/0f8d4ee32eab4c8dad0a31454e3f0ef7 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
| #Requires AutoHotkey v2.0 | |
| #SingleInstance force | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Hotkey Modifier Symbols | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; # WIN | |
| ; ! ALT | |
| ; ^ CTRL | |
| ; + SHIFT | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Hotkey Definitions | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| #f:: SwitchToNextInstance() | |
| #+f::SwitchToPrevInstance() | |
| #+q::Activate("C:\Program Files\Everything 1.5a\Everything64.exe") | |
| #+w::Activate("C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe") | |
| #+e::WinExist('ahk_class CabinetWClass') ? WinActivate() : Run('Explorer.exe') | |
| #+r::Reload() | |
| #+t::Activate("C:\Program Files\PuTTY\PuTTY.exe") | |
| #+o::Activate("C:\Program Files\Obsidian\Obsidian.exe") | |
| #+d::ActivateStoreApp("Microsoft To Do") | |
| #+g::Activate(EnvGet("LOCALAPPDATA") . "\GitHubDesktop\GitHubDesktop.exe") | |
| #+h::Activate("C:\Program Files (x86)\Hnc\HOffice9\Bin\hwp.exe") | |
| #+x::Activate("Cmd.exe") | |
| #+c::ActivateStoreApp("계산기") | |
| #+v::ActivateStoreApp("Visual Studio Code") | |
| #+n::Activate("C:\Program Files\HeyNote\HeyNote.exe") | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| ; Functions (No need to read or change) | |
| ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
| Activate(programPath) { | |
| if WinExist("ahk_exe " . programPath) | |
| WinActivate | |
| else | |
| Run programPath | |
| } | |
| ActivateStoreApp(appName) { | |
| SetTitleMatchMode 2 | |
| if WinExist(appName) | |
| WinActivate | |
| else { | |
| for app in ComObject('Shell.Application').NameSpace('shell:AppsFolder').Items | |
| if (app.Name = appName) | |
| RunWait('explorer shell:appsFolder\' app.Path) | |
| } | |
| } | |
| SwitchToNextInstance() { | |
| activeExe := WinGetProcessName("A") | |
| SetTitleMatchMode "RegEx" | |
| instances := WinGetList("ahk_exe " activeExe,, "Program Manager", "Shell_TrayWnd|SysShadow") | |
| instances := SortArray(instances) | |
| if instances.Length < 2 | |
| return | |
| currentHwnd := WinGetID("A") | |
| currentIndex := 0 | |
| for index, hwnd in instances { | |
| if hwnd == currentHwnd { | |
| currentIndex := index | |
| break | |
| } | |
| } | |
| if currentIndex > 0 { | |
| nextIndex := Mod(currentIndex, instances.Length) + 1 | |
| WinActivate("ahk_id " instances[nextIndex]) | |
| } | |
| } | |
| SwitchToPrevInstance() { | |
| activeExe := WinGetProcessName("A") | |
| SetTitleMatchMode "RegEx" | |
| instances := WinGetList("ahk_exe " activeExe,, "Program Manager", "Shell_TrayWnd|SysShadow") | |
| instances := SortArray(instances) | |
| if instances.Length < 2 | |
| return | |
| currentHwnd := WinGetID("A") | |
| currentIndex := 0 | |
| for index, hwnd in instances { | |
| if hwnd == currentHwnd { | |
| currentIndex := index | |
| break | |
| } | |
| } | |
| if currentIndex > 0 { | |
| prevIndex := Mod(currentIndex - 2 + instances.Length, instances.Length) + 1 | |
| WinActivate("ahk_id " instances[prevIndex]) | |
| } | |
| } | |
| SortArray(arr) { | |
| str := "" | |
| for value in arr | |
| str .= value . "`n" | |
| sortedStr := Sort(RTrim(str, "`n")) | |
| return StrSplit(sortedStr, "`n") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment