此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* _+ g) `% |: K S, K: X2 u- M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
0 A3 y }, u' m6 i8 S 方式一:
$ l1 j8 L O+ |' j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# x5 j$ s( I$ M2 L& ~0 b- o# c' \1 _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和6 e; M9 K' V, M3 L; |4 M
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 ]" }% ?& S5 ^* a! c# ~1 ^
方式二:
+ [) [, ~5 e( @* p 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; G* A- ?" f: J9 W& F. F$ T! r$ u
SetTitleMatchMode RegEx1 y/ m1 Z2 N! f7 k$ J! L
return
9 s3 `% l' C! H. O8 e& O ; Stuff to do when Windows Explorer is open; V( K* M/ y, t2 f+ o
;
3 |9 q% p7 `% F! E #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 N9 V8 {7 X* E; [/ {* ] ; open ‘cmd’ in the current directory
9 F( A0 R5 }3 u7 Y. W. G ; {0 I' c3 t! z; U" t
#c::- I/ e2 ?$ S, ~3 c: G" P8 g, [
OpenCmdInCurrent()! C4 W8 s7 a a' H3 b- M
return
% t$ k8 k3 w- l4 X$ e' a6 X; K# C% G8 d #IfWinActive
" F* I& l" ^1 J2 t. I# C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ A' _, A" O+ R8 V: B" E ; Note: expecting to be run when the active window is Explorer.+ d! C8 v. i* C9 d
;
( N5 u3 `+ g; R OpenCmdInCurrent()" X d5 d) R# Z! q
{
3 b0 {. }! f1 w' Z$ o ; This is required to get the full path of the file from the address bar" I/ D! g3 N+ f% |3 h
WinGetText, full_path, A" [9 I& c- v7 x5 H( i9 V3 G- T
; Split on newline (`n)
8 _/ m% `2 W* z/ a# n6 C- O' \ StringSplit, word_array, full_path, `n, y, @- a) S' @0 z) y' f$ w2 F5 G) B
; Take the first element from the array4 I5 z' s% h n% Z& y
full_path = %word_array1%
. m* W' t# b }9 w0 f. u. H) m ; strip to bare address
' C5 y5 V8 j5 |: m$ P full_path := RegExReplace(full_path, “地址: “, “”)
' Y9 }! c$ N9 D! N. Z, m0 a$ { ; Just in case – remove all carriage returns (`r)' c# m, Z9 b! L0 o# q6 B$ o
StringReplace, full_path, full_path, `r, , all
7 B G2 H, ^1 t ~1 h. ?/ O IfInString full_path, \
# `4 c1 O f$ V {8 D1 c$ ^4 X4 f. ?( ~
Run, cmd /K cd /D “%full_path%”
0 |% @' Y& ^3 Z# u2 |3 P }
" c8 ~ f- f. o% l else: U3 E6 c' a; C2 u& S2 ?
{
/ t1 G0 W$ v; i1 B Run, cmd /K cd /D “C:\ ”
/ [: }* q& o9 ` }* @% ~$ i( ^" n5 O
}
$ |" o! M# B% D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; |3 n i0 g5 N, H
这段小代码肯能有两个你需要修改的地方+ y& u2 @) q( B M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
! J+ r& L0 n% I5 o8 N& e' e' J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 g7 _! x+ Q5 X9 C
|