此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 R2 T1 v. @9 w9 c, o! y 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
$ E% i8 w/ k. W( v 方式一:
0 w! f$ F. Z2 X; j; S7 ~4 u 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 M1 }1 e: K: P* \ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
& N0 m5 ?# @& z/ ? p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& I( }6 E. ?: s 方式二:
" j$ L( H1 B8 C# |% n0 K( f 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
a6 n( C$ n4 V8 z SetTitleMatchMode RegEx- j D; y8 s9 r! A/ f' W: B
return
9 H/ a+ g5 T: c# h4 k- W6 m3 S ; Stuff to do when Windows Explorer is open
% q( Q: p; _% t! t" l, p5 L ;
3 n) `% d% F F1 @; S- f #IfWinActive ahk_class ExploreWClass|CabinetWClass5 C' a, N% D$ y4 P; M' u5 i
; open ‘cmd’ in the current directory
4 k4 b1 O3 X* c ;
2 j7 _' j( T c! v #c::
1 ^, ~* G/ N0 Z, _. N, y( D3 i! @- ] OpenCmdInCurrent()5 c1 L1 t [' \$ {) j0 ~) j
return0 M" F$ ?; |! g, k% p: r: T
#IfWinActive% b7 Z) p, z1 S$ I9 g6 r9 s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% H% L4 B4 E: y# m7 `% h; n0 I! F ; Note: expecting to be run when the active window is Explorer.& `9 ^$ |0 V5 m$ D( m
;
6 {8 J! G4 e" U" T; h6 c4 T OpenCmdInCurrent()" _: A# c" _: A0 ?$ A6 o
{
* S0 x$ k& A( m4 H" B2 b9 B ; This is required to get the full path of the file from the address bar+ ]% B- V0 B7 Z4 |8 L! O' p* r
WinGetText, full_path, A
- f; q( }) U& F ^ ; Split on newline (`n). }7 I/ ~8 b# ~5 C# T$ G; U
StringSplit, word_array, full_path, `n: A, `8 ~$ t! N
; Take the first element from the array+ z3 r. ]0 p) x2 W
full_path = %word_array1%
7 K9 z$ `" N: D* L2 k- b% O ; strip to bare address8 F5 Y" X6 L" H! P+ N6 ~
full_path := RegExReplace(full_path, “地址: “, “”)4 S% F. t# @/ V1 n0 c; c
; Just in case – remove all carriage returns (`r)
1 [' J9 \ {' w) W" e$ _ i/ g StringReplace, full_path, full_path, `r, , all
; H& b* Z E* E3 m: Q IfInString full_path, \
/ j0 o6 m# P [9 J, \ {
8 [, b S; p: P Run, cmd /K cd /D “%full_path%”
, h1 S0 [0 n" U( b5 D8 n4 }( x# g }
; y6 J) e! N5 }3 D0 a8 {: Q else
% |" |; }! f2 S! ^1 J, @8 j8 { {
4 `5 ?- Z. o h% Y4 S( q0 \ Run, cmd /K cd /D “C:\ ”
/ a! G! o- [3 O( W4 F. f }
( A3 E: K' R* H/ B }( j B" D+ T" ~- e+ W( O
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- G/ E9 `* J3 E" R( |+ F x. B 这段小代码肯能有两个你需要修改的地方# S: J+ ]% k2 v1 z, A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& q* {- c; `+ v0 O% r% t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% E n# O: W7 X% |% a! ~$ z, m
|