此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# }8 z9 J- x- v0 |0 A# q9 C1 c
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ h9 c' S% ^3 P s- }; }8 [
方式一:
' n2 d& S) w: O! U. j* p 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ V1 K7 b/ W* l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ l9 f2 u, z7 g) W HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ [+ V' y& f6 j, a( ^3 W 方式二:
9 h$ Q; F0 h% F9 a% _$ h) P3 |5 ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) q& t. {9 C6 i- O/ b; G$ X SetTitleMatchMode RegEx
- `7 Q' ^% O# [( B, [4 \ {$ l* [ return
% |% ^8 R9 E8 W( M ; Stuff to do when Windows Explorer is open1 A2 D1 |% C! K% ]" r! _
;
1 F- g" V* ]: Y+ q4 o5 V. j) ? #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ ^9 o) P+ s- Z @ ; open ‘cmd’ in the current directory
* O& q t( E% d K ;
% z0 b/ e7 f+ o W+ t1 H6 ] #c::
, _$ K1 I' ~4 |2 T, K+ V OpenCmdInCurrent()/ Q* o! |% T7 f. Q1 m) R4 a1 p
return% B6 Y$ B# L. g* \' [
#IfWinActive! [' E7 T- D B% c0 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ [6 U* t, I2 R6 N) P# W ; Note: expecting to be run when the active window is Explorer.
& P& ^9 v$ g* w! S z ;
/ U8 `) ?8 g y w9 ^4 E% t. ^ OpenCmdInCurrent()& `$ e2 I1 ]1 {7 d# R2 b
{/ P2 o% k t& v/ {# j
; This is required to get the full path of the file from the address bar- h% n7 F$ v. m8 [6 Z7 v! o5 f
WinGetText, full_path, A( u* a. Y2 ?) U1 ^" r% t
; Split on newline (`n)9 d6 y, |: E" e$ S7 r
StringSplit, word_array, full_path, `n
8 F) P& I2 w0 D2 @ ; Take the first element from the array
+ x- f+ u/ F2 C full_path = %word_array1%
- w$ x7 h- ]8 f+ u! d$ m ; strip to bare address
- I h8 I2 z. m; i6 L- |" g full_path := RegExReplace(full_path, “地址: “, “”)- y2 t9 R0 O% @' O' Y( Y
; Just in case – remove all carriage returns (`r)) w z" ^7 X6 j% k
StringReplace, full_path, full_path, `r, , all
! H+ I& {3 \- r* N6 G( F' q IfInString full_path, \
/ F% j- i; n5 q+ z% P1 B {
9 ]) {9 E6 V& z: h/ h: b Run, cmd /K cd /D “%full_path%”
$ U" I: P" m5 G; ~ }% e1 s; `/ \: U- _
else
i" J* r0 ]4 S1 H; E { l7 j. P) q6 X! L9 u, ^1 Q
Run, cmd /K cd /D “C:\ ”
$ L }% N" \$ l. U3 r7 h( C3 R }) g5 j2 z% V m4 N5 p' R# D% q
}
2 w' E7 O6 L5 y% ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- V' c1 q( B. ]5 X( V: g
这段小代码肯能有两个你需要修改的地方
`% D/ h: ^: `, y+ @2 ~$ b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 {1 X$ f& c+ e2 g/ A 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# w9 V9 V; P w+ m6 M8 a7 Z; y
|