此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* h" A1 K4 D' i/ T 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' | A* G. O. b( M+ Q 方式一:
, ~$ s) M5 @5 m 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 u+ R7 f! d* }* r% E% b0 z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 J8 H/ U: c. j" Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* _& m" X3 F+ v2 y7 Q 方式二:
9 t. \( Y: o: s( z' ~/ r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ X" c. H. w# l6 f9 l; H" Y- D$ X SetTitleMatchMode RegEx
1 y$ y+ \5 k0 |6 X9 b- k8 X return
/ c( J. P7 P0 F ; Stuff to do when Windows Explorer is open9 ~! ^% M/ W, a+ E* c3 A
;
! `' f- Z$ J, ?$ M7 s" z #IfWinActive ahk_class ExploreWClass|CabinetWClass5 d' |$ Z S# Q- n
; open ‘cmd’ in the current directory5 R, t# K1 V! C) Y0 x, I1 e1 S
;1 k# a. g: w5 }% M+ q3 b
#c::8 H, D" ]$ ?3 _; N+ e
OpenCmdInCurrent(): y, V7 G& w9 W1 B, ~% L& ~
return
5 x* Y7 M2 m) \# |$ F #IfWinActive
. c; a$ P; A6 m% U2 B ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ C H* ?& W j) K& f- P
; Note: expecting to be run when the active window is Explorer.
, t) }8 W5 x0 t, H3 N ;/ h" W% I- u& c
OpenCmdInCurrent()
6 A- t4 r* C: h) M/ l7 H3 G0 O6 ` {* s+ A( u9 ^7 v5 Z Q* n, B
; This is required to get the full path of the file from the address bar3 f2 j! \- e/ ?4 }; | m7 ~% u$ V
WinGetText, full_path, A3 ^! b. b- e( n0 w
; Split on newline (`n)8 }7 z& C7 h7 C. F" l9 j3 \$ {
StringSplit, word_array, full_path, `n
) ?2 ^4 |# K8 f" N ; Take the first element from the array
+ @% @/ n) ]0 B3 h full_path = %word_array1%( X* i; {; f6 z, ?* `: F
; strip to bare address8 b% ?) n! G! O6 L- S4 @/ e
full_path := RegExReplace(full_path, “地址: “, “”)0 V" R4 p7 X" _
; Just in case – remove all carriage returns (`r)
. ?- }+ O' i: K# N" T" T StringReplace, full_path, full_path, `r, , all6 l( Q( A0 p/ {
IfInString full_path, \
* g$ l9 Y ^& b5 y# ` {
0 [+ S& |' I. F% ` Run, cmd /K cd /D “%full_path%”8 E# _ w' a. A, E; e9 }4 i* \
}, y& v6 y2 o, o! `6 `
else
0 G" J& a8 M- T% u {
1 i) i' r. G" J3 F U Run, cmd /K cd /D “C:\ ”" d5 G6 y. R6 T# c. H! l6 C
}
* a0 y* B0 d' [- r5 s _ }
# D7 s. E7 G( D 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ L% V7 v$ g# s- }- F$ M, ` 这段小代码肯能有两个你需要修改的地方
' j- L1 R+ \) V0 N7 g& u, H' ?6 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% ]7 V2 ? q0 J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; j8 ]5 R* B. |8 @
|