此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& O+ H, X# c0 @7 x3 }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 `2 R9 p6 H; i+ L$ Q* e" ` 方式一:
1 \8 R( o" M; N" ?* L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,0 r" e$ N, r5 M8 c
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 B8 t4 \# c3 _( z4 y8 V9 Y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ x. Z- U4 ~1 f) h! W7 F. c# l, ]
方式二:
$ q! F/ s" }4 ~! u+ t9 v1 ` 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; f3 R) G& O4 M% t0 o. x SetTitleMatchMode RegEx# h; `1 X7 J5 E' G2 l! b
return
' O. J- y& k4 X* O ; Stuff to do when Windows Explorer is open( l l# q- R5 T1 S/ l
;
" V4 Y! ^2 m& u" S% A. ^! }2 N9 F# ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ o: t* S# W& F) |0 N6 K ; open ‘cmd’ in the current directory
: \0 f0 O# h/ [ ;! S' \. t9 Z1 u+ N8 d3 }
#c::
0 M0 f# L+ O8 Z& E7 y OpenCmdInCurrent()* U9 t+ [- O. {
return
$ y. |* x8 t4 l$ g4 q+ g0 O: g #IfWinActive: _4 y! Q3 Z4 w
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 I0 j0 ~8 p" M- j) ?1 G& ` ; Note: expecting to be run when the active window is Explorer.
) C$ Z4 I' n( x! j. E7 _ ;. F% C4 A# o: ]9 a3 o f" ~
OpenCmdInCurrent()
8 w1 P4 V; L" J9 t0 g; Y2 R {
7 R! C( K9 g: t* V% o! O2 B ; This is required to get the full path of the file from the address bar
, P2 F( }) h4 t. u7 F/ g M WinGetText, full_path, A1 j1 ?, @ R: Y2 P& P: t
; Split on newline (`n)5 I- R4 ^# v0 F. _+ F# f- w. f
StringSplit, word_array, full_path, `n& u9 ~0 W, {) M
; Take the first element from the array
) Q1 B+ r4 m: r3 I9 v" R full_path = %word_array1%2 g0 |+ S+ n0 P' m
; strip to bare address
3 k, w; e) k y: |9 W full_path := RegExReplace(full_path, “地址: “, “”)7 X, |% g* h6 g8 D0 J( P
; Just in case – remove all carriage returns (`r)' M$ |7 e" [8 @5 g: k- E/ O0 f' ~, ^" I
StringReplace, full_path, full_path, `r, , all+ s4 B3 ?* `0 N/ N& ?. s, Y4 }
IfInString full_path, \
- [- Q' r# m3 }$ J/ U& y( M* b {( s0 T. W, c- ]/ Z2 `4 E3 N9 f
Run, cmd /K cd /D “%full_path%”
. E# e& t! t& ]/ ~ }% g& d# r- {4 b' c6 `+ _; e1 `
else
3 W8 {8 ^& F# _. a& {6 `; `' z3 _0 h {1 j& _% y. T4 o& Q2 {6 Y
Run, cmd /K cd /D “C:\ ”
0 Q) }2 W' g3 G' {7 v& J8 y }
& w; R& Q; M6 ^/ a, r& u4 e } ]# H6 e8 O( C4 j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. L3 m) M& E q9 Z
这段小代码肯能有两个你需要修改的地方$ L3 b& Y1 X4 l1 u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% m. m8 h ]3 q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 m" V5 i4 E" v) P+ K |