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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
;; -> init
ShellApp := ComObjCreate("Shell.Application")
GroupAdd, Explorer, ahk_class CabinetWClass
GroupAdd, Explorer, ahk_class ExploreWClass
GroupAdd, Desktop, ahk_class Progman
GroupAdd, Desktop, ahk_class WorkerW
GroupAdd, ExplorerDesktop, ahk_class CabinetWClass
GroupAdd, ExplorerDesktop, ahk_class ExploreWClass
GroupAdd, ExplorerDesktop, ahk_class Progman
GroupAdd, ExplorerDesktop, ahk_class WorkerW
;; -> library
Explorer(hwnd := "")
{
global ShellApp
if (hwnd = "")
WinGet, hwnd, id, A
for window in ShellApp.Windows
if (window.hwnd = hwnd)
return window
return -1
}
ExplorerPath()
{
WinGetClass, cls, A
if (cls = "Progman" or cls = "WorkerW")
return %A_Desktop%
else
return Explorer().Document.Folder.Self.path
}
;; -> body
;; Explorer/Desktop hotkeys ---------------------------------------------------
#IfWinActive ahk_group ExplorerDesktop
; Open new window/command prompt
^n::Run, % "explorer /n,""" ExplorerPath() """"
^p::Run, % "cmd /k cd /d """ ExplorerPath() """"
+^p::
path := ExplorerPath()
Run, % "C:\Documents and Settings\All Users\Start Menu\Programs\Microsoft Visual Studio 2010 Express\Visual Studio Command Prompt (2010).lnk"
WinWait, ahk_class ConsoleWindowClass
SendInput, % "cd " path "{Return}"
return
; Create new folder/file
^+n::
FileCreateDir, % ExplorerPath() "\New Folder"
SendInput, {F5}New Folder{F2}
return
^!n::
FileAppend,, % ExplorerPath() "\New Text Document.txt"
SendInput, {F5}New Text Document.txt{F2}
return
;; Explorer hotkeys -----------------------------------------------------------
; Edit file
#IfWinActive
LWin & LButton::
MouseGetPos,,, hwnd
DllCall("SetForegroundWindow", "UInt", hwnd)
if (not DoubleClick()) ; see tt.doubleclick.ahk
return
if (not WinActive("ahk_group Explorer"))
{
SendInput, {Click}
return
}
; fall through to next hotkey
#IfWinActive ahk_group Explorer
#NumPadEnter::
#Enter::
i := Explorer().Document.FocusedItem
if (i.IsFolder)
return
ShellApp.ShellExecute(i.path, "", "", "Edit", 1)
return
; Directory navigation
LAlt & Up::
RAlt & Up::
e := Explorer()
path := e.Document.Folder.Self.path
if (InStr(path, "::{") = 1)
return
slash := InStr(path, "\", 0, 0)
if (slash = StrLen(path))
slash := InStr(path, "\", 0, 0, 2)
if (slash = 0)
parent = ::{20D04FE0-3AEA-1069-A2D8-08002B30309D} ; My Computer
else
parent := SubStr(path, 1, slash)
e.Navigate(parent)
return
LAlt & Down::
RAlt & Down::
path := ExplorerPath()
if (InStr(path, "::{") = 1)
return
Explorer().Navigate(path) ; go to real path of folder
return
; Toggle hidden status
^h::
SSF_SHOWALLOBJECTS := 0x0001
VarSetCapacity(SHELLSTATE, 32, 0)
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", SSF_SHOWALLOBJECTS, "Int", false)
NumPut(NumGet(SHELLSTATE) ^ (1 << 0), SHELLSTATE,, "Int")
DllCall("Shell32\SHGetSetSettings", "Ptr", &SHELLSTATE, "UInt", SSF_SHOWALLOBJECTS, "Int", true)
WinGet, win, List, ahk_group Explorer
Loop, % win
PostMessage, 0x111, 41504,,, % "ahk_id " win%A_Index% ; refresh
return
; Sort and display options
^q::ExplorerFolderView("name")
^w::ExplorerFolderView("modified")
^e::ExplorerFolderView("type")
^t::ExplorerFolderView("created")
^g::ExplorerFolderView("groups")
^s::ExplorerFolderView("tiles")
^d::ExplorerFolderView("icons")
^+d::ExplorerFolderView("thumbnails")
^f::ExplorerFolderView("details")
^+f::ExplorerFolderView("list")
^!q::ExplorerFolderView("name", true)
^!w::ExplorerFolderView("modified", true)
^!e::ExplorerFolderView("type", true)
^!t::ExplorerFolderView("created", true)
^!g::ExplorerFolderView("groups", true)
^!s::ExplorerFolderView("tiles", true)
^!d::ExplorerFolderView("icons", true)
^!+d::ExplorerFolderView("thumbnails", true)
^!f::ExplorerFolderView("details", true)
^!+f::ExplorerFolderView("list", true)
#IfWinActive
;; -> library
ExplorerFolderView(view, children := false)
{
if (view = "name")
n := {m: 30210, d: -1}
else if (view = "modified")
n := {m: 30213, d: -1}
else if (view = "type")
n := {m: 30212, d: -1}
else if (view = "created")
n := {m: 30214, d: -1}
else if (view = "groups")
n := {m: 30209, d: -1}
else if (view = "tiles")
n := {m: 28718, d: 6}
else if (view = "icons")
n := {m: 28713, d: 1}
else if (view = "thumbnails")
n := {m: 28717, d: 5}
else if (view = "details")
n := {m: 28716, d: 4}
else if (view = "list")
n := {m: 28715, d: 3}
PostMessage, 0x111, % n.m, 0,, A ; change current folder
return
if (not children or m.d = -1)
return
old := A_BatchLines
SetBatchLines, -1
Loop, Files, % ExplorerPath() "\*", D
{
MsgBox, % A_LoopFileFullPath
}
SetBatchLines, % old
}
|