此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 m; k. H- y) a$ H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& b# t) M E' @+ E* k) j& U) [
方式一:1 J- r# U: z ]- d1 X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* g9 ?; ]- _: L4 y k) ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
! G/ ` |7 m( p w6 ] HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) @5 h9 f _1 f$ j5 W; ^& a7 t 方式二:
' V- c9 m6 O7 K1 O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 p7 Z. |0 m! q6 Z5 {, [/ q SetTitleMatchMode RegEx6 O! C, B# ^) E: Z+ |1 ]1 b
return
! f0 l) I( \3 w! o5 x ; Stuff to do when Windows Explorer is open( i5 p3 V- P1 X# h) l
;3 o$ `. |6 G! ]5 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass) B. O M5 j0 @- \4 j6 ?$ i
; open ‘cmd’ in the current directory
8 C( P( p e7 `# ^ ;$ z5 A3 M; U7 M0 U- k; h
#c::3 U7 \! h% o- U0 j6 {% E! f3 l' d
OpenCmdInCurrent()
6 \( \( F5 ]% h* ~ return/ H6 A. _. D' a
#IfWinActive
I# j/ _* W+ U6 Z% u7 K ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) g; r# P# u1 _. M! \7 U: g, v; A' x
; Note: expecting to be run when the active window is Explorer.$ d6 B7 n, F/ J. M) J }& e0 J
;$ F; L0 T7 K- J) }0 K; d# S
OpenCmdInCurrent()$ X8 Y" F+ p8 A6 G) E/ B5 E) d
{) _, K% Q; b: @' n
; This is required to get the full path of the file from the address bar+ G9 G! J1 g9 }; `! Q
WinGetText, full_path, A
2 `& P0 A" y4 e2 K0 y0 n ; Split on newline (`n)# X+ A6 f' t p5 L$ h" [, v4 \
StringSplit, word_array, full_path, `n. ?, M, N) g: T% j! P9 C2 b
; Take the first element from the array
2 ?+ x' S" r, u( ^9 \2 @% M1 o full_path = %word_array1%
- i4 a" O8 G* M# k# [ ; strip to bare address
1 q# o; s' ?* Q# E) y full_path := RegExReplace(full_path, “地址: “, “”)0 V6 l! `- J4 {% _* W. Q# c
; Just in case – remove all carriage returns (`r)
# l! d8 N H, ~# f8 _) k, ~6 ?0 s, u StringReplace, full_path, full_path, `r, , all" b7 r' ^, r5 |$ ?. \" u2 g
IfInString full_path, \
8 ~% h- e1 ?5 {# j) Y2 ]0 O {
" M. g8 [) _& q; Q$ K& B Run, cmd /K cd /D “%full_path%”
. @9 [" n3 J8 _ h }
5 a" e* Q- r6 f3 n; T$ n else6 l, t4 }9 }1 L% P2 R7 Y, [$ f
{6 F/ O2 Y8 W/ N* x3 w
Run, cmd /K cd /D “C:\ ”. S& I2 _4 e9 {, |
}
2 I/ O( A8 G1 ^3 T7 \+ T4 a& G }
- J0 V4 _0 Z9 D7 y5 y 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 p# |; t% n' [% \5 E 这段小代码肯能有两个你需要修改的地方" \: [1 K; d: T5 Q6 g& B. m2 `4 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 }, S* Z5 v# t- r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
, o% n* T: t8 X/ M' ^( n2 N0 b! n |