此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 v9 }- e2 d, t8 s5 g& w
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, D) u2 l( V& m& k+ ?) I( w 方式一:+ E: c* w# a* ]) z5 n5 t* _
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,! k# G x6 [* n! b. _5 J3 a$ Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 F$ n& N( g# u! P1 D; a+ H; T! | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
: m$ w$ J, f3 u6 l 方式二:
3 C8 r+ a2 ~2 a. E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, y& z8 s8 T$ [) v: }- Z* h SetTitleMatchMode RegEx
+ T/ ?5 V$ h$ @, d return# E5 _, N3 W7 a+ s* z# F8 v+ {
; Stuff to do when Windows Explorer is open: G0 d% a$ ^- z% P; ^+ U
;
' J& C' d; w* X9 `# g #IfWinActive ahk_class ExploreWClass|CabinetWClass
# c2 T5 F( f& D5 P$ S' U5 V ; open ‘cmd’ in the current directory
$ I s" @! H1 E. k4 J9 m: {5 t ;
, J- D) [# I, T #c::0 G6 X; Z7 e; s8 w: o+ p
OpenCmdInCurrent()
; Z; Z! }; Y% ~+ C m* u return
. O- S2 y# J0 u# M" _6 K #IfWinActive
b" L+ D) a8 D* J4 { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 N2 U' E0 ^+ s
; Note: expecting to be run when the active window is Explorer.
0 s5 i+ T- i; G- t8 i/ B ;3 t; ^6 E; n% C, i
OpenCmdInCurrent()
( m: c3 M# U7 w$ I& j# G& Q2 i6 f {- k3 c- b. S- n7 Q
; This is required to get the full path of the file from the address bar" S2 x5 k# X( w* Y5 V% M" m2 q" w
WinGetText, full_path, A
- i% q3 P( C% U ; Split on newline (`n)6 h# m6 y; c: x% i
StringSplit, word_array, full_path, `n5 x& T5 w: N0 v* n; |
; Take the first element from the array, X8 e% f+ m- }
full_path = %word_array1%" g/ i" G3 ^, ?, M
; strip to bare address
3 ~, B, u t% C: X& l( z full_path := RegExReplace(full_path, “地址: “, “”)1 k; T {( _9 ~0 C
; Just in case – remove all carriage returns (`r). k% x/ |1 S" ` _$ J+ x3 \' k) U
StringReplace, full_path, full_path, `r, , all V+ a% K% C1 ^% \# Q0 X
IfInString full_path, \
! R2 n8 |$ Q( \ {* v( M' n3 ?! r; P. E
Run, cmd /K cd /D “%full_path%”
8 a k5 B% |3 V$ M% W4 I }
+ h$ k# U) v1 R0 h else+ D' [8 n* \3 ?) ~
{
/ o4 D$ P# ^% K, F Run, cmd /K cd /D “C:\ ”# j3 H$ J( h: Q$ D
}0 |. c2 {" V( S5 J% N
}7 m, Y: }/ k( a+ L3 o7 B, n" k: `
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" \. W$ k( F6 W0 b5 l 这段小代码肯能有两个你需要修改的地方3 Z u# ~/ E U2 F4 m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 X; j+ o1 {. y" b' t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 s# Y; X7 p1 z/ t; E" S+ @& f& x |