此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 j+ q6 ~! [$ A5 S+ \5 G! m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* g2 Z+ w6 J9 }" S( O2 E9 I# u
方式一:' ]. S7 w! {( Z& y, I0 s
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- F8 w2 X5 d' w1 X6 f( \5 d# `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" `# @8 {) A' \
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* g: X7 P- k; \# \4 f7 K" C 方式二:
0 ?8 y% U9 H) Q8 L" a' w) |+ D( E, _ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# j/ _* {8 x" a# _: A, u2 K6 A; r SetTitleMatchMode RegEx
- ]6 B2 N w. L& ]4 | return
9 Q5 T- M" `( y ; Stuff to do when Windows Explorer is open0 T" A I2 K4 W' `! c3 c% t3 R
;
0 x) Z9 x9 J4 }4 v9 E7 Y #IfWinActive ahk_class ExploreWClass|CabinetWClass
# G5 R, I/ J* ` ; open ‘cmd’ in the current directory+ L, R5 d$ }: g9 U9 V% j1 Q4 S
;
; A& e. H+ H: {5 O& ]( F2 M9 } #c::
* G8 C, Z6 B7 ]( N: H3 }! C) M) } OpenCmdInCurrent()
: ]5 R. e9 J, L/ X return
. f) C3 l n6 |* d #IfWinActive
+ J, J' M) K2 ?0 K' Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 R. ?0 Z9 C6 M* X
; Note: expecting to be run when the active window is Explorer.
! u0 D& t1 i: K6 V7 { ;$ y/ B% s0 n# E$ l% u7 C# C
OpenCmdInCurrent()
7 i% v$ ]5 S/ B( u% E: h {4 c! Y. |0 Z6 _0 m# w
; This is required to get the full path of the file from the address bar2 ]& o; L% h; o( m% W
WinGetText, full_path, A
1 |# S/ v6 d& r( g' q @* M: ^ I ; Split on newline (`n)
! {4 X' y2 D0 G4 N StringSplit, word_array, full_path, `n
8 q3 h j z/ p- L6 e- I ; Take the first element from the array* W( ?% ~! k5 a# m" A9 f* d5 d( p) k1 _
full_path = %word_array1%! d0 @" X) g3 ]2 z9 P$ ~; N( x
; strip to bare address. X- `- p5 b+ |' z9 w7 z
full_path := RegExReplace(full_path, “地址: “, “”)
4 X# U v' g8 ~; g- `* M( \$ m ; Just in case – remove all carriage returns (`r)' e7 h) q/ E' V# p- S+ j# f
StringReplace, full_path, full_path, `r, , all
3 e& I- K" K0 E6 N) W IfInString full_path, \
3 s; G1 r5 f. b; Q; y( E {0 D. _0 K' P/ W8 ?9 @% ~
Run, cmd /K cd /D “%full_path%”0 P, P6 \, T: O' y
}
3 b9 u3 `6 l& p" M/ D# C- Z else. s* Z$ u) z4 Y: X3 f4 X
{
. Z3 }. p6 W4 C% X Run, cmd /K cd /D “C:\ ”
% u) [0 C: |8 V* _: F# G2 } }
! f r; B4 Y% F. Y R6 F: c }
/ m( B0 @- `0 D: d. Q' ?. d2 q 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
7 t% P+ Q$ T8 x6 E4 R4 d; l 这段小代码肯能有两个你需要修改的地方
9 z& Y, C9 d; ?, C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% c/ ^% Z6 G4 ]. h; ~( A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. V: S( p. }2 t |