此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; E) R* C2 r* ? I9 z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 W" L3 g- G$ r" W3 R 方式一:' C* j6 R+ q# ?- K( p, f, R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ Y9 Y# i+ I6 ?0 L1 ?8 e" D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 J# z/ y/ c+ s6 J. R6 t& d. u8 Y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- i. K4 B% G/ j 方式二:
4 c. o1 j9 Z! D3 x8 u$ [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:# e1 g3 O4 k0 u* q: ?, ?; }& y- I4 W
SetTitleMatchMode RegEx* A. k5 T- w( F$ S' Y& z* L2 I/ z
return% `4 k8 } v- A- v* B
; Stuff to do when Windows Explorer is open$ |9 y* g0 k t, y; A
;+ d: b$ b# ~5 c9 w* e
#IfWinActive ahk_class ExploreWClass|CabinetWClass
, {; a3 c: h! h6 E4 K y f) ~5 g ; open ‘cmd’ in the current directory
" i. z+ k# Q6 n8 S ;: s8 o* X0 k$ X* Z, k2 ]+ j2 M
#c::1 L6 \6 ^2 B ]2 m8 ?
OpenCmdInCurrent()
& J( `' L( n6 d- b# G" P return3 B' b0 p# ?. o5 H( }2 |8 n
#IfWinActive: C7 \1 O7 ]/ c8 V6 W! h
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
& @* ^' M: r; `, { ; Note: expecting to be run when the active window is Explorer.) z% Y% N0 Z% w( G
;
; l: W" g% w2 Z; R7 L3 [3 }0 M OpenCmdInCurrent(); v. N ?$ L$ ?% W( m
{/ f u, m, Q: a& c4 j2 d& U' s
; This is required to get the full path of the file from the address bar
% I: a2 y4 I( v9 B" L; t# g, t' ` WinGetText, full_path, A4 `) y" }9 f0 Y4 x! U
; Split on newline (`n)
* {; e; v2 |/ ^! _0 G N StringSplit, word_array, full_path, `n# d6 v: I- O" t2 ~9 t7 ~- i0 _
; Take the first element from the array/ r _* H; A9 w& r
full_path = %word_array1%
( ~/ z- W X; J2 ], H0 B+ c" x ; strip to bare address
$ Z/ ~, i7 V: v+ R/ D! v full_path := RegExReplace(full_path, “地址: “, “”)
3 N' S6 p' c. x, S' P7 I7 u: I ; Just in case – remove all carriage returns (`r)1 `3 y* E2 X n( W7 s8 `$ E
StringReplace, full_path, full_path, `r, , all
0 B. {1 n, t- x. ? IfInString full_path, \
2 `; t7 T# t+ a$ Z" o4 T& S {
) a- o1 F/ ?( f; j# S) b# a% e Run, cmd /K cd /D “%full_path%”8 F) [) D( l. C% Q3 M/ c
}
) g+ K% i5 D5 } else" `. `7 z, |5 S# F) [
{6 z5 M! }0 C+ N$ L$ D) \
Run, cmd /K cd /D “C:\ ”
1 \) Y. o3 p% z1 \& {# N }
. l+ a, e! w; ^* q( r; P3 q) a% } }, B3 [ c, ]3 C7 a* W1 J; g
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: ^- ^8 x3 c0 d
这段小代码肯能有两个你需要修改的地方
$ Z# Z5 H, P: X4 u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ L3 s$ ~, X' ` p 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ n/ g* c/ d1 h% Z! r: w
|