此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# {7 ? `- B! H t4 H: |) h
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 p P7 {7 R$ J( H, r$ t
方式一:
- I+ ]2 x+ ?0 P. L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' I, ` x- A: F' D- d5 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 N) k: h/ |& S3 l
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ d! I7 z0 H+ x: I7 m* V1 a9 `
方式二:+ y: s: F( T: F8 X9 K# i
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 h+ {- j. @- m8 Z5 K' u% `& J: u* O5 x SetTitleMatchMode RegEx& J6 `/ z* T! a. J; E {: \- s
return6 S) V& b: l1 }/ l3 h6 o+ g
; Stuff to do when Windows Explorer is open+ X# |/ X/ L+ Y) w" h! r. U- ?
; f" U( c+ F( U
#IfWinActive ahk_class ExploreWClass|CabinetWClass
2 k$ \9 g% Z3 R. y* X7 v ; open ‘cmd’ in the current directory* s6 c& b! {9 Y' ^' h P; N
;
! e) W& _1 i$ M% L3 b( N #c::
6 A: s2 ]2 r9 ^2 I. D OpenCmdInCurrent(), [$ d+ R( F M, ?
return
0 ~ b/ {) z7 g3 V- N* | #IfWinActive2 w+ T s! a" ]& S& v- a
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 [$ P2 B2 s- ]% C9 C+ E
; Note: expecting to be run when the active window is Explorer.
8 ^$ A/ q" l" A9 a( H ;
|# J9 g' ~+ r6 q' U5 {) z OpenCmdInCurrent()
9 z% b: |1 J- G/ R( ] {
+ b( ^0 m" ?! i2 ] ; This is required to get the full path of the file from the address bar
7 p. Q! M" D4 y' A0 c WinGetText, full_path, A* t+ }1 Z' T O
; Split on newline (`n): q- s0 t: p6 ], M, @ B
StringSplit, word_array, full_path, `n
( G) S4 Y) e4 { ; Take the first element from the array
; e/ g# s1 O$ Z. U o full_path = %word_array1%7 _. k1 i+ g: q9 V8 W
; strip to bare address1 K" k7 E' } Y& ?
full_path := RegExReplace(full_path, “地址: “, “”)! Y# ?0 ]* F; t: p8 U; o* u
; Just in case – remove all carriage returns (`r)
' [1 I" u# P$ X StringReplace, full_path, full_path, `r, , all
( U& p4 r* ?1 D+ e$ E8 B IfInString full_path, \
; R N7 O) v6 D# ~ {
3 a- |: k: ?0 [- f- U# X: l Run, cmd /K cd /D “%full_path%”4 @7 [3 [" M! A
}
, B* Z- g( ?& p3 ] else
2 h' z( v: J6 K {
" l0 s8 ^: X n2 h Run, cmd /K cd /D “C:\ ”& H. }$ m* H( S
}
) V$ C) L Q3 f$ e }' b3 @7 k0 ?. v+ J0 ^( J V
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( _2 ?* s3 A$ z- e- F; I 这段小代码肯能有两个你需要修改的地方
/ p4 \8 f) K8 {1 o/ L1 b! X6 _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 k1 ^5 l- S9 M3 ?0 E- w( Q5 Z# ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “" t4 {/ c) Q7 } B m! f' _
|