此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
! Y! S- g/ V1 a, s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 j$ c, N+ r" N2 w7 i 方式一:
! ?( L+ e% N% G j8 b. ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) E" H) @( Z0 O2 M% x R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; q2 d a. r( n& ?1 k6 ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 K! N+ T" w4 T- Y0 Y% X; x 方式二:' I! g5 _, n% O' \ z8 ^# j* f
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! |$ R: U7 i- V
SetTitleMatchMode RegEx$ w+ D/ v2 a7 H) t s# e
return' B- q7 z) c0 J# G* b
; Stuff to do when Windows Explorer is open
5 Y5 f$ s/ J1 x9 H# ?7 v! o ;8 r1 v9 f/ [4 {" }& K% [" V: h
#IfWinActive ahk_class ExploreWClass|CabinetWClass" o/ Z2 h& ^) ]; c4 `& @
; open ‘cmd’ in the current directory& |7 @. B4 f& B, S$ m/ L4 R
;5 ]7 H. U+ z" l9 f
#c::7 _# s6 K/ }; f/ Q
OpenCmdInCurrent()2 e; f: E! D+ N$ E* v ?* {/ D" y
return
/ q$ D+ ]' I. ^) T7 C+ P #IfWinActive' o2 K4 j. n O% n: p5 P
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' c/ o% u! K* n; }+ z
; Note: expecting to be run when the active window is Explorer.+ h3 \1 Y7 g. }% e7 C! Y
;
2 R R: O' A, H5 N+ A OpenCmdInCurrent()
8 g. e0 h0 t9 U {' B" G# B9 m+ \
; This is required to get the full path of the file from the address bar" h& D( m/ U3 t5 {% _
WinGetText, full_path, A- l( c( E" a& I/ X& q- e
; Split on newline (`n)3 Z3 D: _; p+ A
StringSplit, word_array, full_path, `n
" w6 f/ t c$ |' L+ h! ? ; Take the first element from the array: ^3 \$ [" P$ a' k: k' M/ |# u
full_path = %word_array1%3 a$ T* `' P2 N2 V6 Z( D$ u( y
; strip to bare address5 |" T9 b2 F. m8 C3 v7 ?
full_path := RegExReplace(full_path, “地址: “, “”)7 Y9 q% K7 q: D2 n% G
; Just in case – remove all carriage returns (`r)
$ j% L% A4 t# C% W% ?/ p! A StringReplace, full_path, full_path, `r, , all
& M3 F L1 I2 P# V! p( b2 D# R IfInString full_path, \
3 z& D9 `( z/ |# z, r8 }' ^6 L {
5 _. w1 N2 B: E Run, cmd /K cd /D “%full_path%”
9 h; @- k7 Z6 H% ]: s7 h4 L" `4 | }, R5 W0 X' j9 P5 y2 K: w
else
" W0 F: g* N% L5 E; g6 i5 h {
1 N4 m3 M% s2 F- y: ~3 [; m: D Run, cmd /K cd /D “C:\ ”7 [- }- L+ v. v& X8 X& X: N
}( E! k5 u! {. w/ ?' c
}
- Y& p' F0 t, ~- n# p 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 ^. O; ^) p7 ^# w3 l3 P 这段小代码肯能有两个你需要修改的地方
- o; k# s! |* S8 P3 j8 | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- [& G( V( v) B' @ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ F2 _& c4 [+ L( _- c4 b |