此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, P- y( U; a$ g& v( Z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* N; T0 ^& t, e& Y 方式一:- E$ N$ |: I9 h& v/ ^% _6 A
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
& a; U( J, b. `9 G2 x3 g 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 {- v/ t3 w" D* T% |- Y. R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 y8 t4 q+ T$ D0 Q% R% u* J 方式二:
- L( N" J5 f4 f. k+ ?0 }" I5 I5 G 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; L+ d: v# y. _' o. W }; `0 G1 N4 z
SetTitleMatchMode RegEx9 v, I7 O3 u/ }9 S) c
return L/ ?9 \% ]! n. y
; Stuff to do when Windows Explorer is open
( ^) t% a( S( C+ V! l7 g ;. i) b! o9 g( p. j; z/ o
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 A' E' f' S7 A7 p* C; Y+ L
; open ‘cmd’ in the current directory
, k& @9 g X# h( u7 D ;( V3 m1 B+ ?& n7 y# v# F
#c::- O/ t! S! }% ^$ G: V0 d( g5 X" q: z
OpenCmdInCurrent()
# _2 E/ W( L- P" `! k return: v1 U+ \( b1 M- ]+ }
#IfWinActive
& H+ k ?; {; m4 L5 G, c/ T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer. X2 p5 R4 x: s1 N4 [& O; L
; Note: expecting to be run when the active window is Explorer.7 H: f3 n# B ]5 a
;- _- [! v6 O( m" X( l6 A$ A) L& _. m
OpenCmdInCurrent()
' s! |, I3 ]& f2 o! E: `( V) y {
3 H2 l" ^' `" x8 W( J% c3 f ; This is required to get the full path of the file from the address bar
, J3 n. Q2 E% |/ e* Q WinGetText, full_path, A, @/ J% I' ~# Y- B& H$ l
; Split on newline (`n)
- r2 M; `, K4 o; m* C StringSplit, word_array, full_path, `n- g* |5 r- L" ]. {, B) `8 B
; Take the first element from the array1 E7 L" ]! i" B$ O2 g
full_path = %word_array1%; D6 b- {1 R+ v
; strip to bare address- P" t% E0 E+ H% O. n
full_path := RegExReplace(full_path, “地址: “, “”)3 ]; x. {. s" Z+ l
; Just in case – remove all carriage returns (`r); w: t& s2 b* V
StringReplace, full_path, full_path, `r, , all5 K6 c5 ` `) j3 z
IfInString full_path, \
9 Q( X4 w9 ]& F R6 m4 v {8 s+ A3 K, I* i; P
Run, cmd /K cd /D “%full_path%”; {6 e# G, q" q/ u5 ^' ]" K
}& P6 I2 u( K: \" `' f
else
; {. r% `5 R& } i$ e! Y {, ]3 Q! F) J1 c
Run, cmd /K cd /D “C:\ ”
: T# ~$ G' d- y }% ~: N# f# Y( X* I) c
}
/ h" H( u% R }- _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! r2 l1 I/ [' l 这段小代码肯能有两个你需要修改的地方 T @1 u: w- t C- O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% b, K; W1 `3 C! v7 \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, B0 _4 m, D$ F. c m; e6 H: I+ O |