此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: n5 o4 }2 B( e( b! g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" `% v# v4 e: x6 D* P5 N 方式一:
: c3 @# ?* m' S6 J3 g 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,: Y0 p) d, g& Z {% B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, @2 w5 U+ e% x6 G% |7 Q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, f0 A$ e& _( C; R q 方式二:
7 c7 p- M: |4 N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* @: k: K4 d, _. }% ?" u4 Z. d7 W. ~6 o SetTitleMatchMode RegEx$ o' w4 _) U* y* \6 Q
return" `2 Z6 D1 r2 X6 k! ?
; Stuff to do when Windows Explorer is open
# p2 E8 L. W" I# F+ b ;
7 i" v& z; T! s #IfWinActive ahk_class ExploreWClass|CabinetWClass
7 X8 i& R6 x. m, U; T h ; open ‘cmd’ in the current directory, H' ^, b1 Y0 L9 ?( c$ J$ O6 Q4 v6 b
;% i( q; [2 O! m8 M6 }$ x* p/ D' r
#c::
* c8 h/ u& H( c l, \* v& E* j OpenCmdInCurrent()
7 d' c+ L+ e9 p4 ~8 q0 z: x0 F return
5 b: H1 t5 z, h5 x! o( \ #IfWinActive
' X3 H2 r/ N S+ V* S ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 [, A0 w, J4 W9 G; W
; Note: expecting to be run when the active window is Explorer.# z8 E$ J( x9 L \
;: ~9 v/ d- S5 j/ P! d6 f
OpenCmdInCurrent()% _( e& r6 L; P. `% |
{
/ @# t8 s6 }. n! t; ~2 L ; This is required to get the full path of the file from the address bar2 p; l; _* Z [2 R
WinGetText, full_path, A! p' {$ f0 T% L. f4 h2 d6 c, w3 @
; Split on newline (`n)
4 l, q3 A1 s+ y& H& @5 l; L StringSplit, word_array, full_path, `n
7 j0 \" S. S2 B; Z3 z% X: F- r ; Take the first element from the array
5 K' x8 j8 ~$ z full_path = %word_array1%
" m3 c) ~/ G* l6 M4 f% Q6 |, G ; strip to bare address
0 f1 x, Y4 a& o full_path := RegExReplace(full_path, “地址: “, “”)
. v7 R8 @1 P0 i2 {. G$ S( I4 [ ; Just in case – remove all carriage returns (`r)8 x& v' j2 P' z- u: [
StringReplace, full_path, full_path, `r, , all
' R3 R8 ?/ d. ?. r8 \ IfInString full_path, \' D7 Q* x# `+ ~
{& l4 m9 H* A# X
Run, cmd /K cd /D “%full_path%”
( L) S# T$ Z7 g* a; w' R }! N& J) |) |4 ^- _- N2 _
else; u7 h6 M3 e7 ]0 W8 F/ e, y y$ h1 I
{
' w9 l# U0 [- N- l2 P Run, cmd /K cd /D “C:\ ”" F2 z! C& Z7 B ?+ m0 x
}
1 T3 ~" Y4 X+ O7 y$ F) g- P; C }5 d* g; B9 d' }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。6 B1 Q( P9 L7 U, N
这段小代码肯能有两个你需要修改的地方6 ~0 ]: N! m5 m9 y$ K* }" L1 }
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- Q5 X: [# Z; ?7 V) U0 f) _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- @% y" q: s* H( y( ], L6 C( g
|