此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% U% X& a% u6 a3 |, J
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 o( ^/ c7 z/ e8 K
方式一:
# ^: J! V7 M. s u5 ~, m& M 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! j7 i. g' N7 W8 D 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ p3 S. n2 F' n' ]4 [1 D% e: L HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 T/ M- F7 x1 X
方式二:
) w* d0 U) h7 _. H$ _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:4 \9 D9 A% P/ }- Y9 V, i
SetTitleMatchMode RegEx
1 r0 ?. T" x6 W1 \ return
% g+ y- b: i" X( F! U* ]5 X ; Stuff to do when Windows Explorer is open" z9 N+ A$ `3 Z" o- Y4 [: |5 R
;
8 ]( u2 o( P' Z+ g3 W5 U- u #IfWinActive ahk_class ExploreWClass|CabinetWClass3 @; B$ ^. [9 O2 K9 I3 l" V
; open ‘cmd’ in the current directory3 Z& V7 s7 i) _8 m" V! I
;
/ {' O2 O4 ?- C" _+ E; B9 L! N #c::
. }0 [) X/ J. J+ N+ h9 R OpenCmdInCurrent()
! C4 r* t7 i$ o; e return
% v- [* [ h$ d) g; q! W) t9 w7 S; Y #IfWinActive" v; z* q Z. ~" K1 R$ u& o# J* L
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. M7 {- A" s( D
; Note: expecting to be run when the active window is Explorer. m# o4 E6 U( x8 o& ?
;+ I2 [; e( v+ `5 G9 |. i
OpenCmdInCurrent()
) P% ^% s: n8 o+ H {
! @ a6 ^; G) S7 z5 n- \ ; This is required to get the full path of the file from the address bar
9 c. S! [9 m9 V0 H6 Z9 P1 k* d, t4 ` WinGetText, full_path, A
$ O0 N! @% ~' x ; Split on newline (`n)
2 f1 R; A. J! _1 G1 G/ h3 T% b StringSplit, word_array, full_path, `n/ \+ a2 ]& z6 i# N: @7 a
; Take the first element from the array8 X' W6 P, Q: I; h
full_path = %word_array1%
. ~% [* l8 _- W& d$ S ; strip to bare address
$ U0 O8 ?# s& w, T' Z0 x full_path := RegExReplace(full_path, “地址: “, “”)
& c' o( |% F- ~6 C4 p ; Just in case – remove all carriage returns (`r)# I: S( _" D, @/ W
StringReplace, full_path, full_path, `r, , all2 G6 d S: j8 f$ K6 Q
IfInString full_path, \
. O: Y6 d% }3 [1 n _6 ^& V {6 t* }4 h% @- b
Run, cmd /K cd /D “%full_path%”) \/ f# d1 ?$ ^- p$ Z# r
}# t. e4 ^8 i$ F" ~5 Y
else
( u- D5 u0 J3 Z. f) h {
! u; ?1 v1 U$ q4 D Run, cmd /K cd /D “C:\ ”
5 H5 N% ?0 j" k% W! r: G }$ G; j* Z( a" o6 |
}
# K( n( P# f# C, } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- @- g* l9 o W4 S: | 这段小代码肯能有两个你需要修改的地方
* N/ W, B' l; _0 o' N$ X& x3 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ J' o9 X( F5 M* C! C
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 u" g6 K6 K* z1 t' y |