此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 _: s4 d1 s% q, M( k& V
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, C& @% b$ |' ^4 v 方式一:2 V+ G' P9 V7 c' E/ A9 V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,) u& N2 H+ N% d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和2 T+ o d: |( [2 j* S( l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 z' h) m6 ` p+ o 方式二:$ ~9 P2 g. a4 {6 R H: s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 z/ T; V/ ]/ g' x! B3 Z- v4 M7 h
SetTitleMatchMode RegEx6 D7 e$ p( k5 N$ }- w
return( P9 t9 T8 m* v8 Z! ]( _
; Stuff to do when Windows Explorer is open4 b; p3 ?$ M- t+ L2 Q
;
/ L( q0 G- s0 L0 H" X) x, B5 | #IfWinActive ahk_class ExploreWClass|CabinetWClass, `/ Z1 Y( s p( {/ @
; open ‘cmd’ in the current directory* r# D: S# ?8 {
;
* B% V5 a+ ^0 |' `$ P6 u #c::* {) w/ p4 ^! Y
OpenCmdInCurrent()3 J3 }- k. c2 \( w6 y; U8 Z. G
return) F2 M0 ?9 O' ]: B1 m8 y
#IfWinActive& B5 }( X C( y/ N& \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer." N- t9 l% [2 n4 ^5 B
; Note: expecting to be run when the active window is Explorer.! K+ Q4 t$ S( B$ w
;
6 }2 F7 L. W( w# L1 ~# p) V OpenCmdInCurrent()9 ~8 n3 l+ H- o; g
{
$ n$ S B# o" x+ g, r3 U8 G& |" {' V ; This is required to get the full path of the file from the address bar
$ @# g D- M& }* ^$ c8 l WinGetText, full_path, A
$ K/ W' E- ]7 Q% y* N ; Split on newline (`n)
* p. j# G* j3 l" L2 g. R StringSplit, word_array, full_path, `n$ h7 D/ `/ c+ b' x
; Take the first element from the array
. F( D; z" z$ _ full_path = %word_array1%
, h6 \ F. k! m0 | ; strip to bare address5 ^4 B0 {7 s9 @5 l7 A
full_path := RegExReplace(full_path, “地址: “, “”)* g0 i" r( X. \$ I: T' F9 ~+ {6 Z
; Just in case – remove all carriage returns (`r)$ a2 {7 E F9 |- A, |/ @& D
StringReplace, full_path, full_path, `r, , all
9 E# n& i8 v; C( {# [; G3 B$ c IfInString full_path, \0 N# y% |, s6 U+ K# y' Q& a
{7 x& g% Z. ^2 h* r1 g
Run, cmd /K cd /D “%full_path%”
+ C6 B, Z: k9 i }
9 e3 }6 F/ \( W7 p3 R else
6 M2 V' f/ q' Y- S; ?1 L3 T {
- M; r. ~: c- i7 E0 t Run, cmd /K cd /D “C:\ ”: z. b" H; P. |/ h
}
0 o% v+ b% d! T- h. m5 M1 ?/ o6 l }
* [8 _( I' v0 i$ W' ^3 ^0 b 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% X" t _! h4 M2 V \ B0 t S0 E+ m
这段小代码肯能有两个你需要修改的地方
2 s9 q! f6 Q2 e4 ^/ B7 ] 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 u' o& \1 P8 \$ B6 d
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 d8 D4 T! \2 B% O! D5 y$ { |