此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 T* Y3 |( d4 w7 p. G% a( u 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& B6 |: p1 |' u* X8 e* i 方式一:( G+ p+ Z% ]' J) a! V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* x/ ]# W7 _$ K/ t. L1 Y R3 X
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 A$ I6 X* b# } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
3 X" M& ~% C8 E9 S' ^# ]# h# \ 方式二:) n9 N$ y3 T) n4 m5 c8 z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ Y& M; e5 d8 a0 O' U SetTitleMatchMode RegEx
( T) h' k4 z" a( H) ^! A3 o return3 m: X. g& {$ e' C
; Stuff to do when Windows Explorer is open7 q/ q' A6 i2 b# }
;
u0 T4 k$ l/ X: M #IfWinActive ahk_class ExploreWClass|CabinetWClass
* _( I/ [0 t5 C! V5 F ; open ‘cmd’ in the current directory" ^- c1 Z j' l! V$ m0 J, {0 D6 o
;
. _! k& L! h" _* w$ j" K- j2 k& { #c::6 E1 ?' z% h; w s
OpenCmdInCurrent()
9 m/ \' ~2 K# {" }* K4 Y return
; ~3 U8 R$ Z5 w# b4 N+ Z #IfWinActive
' q( T, ?; a7 o1 C3 v ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 q9 s9 e+ c( { ; Note: expecting to be run when the active window is Explorer./ w N9 e: b2 w* e/ K* R# K
;
$ b) _: ?. G. Q; q1 C5 b/ S8 L9 ` OpenCmdInCurrent()
5 d7 u9 D; q9 b" i" k$ C4 M {
) J, h9 y/ J2 U* i0 n; K) S) X ; This is required to get the full path of the file from the address bar
" W1 ` C! e$ Y) S2 S9 X0 N8 K2 V' W WinGetText, full_path, A6 z( k- Q$ }% q* C
; Split on newline (`n)5 X( n5 I/ K3 O: `8 E" a
StringSplit, word_array, full_path, `n3 H* y' h. Y/ j% g3 S e
; Take the first element from the array' g' T- |3 R' \
full_path = %word_array1%
$ v' f, W% f% ~2 A9 _6 Z0 D S ; strip to bare address. R% M; M' b0 _
full_path := RegExReplace(full_path, “地址: “, “”)
( k4 Z3 g6 I; `3 Y. \! ? ; Just in case – remove all carriage returns (`r)
! ~( _2 v* @3 |: } StringReplace, full_path, full_path, `r, , all
' W; V/ f6 P( Y! D/ H( Y; a6 |3 {1 p* a4 B IfInString full_path, \7 s" y6 m0 M9 I! I- D
{
% c2 ]# ?" K! i; i* a% \! X Run, cmd /K cd /D “%full_path%”
! D2 \" ~0 L" X3 R4 a$ a: z }
5 `' l! P; T( d" x) ?# _# N+ ~ else
3 t8 K* _2 `# k% ^+ b0 o5 y {
5 G- E2 O# v8 j4 _3 k Run, cmd /K cd /D “C:\ ”
* b* M/ m4 Y9 c& \7 a6 q. _% e }7 o( v8 M* m9 z7 W/ I! ~
}
# p8 V9 N5 ~; Z4 q- _, } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# d u* M3 ]5 C! i+ \' D1 R 这段小代码肯能有两个你需要修改的地方' }( {1 H/ X7 }; S
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 j4 C% G9 |& y& K/ ^8 D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" x4 X9 N2 c* K- H |