此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 U: x$ p2 {/ ?5 O0 J# r5 @
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 J: l6 B4 f+ l- Q9 s
方式一:
" m6 {8 [" f/ j) m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 K+ u: S$ c U" T9 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( q0 i* P; t- d9 c1 b; O; S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ [" a2 [! W, X: L5 \3 z 方式二:% r8 V7 s q* [! c
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ }; P& X( B* M! B9 w( z
SetTitleMatchMode RegEx" O" @0 m0 G2 ~; ?0 W8 a V; }
return
& d# H3 u8 _! b7 V' |( Q+ N ; Stuff to do when Windows Explorer is open
" I7 r* J% X; N' A$ b7 m7 X% s- X ;; P& |7 h; s$ t2 o: d
#IfWinActive ahk_class ExploreWClass|CabinetWClass4 m; a* y5 j+ Z5 a3 f
; open ‘cmd’ in the current directory, L3 v; f" c2 B, ]$ w' O: \
;
0 x9 N6 k. L; i( U #c::
5 k D& p- b: ^8 j0 m2 Z OpenCmdInCurrent(), \2 u# S& [# ~3 ^
return
6 |* Z& H' l: p- K, @ #IfWinActive' u6 _0 E- R+ D2 W; y4 _' t* m, R
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." g: {" i& y4 f; A3 {
; Note: expecting to be run when the active window is Explorer.4 ~% `3 u$ e0 {' ?7 V0 u
;
- p8 C! ^$ S {* A0 m OpenCmdInCurrent()! b' R. j* v$ F" d: {! y
{& K ^, m1 Z2 \
; This is required to get the full path of the file from the address bar
6 Y0 B$ R* q: H$ K6 T5 K% O WinGetText, full_path, A
5 \; _% ^. i% r* s7 T# @ ; Split on newline (`n)( s1 [9 r* v& I, Z. O( v
StringSplit, word_array, full_path, `n& o* h8 P5 a# {0 ]# S( B! M( _2 s
; Take the first element from the array
7 s7 e4 f- F/ j, _1 D: _2 D full_path = %word_array1%, c; ?7 a+ K% g0 [7 I: w G
; strip to bare address& k9 m0 M1 E! W. F1 u: g; n
full_path := RegExReplace(full_path, “地址: “, “”)
& K4 h1 D' S4 f3 F$ t( s" B' V5 f; D/ v ; Just in case – remove all carriage returns (`r)5 C, L, v1 b) B3 x% W1 D$ i! h
StringReplace, full_path, full_path, `r, , all
# \- |) `4 h: O: z. F/ A3 A K IfInString full_path, \( @5 I6 }+ ^9 G) V! H# X
{2 ^# x4 H/ I! W& w* h
Run, cmd /K cd /D “%full_path%”
: }9 b1 _3 f. P" ^9 ^- [ }
) O; r7 C J+ C; ~3 q! C# W3 Y/ [; \ else
3 Y$ }" t: d" n9 R+ y, f. c {
& k: M* v8 ?9 I7 V4 f2 E) r Run, cmd /K cd /D “C:\ ”
; B2 o5 e$ T4 q/ t' @6 E/ `* u$ W }
, G4 B+ y$ p0 W, K }7 R2 k( b' ~) t' X
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 N6 D2 W4 O2 r/ B# o$ X. n" k! i7 r
这段小代码肯能有两个你需要修改的地方. f1 g; { h7 t. J- @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
: b' N1 y2 T+ E+ l/ M# [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, D6 t, `/ p! W/ n8 m
|