此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 I' R( ~5 _1 u2 `" Z3 p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& ?4 s3 w0 O* O8 C
方式一:" T7 F9 S* X, E: X! D2 A0 x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,- G& m2 f( o' g7 L! H1 a& f9 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 b! _8 {- O1 E$ J: x+ z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ z \, c7 A% G9 ~
方式二:
; d5 Q' |3 ?' B; z* D$ P0 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ p1 k( A. C: G: B0 X3 j' X7 \ SetTitleMatchMode RegEx, z! t$ Y; \0 z2 l
return
3 T6 W$ Q1 ^! B, ^% s ; Stuff to do when Windows Explorer is open' A9 i" I3 D6 d2 m
;
( q. \. j6 V! N3 Q6 S7 {) }/ C& d- z #IfWinActive ahk_class ExploreWClass|CabinetWClass
3 ?5 O! _" }3 P7 P( g4 p7 L5 P ; open ‘cmd’ in the current directory
( x3 f" E: G" K. A ;
# }# n/ u! @7 b, e) \5 G" K #c::
5 k5 [0 o; b, ?3 @5 K% A) m OpenCmdInCurrent()$ g( |- _7 C. d( V4 ?. J& i0 x" d1 W
return% M9 }7 B" t6 b# p; T% O0 S
#IfWinActive4 R7 m: X- g8 Y1 [
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. |# d7 U! J- H# r3 N ; Note: expecting to be run when the active window is Explorer.8 ^* @# Y9 v/ v: y
;
1 M- O/ i- I) q% w OpenCmdInCurrent()
" H. q% P; t7 g/ U+ ^3 E$ D {, T$ Y+ m% t! z$ @6 Q
; This is required to get the full path of the file from the address bar
; ?% s6 {5 P$ C; }$ X% @' u WinGetText, full_path, A
2 n8 Q" \1 h' z2 e/ E5 @$ R ; Split on newline (`n)) Y: [+ H+ H6 b' i2 X
StringSplit, word_array, full_path, `n) N/ Q+ k. @* }9 L1 G$ Z& f- s N
; Take the first element from the array
% J3 T7 G- Q0 O$ p full_path = %word_array1%
" q4 R, M5 m% I3 G ; strip to bare address' Y" L G2 C9 n- b; y/ N8 k
full_path := RegExReplace(full_path, “地址: “, “”)2 ]" {) M* y1 c. ^# b/ J# A
; Just in case – remove all carriage returns (`r)
* _ C8 u4 M, G, t3 G StringReplace, full_path, full_path, `r, , all2 t& I! j' v1 r6 n
IfInString full_path, \/ N$ ^- A% J. C7 Y
{
5 m4 I* m7 ` [, z' E Run, cmd /K cd /D “%full_path%”
/ F/ [! x7 U! ]. z/ C+ E }
2 q: f2 f9 w) v' \6 j+ H else
; l: Q0 {2 e9 p4 o( X( b! l {5 O9 H: J4 Y2 ?' m7 B- B
Run, cmd /K cd /D “C:\ ”( @# g9 H$ q' F! Y/ p
}5 I5 }" `6 M- G5 ~8 h! p F9 ]
}
1 O! h6 ~; M* h0 a; O! A 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 K& p4 U* _; Y
这段小代码肯能有两个你需要修改的地方
' p4 _' P. P9 \/ v3 w' E 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 h6 ?6 q; r& y/ U3 d8 v8 ?: D
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" P! m6 J+ K' j, W* K, @9 | |