此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。, [' _* }: [3 O# {, T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 J6 E3 s7 p! V7 j* w9 f8 R
方式一:$ B! Q& ?8 l) L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ a1 n4 F9 T' q& D& x: x* G, ]' ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 R9 o. J! }: n% v- y* T. z7 X
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 Y9 I# U) @1 W( K: q8 e N, ^( P
方式二:
. G: z# V* R0 j- L, n9 e( x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* Q8 [! { o) Q SetTitleMatchMode RegEx% i2 m' |+ X! v8 n; ]
return" @6 L, [$ j @# _ x0 Z
; Stuff to do when Windows Explorer is open% n1 W' N7 L( {/ u0 C' P+ n- c$ j/ `
;
' p/ @( j2 v( x. f: c #IfWinActive ahk_class ExploreWClass|CabinetWClass
( c& b' ?6 \$ L0 [/ ?1 `" T- C3 O6 ] ; open ‘cmd’ in the current directory
! [0 r$ d9 n% o1 c; ]; b ;8 ~$ y# I- w; Z/ j
#c::0 o8 o \/ f3 F* _+ e0 W+ [/ T; F
OpenCmdInCurrent()' Y1 r# Q1 T# F# R% [6 m
return
! I* M7 f7 K2 W! A3 c" L8 y' _ #IfWinActive
9 y0 l2 Q6 L! l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% h( C @5 \2 }$ x3 b( z0 T% n
; Note: expecting to be run when the active window is Explorer.# U# \' L; { {
;- E, a1 `* M$ X: f- g% r% o4 f
OpenCmdInCurrent()! B! b& X1 A5 I9 s( c
{
& r6 Z$ b- E" [ K$ b* q ; This is required to get the full path of the file from the address bar
# n$ x- i9 o6 Z( t5 k4 T WinGetText, full_path, A, [. z9 A. P- ?" g5 f/ f) @
; Split on newline (`n)
4 ]' D9 \0 k4 B1 W- ^' Z; ^$ { StringSplit, word_array, full_path, `n
; t2 O' Q7 U Q8 a6 s3 ~ ; Take the first element from the array
Z% i+ l$ h N full_path = %word_array1%
5 c6 n* q5 I5 G) s2 K" ?# H, G ; strip to bare address5 t3 @+ F$ o0 s; h9 Z# O, S) ~3 x% ^
full_path := RegExReplace(full_path, “地址: “, “”)
' h. G& v) `% g7 D ; Just in case – remove all carriage returns (`r)9 m4 M% w% P1 N. g6 k* j% S
StringReplace, full_path, full_path, `r, , all
$ Z; t! R* V9 z) M IfInString full_path, \' r: U, a. W1 F6 e N, h: n! k
{
$ ?3 C. j1 [. x2 J Run, cmd /K cd /D “%full_path%”
4 o2 l' C6 {$ _1 s7 ^4 ~ }
: S" l, D+ A! ~9 N0 p# N, @ else
9 o3 F0 w" u8 F- ~) g+ K5 [ {9 [, L; r1 J" L3 |
Run, cmd /K cd /D “C:\ ”6 [" j# D" b2 |5 v) G2 u6 o: d
}% g4 O) t2 \/ E5 ?' S* |2 f
}
( Y0 L2 g) @- Z* j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 q- j1 j) t `
这段小代码肯能有两个你需要修改的地方
1 F& D- Z- n. N! H* [9 X% L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 o% J; m P7 M) u! C/ Y( P# r
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 S. Z' d( c, J |