此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' f9 q% Q! V) v* g
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) |7 d( P! J" C
方式一:
( Q. Q! A# P8 D1 t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# i$ y* F0 g' B7 W/ J0 I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' ^& f* b+ K! M3 u+ D HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。* F, N. ~* ]# N
方式二:
3 u$ F1 Y6 f- q* q' u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: q6 t4 \$ f" ^/ {
SetTitleMatchMode RegEx& C( j% r+ I) F1 Z) P, ^ E% k
return
9 D$ i4 d9 H' ?& N ; Stuff to do when Windows Explorer is open: c5 ~0 J. {) Y* W
;8 K# p/ j9 j* I3 n$ l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
* L6 x! B9 @( ~$ T# g5 w2 i: L ; open ‘cmd’ in the current directory
0 @- ]0 s' \* D ;0 s5 F, D, S+ t5 }/ b
#c::; m5 f; O9 G) w- {0 M F7 I
OpenCmdInCurrent()
3 q! q! w1 o+ x) Z' J) d' t return, C7 a3 R- v# C( g y
#IfWinActive
' S3 X% G( k3 H% ?) g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! E" {% D& q4 L! ?8 W# N4 _ ; Note: expecting to be run when the active window is Explorer.
- `. N5 O, }- X* T E) u ;
* O4 M9 }! {" B4 W: Q OpenCmdInCurrent()
) n" `" E% j5 F4 y { i3 J3 |/ i; E; K
; This is required to get the full path of the file from the address bar
- V. l9 p1 Q5 |. n$ k! A* L1 E1 r WinGetText, full_path, A
5 ~9 e( K- [9 m' o5 U ; Split on newline (`n)
* U; ^3 D+ `' a+ M9 d StringSplit, word_array, full_path, `n
5 l0 A% V( T7 T8 z! ]1 s ; Take the first element from the array
' a0 V' U0 \4 D4 H; `/ p full_path = %word_array1%
% c' r7 j" b7 a J1 Y7 o8 e ; strip to bare address
/ k7 |) z6 m8 B9 n* E9 I( z7 q7 M full_path := RegExReplace(full_path, “地址: “, “”)% _; S& f. N$ Q f4 ?* U
; Just in case – remove all carriage returns (`r)& ]: a/ t3 Y% a( s5 a
StringReplace, full_path, full_path, `r, , all
/ L; ]4 s& s; Y( _4 ]2 t IfInString full_path, \
& B& T& `- |+ q \: f6 U {/ w* z( m# ~& ^ Z
Run, cmd /K cd /D “%full_path%”6 |) D: ?4 b- d
}) E: k5 {4 s# T# O
else
! d# Z) d: ?9 c1 u! @6 }7 I+ e {3 i4 m4 a, {' i3 R
Run, cmd /K cd /D “C:\ ”
; E7 h4 p4 v% O+ H7 A' X& {6 R+ x }3 w4 a- L2 u, i3 q1 ^( E' q
}
$ T( `% }$ S7 | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。1 D; i# O: h z( Z0 {5 V9 g
这段小代码肯能有两个你需要修改的地方; _6 m' @) J; ~+ d% s4 n' @
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ h6 ]! Q) W z/ T0 ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. a, g4 U; b# j4 a! \
|