此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- @) s8 f4 H7 L$ I% X6 ]3 N8 ^
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 h1 C3 N4 Y( q6 i* e5 ^! | 方式一:
/ L- `! \" ]+ L# K/ D; r 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: H5 ?/ r8 c$ u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) y! F- U) z$ J* G: p/ }5 D
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 }7 J% E4 W& ?* i 方式二:
4 c7 H. g* l6 H% c" x0 L7 j3 P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 D: t5 D; B; T, I
SetTitleMatchMode RegEx, ^: @* \4 v! d* R4 f1 J# E
return
$ S0 u: `% e2 F- ?0 ]/ X! } ; Stuff to do when Windows Explorer is open
% ^. I; r, _6 v3 Y6 ]) ^% G" w0 N$ _ ;
- ?* k5 I$ Q* \. T, C5 V% C, \ #IfWinActive ahk_class ExploreWClass|CabinetWClass9 G( p8 G. g( D7 t, C( h1 B$ \
; open ‘cmd’ in the current directory" `5 D0 ?8 ^' j; W
;8 f* ?7 V* Z0 a P4 }
#c::/ b# }& o T; V. L4 e
OpenCmdInCurrent(); V8 R, k) D( f: `8 u" {
return
2 E. u; p) b2 d; l$ X2 C& |5 W #IfWinActive2 P/ P$ b5 U/ a2 s2 y8 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 G" ? Y+ z7 n' \6 n! F4 g+ K! x ; Note: expecting to be run when the active window is Explorer.- }% Y7 j8 Y8 F! y u
;
. ^8 u+ @$ z$ W0 G2 ^: Q OpenCmdInCurrent()
/ V r: N7 K# B3 d8 w# I; ~! i8 k- T {
. m5 J; d: U f ; This is required to get the full path of the file from the address bar
# t/ p# F& m( J WinGetText, full_path, A( u3 A7 {' T( z' Q9 b
; Split on newline (`n)
o* _! d7 G1 a5 v StringSplit, word_array, full_path, `n
% s1 ^# w% A { ; Take the first element from the array# m* v- D/ }& T; @/ g
full_path = %word_array1%
1 j; R, `' ~& l/ P8 G, A6 ? ; strip to bare address7 T4 g6 m! d$ U& ?; F* I
full_path := RegExReplace(full_path, “地址: “, “”)6 {# R8 K: |# a9 \ x+ C' l/ {
; Just in case – remove all carriage returns (`r)4 q& x w- O/ N- b: ^
StringReplace, full_path, full_path, `r, , all
* ?1 |3 v. g* B* r( z+ o6 | IfInString full_path, \
% F$ ?; {7 H5 r, i8 F {( T3 `2 Z- l( Y" ^4 j4 x( B
Run, cmd /K cd /D “%full_path%”
: l( o- P# _7 [# Y( |" H }& U' ^9 Q' h8 R, h- ^8 I
else
- D" H1 u% I! B+ g+ i( u {8 N5 w+ Y4 k: }9 B* e9 l! j0 }
Run, cmd /K cd /D “C:\ ”
' ]2 P+ d: p0 D, ^1 a7 I9 s }" X) ^1 C$ W4 F7 G* ]
}3 L4 `3 L& c0 O Q
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% Y1 s% t0 Z! Y* A: ~6 R; C 这段小代码肯能有两个你需要修改的地方# m: c- y" Z% s/ z- G( z# h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! p+ _& a, v, _# ^3 _2 L+ S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
7 p1 ^) s8 P: ~) E3 `* H2 x$ S+ y: t |