此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
z+ A$ B% U% c3 R# k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- z5 b9 A* I7 m' [: v. K( }
方式一:. A0 l4 v2 Z7 d. W- l! S4 F1 T
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: J6 c2 @; {9 X& ^9 q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: y' r/ q+ ?8 v HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% x) p3 }0 K) {( l) f0 H 方式二:4 m9 G" ^0 }6 _- z! m( t h
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% u6 L# c$ {# ?3 B SetTitleMatchMode RegEx& A, n- |* L. ~8 {# j" l2 _! I
return
2 N* G0 q: t/ A5 t+ z. p( O ; Stuff to do when Windows Explorer is open* v& ~/ T% u! ?9 s; j4 G3 c: @( I( t# {
;
5 P1 u% q( k2 R7 E7 @1 J #IfWinActive ahk_class ExploreWClass|CabinetWClass# U7 H6 h( N7 Q
; open ‘cmd’ in the current directory* ~/ j s( F5 Y; d7 \; O
;
3 g- X$ @3 L) o3 i #c::
. U! z8 [; N9 O0 j OpenCmdInCurrent()! u/ S y% W0 G+ l9 ]. C
return
0 K0 \0 M+ z* a #IfWinActive9 N. m3 X$ H' U! l8 r0 G* `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 u; A5 D" x; M# O0 Z, l/ M( z ; Note: expecting to be run when the active window is Explorer.
- L+ I: w( o0 ^3 I& c0 X! L ;( m3 J" m. i! a W2 J" Y( \
OpenCmdInCurrent()% c) n' \% b! k( r/ K6 {
{
, E/ _% ` T2 a3 T% j ; This is required to get the full path of the file from the address bar
1 U+ w0 U9 L/ ~$ z* C WinGetText, full_path, A( \& H0 Y# T! t, q$ ?$ k
; Split on newline (`n)
2 p& F' c4 U- b; y: J StringSplit, word_array, full_path, `n
6 Q" ^9 M, q/ S1 R( y4 H7 v ; Take the first element from the array7 [, c& Q. a! M2 \
full_path = %word_array1%
' `* a/ }- f! M ; strip to bare address
3 y2 c, e z4 Q* n, m5 _' ?2 d full_path := RegExReplace(full_path, “地址: “, “”)
) B; }) Y: u, ~: a( d% Q( | I) \ ; Just in case – remove all carriage returns (`r)# @3 t E- D& v' b" B: C
StringReplace, full_path, full_path, `r, , all
* T3 w1 A% H \3 ` IfInString full_path, \
$ p) m: y8 h3 M {' N- n t( [+ a4 Q; Z7 ~
Run, cmd /K cd /D “%full_path%”
. \7 J: V& C* x }
; f4 K/ E0 f+ V4 U& x5 ^! I% p+ j7 z1 }) F else
' L: r* Z/ a& P" d5 o {8 O8 i4 M9 L: v$ X# L5 [2 B
Run, cmd /K cd /D “C:\ ”9 L3 e7 l3 E) a6 i2 D0 x: f3 k2 o
}
8 A2 W& |+ v! `. v+ C6 L" |. q }% F: i( Z+ J d$ K, {: C1 x# B
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# _& K- B" T$ w0 W
这段小代码肯能有两个你需要修改的地方4 D- R7 c" M: b3 G
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. t: M4 i7 Y; \$ _. I z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( J0 o6 D. D( J6 i" z
|