-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlauncher.ahk
More file actions
118 lines (96 loc) · 2.54 KB
/
launcher.ahk
File metadata and controls
118 lines (96 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/**
* Tested by dufferZafar on Windows 8 Pro Build 9920
*/
#SingleInstance Force
/**
* Configure your paths
*/
CmderPath := "F:\Winterm\"
FavDir := "F:\Projects-top\"
; This variable is used by the init script of the Cmder project
EnvSet, CMDER_ROOT, %CmderPath%
/**
* Real Code Starts
*
* AHK newbies stay away :p
*/
; Create a group of windows
; Note: Groups are used to club different windows together
GroupAdd, Explorer_Group, ahk_class CabinetWClass
GroupAdd, Explorer_Group, ahk_class ExploreWClass
GroupAdd, Desktop_Group, ahk_class WorkerW
; Attach hotkeys
Hotkey, !^c, RunCmder
Hotkey, !^x, RunBash
Return
; End of Auto-Execute section
/**
* Opens command prompt in the current folder.
*/
RunCmder:
Path := GetPath()
Run, %CmderPath%/vendor/conemu/ConEmu64.exe /Single /Dir "%Path%" /Title Cmder /Icon "%CmderPath%\Cmder.ico" /LoadCfgFile "%CmderPath%\config\ConEmu.xml"
Return
RunBash:
Path := GetPath()
Run, %CmderPath%/vendor/conemu/ConEmu64.exe /Single /Dir "%Path%" /Title Cmder /Icon "%CmderPath%\Cmder.ico" /LoadCfgFile "%CmderPath%\config\ConEmu.xml" /cmd %CmderPath%\vendor\msysgit\bin\sh.exe -l -i
Return
GetPath() {
Global FavDir
If WinActive("ahk_class PX_WINDOW_CLASS")
{
FilePath := GetPathFromSublime()
SplitPath, FilePath, , Dir ; The Directory
}
Else
Dir := GetCurrentFolderPath()
Dir := (Dir = "") ? FavDir : Dir
Return Dir
}
/**
* Extracts the current file's path from sublime text.
*/
GetPathFromSublime() {
WinGetTitle, wTitle, ahk_class PX_WINDOW_CLASS
; wTitle := "D:\I, Coder\@ GitHub\win-butler\Test.ahk (WinButler) - Sublime Text"
StringTrimRight, File, wTitle, 15
If FileExist(File)
ScriptPath := File
Else
{
pos := InStr(wTitle, "(", False, 0)
ScriptPath := SubStr(wTitle, 1, pos-1)
}
Return %ScriptPath%
}
/**
* Get the path of currently open folder.
*
* Use Path := (Path = "") ? "C:\" : Path
* to handle exceptions and set a default path
*
* Todo: Handle CLSID for special folders
*/
GetCurrentFolderPath() {
If WinActive("ahk_group Explorer_Group")
{
hWnd := WinExist("A")
shellApp := ComObjCreate("Shell.Application")
for Item in shellApp.Windows
{
If (Item.hwnd = hWnd)
{
sfv := Item.Document ; ShellFolderView
path := sfv.Folder.Self.Path
}
}
If InStr(path, ".library-ms")
Return ""
Else
Return path
}
Else If WinActive("ahk_group Desktop_Group")
Return %A_Desktop%
Else
Return ""
}