此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 T( E% ?3 R1 r& a) I/ s f5 l3 H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 g5 C* E' a( Y' |+ n 方式一:) O: g E& z! V" O- K) U+ r6 A7 G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 L h8 b+ n' a* d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% c& H4 e3 g# b2 n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。9 S, b5 n# h m9 t
方式二:
7 g1 }6 h, A+ U8 u: ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:) e+ k6 y8 P+ ~2 S, J& Y
SetTitleMatchMode RegEx. _( I4 |1 o9 ]8 _$ ~2 W
return/ L- t- |& u9 D5 r0 ^
; Stuff to do when Windows Explorer is open
' p$ A8 W/ n. Z ;# H. I+ L7 A* Z: J% k& A* r& t
#IfWinActive ahk_class ExploreWClass|CabinetWClass: S- f3 @/ K: @7 k. g3 [% g) p Q
; open ‘cmd’ in the current directory
/ M$ V9 r( ?1 r( {9 a) P ;
& a4 z0 B: O1 D8 q/ U! Q B #c::3 J, `, d1 W. y- |! q q1 j, P* n W
OpenCmdInCurrent()& M& g2 X6 c/ f" n* }; K5 U
return
- ]: Y# n4 w% v6 S( N #IfWinActive6 X' V& f0 v2 c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 C/ P5 o9 w" ^" Z/ x+ T2 ~ ; Note: expecting to be run when the active window is Explorer.
. T0 d& ^5 G6 }. Q4 n+ P ;
; B3 j7 h; f" |. `% F/ A- [ OpenCmdInCurrent()
8 C" E0 h& U& e3 w( n. Z {
2 }( e4 F$ v4 V2 \& R ; This is required to get the full path of the file from the address bar- L/ X' x- |! R7 q+ ]
WinGetText, full_path, A2 q) \- L* R" D9 M% F! G; F
; Split on newline (`n)
l$ C5 z( W5 G4 N. N- r6 f+ I' _ E StringSplit, word_array, full_path, `n
# T% \- W. f0 t* f, ^# Q" d4 H& m ; Take the first element from the array
' ~) s2 |% t) l full_path = %word_array1%
# l8 B, Y- ?; w ; strip to bare address) W! v# D# k' W4 M/ f) k) ~
full_path := RegExReplace(full_path, “地址: “, “”)
4 F" \. X1 ]7 X+ W; ` ; Just in case – remove all carriage returns (`r)& u) Q4 d" w( r2 } y, A- b
StringReplace, full_path, full_path, `r, , all
! w) R8 V2 N: c" j1 |5 e) c IfInString full_path, \
: f; N1 O4 |, ]/ N9 r {/ v0 s. v( y, Q! h
Run, cmd /K cd /D “%full_path%”
+ i1 s7 D. e5 b }2 e, `1 j. r h' Q; ?
else
; U2 Q3 j, B+ ?9 q {9 A3 R! ~4 ~5 D6 E8 j3 l5 y0 e4 o
Run, cmd /K cd /D “C:\ ”
1 ^: }$ Z! V* Q }
; B. h6 l' K$ ?, Q }' K! T' X4 I8 r O- a
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* m! `" k5 L' b7 V7 O. a 这段小代码肯能有两个你需要修改的地方& @$ o# z* g! A" s
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ y! T, i3 B* T. I6 F6 ~ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 X9 J% v1 g+ _ |