此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 X) {, h r8 G9 s
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 G7 y( N8 Z' V
方式一:
6 g3 R9 v# T% h* E f- E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& }' D# Q+ F3 A3 O% A, w+ a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) z0 n1 |4 z/ p- h/ c3 E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。$ `; x1 M; @% Z, Q! |
方式二:1 v/ g; {/ i# d1 T7 T
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" I$ A X+ J% N4 b9 F1 c# _ SetTitleMatchMode RegEx
6 C, ?; |5 @5 r; n return3 j0 k% F* R8 E l( w! Z4 T/ U: t' f
; Stuff to do when Windows Explorer is open
# m6 O! }9 G2 Y# | ;
8 ~2 }# c+ H9 x- l9 K4 r" c #IfWinActive ahk_class ExploreWClass|CabinetWClass& i) x3 O( D% `
; open ‘cmd’ in the current directory+ @3 A: l" Q2 g( k- E/ z9 ~& e
;# e! A4 t( J' k# ^! `" R8 [. c
#c::
' I F C" G; k) V5 `: z) |3 u OpenCmdInCurrent()
* k1 @1 e" y- ^ return
4 V+ u2 J# v$ v( j4 M! w #IfWinActive
6 v! Z) a) c' d; j( e/ F1 I$ S" g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 f4 E, d4 |9 v- l3 K
; Note: expecting to be run when the active window is Explorer.
]# p2 h. e) B1 ]' q& x2 k: Q ;
+ O" q! w/ ~, ]( u OpenCmdInCurrent(); Q1 }( M# b. w
{
- Y) a8 T5 b9 f( Q" \3 j M ; This is required to get the full path of the file from the address bar9 f0 J' Y. J3 G; g4 j
WinGetText, full_path, A s, h7 ~* w/ D- n7 w
; Split on newline (`n)
3 v5 s: t0 I% R# U StringSplit, word_array, full_path, `n! x2 ]# F6 F6 C8 ~* L
; Take the first element from the array0 v) [3 J. {0 f( v7 o0 `# d/ H0 U
full_path = %word_array1%: H& R+ I8 h* u z
; strip to bare address
+ k5 R% R' v f7 o5 H* m full_path := RegExReplace(full_path, “地址: “, “”)
9 Y0 h" }' H% b3 X ; Just in case – remove all carriage returns (`r)
9 I9 R. J4 F! D3 Z& E; N( c" S StringReplace, full_path, full_path, `r, , all
+ |3 X- [% l; s& _9 q- v) D. Y IfInString full_path, \
" e2 @1 F' r# q6 q {
$ }' s5 {' `; n [: L* A" v Run, cmd /K cd /D “%full_path%”
2 i& o$ h ?: y* f1 E9 O# q" U3 p }
0 `, M( G' h7 j else) M: k/ o4 M$ ~& @5 M
{% n4 f( C$ u# M; T, O0 t
Run, cmd /K cd /D “C:\ ”* d5 |! U: Q1 N' m9 d6 Q" D
}8 B$ H( s- t" y; O9 V* z% y
}; u9 v# G( o! h7 s+ t4 L
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
+ c* v7 L' R" U* f6 J+ p$ b K 这段小代码肯能有两个你需要修改的地方: p! x0 y% T# r, v5 D! o2 V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键6 F8 K, X% I' \1 t6 v5 W! a8 y- @
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- s' `7 k: z7 U8 o* ~
|