此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- g8 e8 k- ^* q( o& d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* s6 k; J- ^# i* b: f
方式一:2 E0 [" g6 t4 Y7 u2 T
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) U2 z% y5 q7 r W) D
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: v% e. A6 F: V. A& w6 {$ e, h) s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( R9 z( \% }; y9 ?4 f) W( d: x1 X 方式二:: d5 M- \1 Q$ r4 t7 V6 \
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, f, D6 _( W9 ?* ^- ~/ M
SetTitleMatchMode RegEx/ z0 H6 ]6 i! z/ B, W, S. Q7 i
return
! T; _! A* t1 e# [% K ; Stuff to do when Windows Explorer is open
4 R- I0 S: m9 W1 }, s( E7 G ;
; c% p+ w( V, a, K9 V #IfWinActive ahk_class ExploreWClass|CabinetWClass3 S3 K8 x8 E3 @) K' Y
; open ‘cmd’ in the current directory. C( D% y# d: W4 f
;2 ^1 I- v; Q6 n
#c::
; K, R2 N) k6 w2 D8 [6 W/ K% n OpenCmdInCurrent()
+ l$ g" e1 N+ S8 A' ` return" |6 |( e1 B: _+ L8 K0 m5 G
#IfWinActive
9 e1 A+ q8 o& j: E& [: q4 } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% C% Q' d) p! q( f ; Note: expecting to be run when the active window is Explorer.
( d5 p1 L2 ^' G5 i ;
9 s$ i- k4 z" M* K7 Y( m, b2 B, N. o OpenCmdInCurrent()
# f0 F+ o. O: M) N3 L1 A {
7 F4 h9 O9 R! B- I) L ; This is required to get the full path of the file from the address bar. k! ~& y/ |- H% N
WinGetText, full_path, A. `+ I7 B2 T7 i6 n' k6 ]1 A2 N
; Split on newline (`n)
9 [, G; L/ C* k* y- {. r StringSplit, word_array, full_path, `n
- m- d5 D8 R; a0 j; ^2 O% Z' s ; Take the first element from the array
O+ a6 z- Q8 E, L! n7 b3 H% x5 y full_path = %word_array1%
! Y2 _- v( U0 G4 @# s ; strip to bare address* g& p* l5 A3 w, I* A/ B+ T
full_path := RegExReplace(full_path, “地址: “, “”)
1 P8 ]2 V( Q% O5 u' |6 `$ y- D ; Just in case – remove all carriage returns (`r)8 J, a* [; @* b5 T
StringReplace, full_path, full_path, `r, , all
0 I' i* c9 {! x IfInString full_path, \- U6 e H: b Q u" k/ R$ D9 n
{
3 q3 `$ e1 V; [! ]7 z6 S Run, cmd /K cd /D “%full_path%”
: z& T; }' L( K" t8 a, Y }
5 b% [! u- B% o9 Q0 F' f else+ v9 J; @7 K8 |/ Y/ X
{
# a" J! a' d! ]% k Run, cmd /K cd /D “C:\ ”+ Z! O0 d! i+ a+ t
}6 ~3 b, V" s+ I+ b" V
}) r% y1 E! i( i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ F. b, P$ @. ~7 }9 }
这段小代码肯能有两个你需要修改的地方$ s% S: Y3 Q/ ~6 L& }7 Y& @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 C# n5 h, s& z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ P$ x9 D9 i6 Z' d# Q
|