此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 G) a; `6 ~4 y g" y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" _6 x, x. u- X: K) p! [ 方式一:0 |% e9 j& z( t3 E: g6 Z3 w" [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: }2 u) r) u9 }6 `5 e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 T" Y& O5 K# @. v( n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ s% {$ X$ l5 r3 o& x. q
方式二:* J7 F6 F( w1 T: P/ X* V- Y6 ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' @6 S* J1 d: L# m6 b- I SetTitleMatchMode RegEx
: I: g( i, @* T/ C return
4 z& A. Z* b: i0 y" e ; Stuff to do when Windows Explorer is open- L1 u2 U, i# f# j; d; I- N7 f/ |
;6 L; y; F5 h, a$ k7 c; C. H8 W- E: n
#IfWinActive ahk_class ExploreWClass|CabinetWClass0 j p: M' b" x( b
; open ‘cmd’ in the current directory$ j7 e: n9 q8 z$ e; d. |8 T
;
7 c3 t) x2 Y( q0 P: L' A+ q #c::- ~* h7 r' B4 f8 X
OpenCmdInCurrent()
7 \3 Q, m4 y6 w n4 E+ { return- J) S* {: R- Y s) S) R, w
#IfWinActive
) ?* J& ]. W9 y- m. e" }. P. ^! ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 J: O0 C' q" H1 f- H9 _* Y' m ; Note: expecting to be run when the active window is Explorer.
5 Z' W, j4 b3 i. k- J ;9 {8 z, E: j8 I |2 x, w0 F( T z) v
OpenCmdInCurrent()
$ d; i0 S" U3 G$ B: t9 N. }8 k5 Y {
" X" e9 ], d( l' b) U- g ; This is required to get the full path of the file from the address bar! L( g+ I$ o' j) T# s
WinGetText, full_path, A
7 t* Y. {+ _" e/ G8 f3 \1 w ; Split on newline (`n)' z+ C2 g% I* m$ R
StringSplit, word_array, full_path, `n# {7 G! S7 w& t3 B/ x
; Take the first element from the array
' F0 r/ t; q9 U3 M% N) `- r B$ ~ full_path = %word_array1%
! B2 u: Q Q" P/ O; C/ ^/ J& e ; strip to bare address8 o8 |3 c1 L; j! v: Q! o
full_path := RegExReplace(full_path, “地址: “, “”)
# \7 f+ h- s; {: u ; Just in case – remove all carriage returns (`r)! p/ G, S/ d" r+ t( m* I* b! D
StringReplace, full_path, full_path, `r, , all
; V7 ~) c" x" A" R' c! `5 ~ IfInString full_path, \
+ |( U/ O' D7 b& Z( U {6 o, B0 g5 _, Z$ f
Run, cmd /K cd /D “%full_path%”- N2 M6 J1 D* D
}/ `0 u1 R/ Q2 W
else4 J1 A6 E+ P4 D* ]+ s% p# z+ P7 J) u# f
{4 |7 g! @0 f1 z
Run, cmd /K cd /D “C:\ ”8 e. o- J' ?7 P
}
5 @# P1 h4 E$ @1 a8 M1 @ }# p9 T- `! L2 S: F
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" |4 Z# T Z( r 这段小代码肯能有两个你需要修改的地方
# [: B! n8 B& ]3 E* T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 Y! B2 G# c* ]! o' b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; Q3 V1 H3 S a9 T |