此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! N e. M: R" @1 J5 E1 W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ m) |) O# j3 ~ _ 方式一:
8 e; r/ u& y4 R1 E7 i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, H; ^8 M/ O. O, X7 y2 N
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' j; `% H$ a% w1 K- X' U HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; x/ q- K- x0 o# b 方式二:
; ?- K& i2 k- N" E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: u+ N% w- z% {- r, H/ @/ L% q SetTitleMatchMode RegEx
; I6 T9 _4 F1 c. v! y7 P( z7 i- h return
5 Y/ u# G2 U7 c5 L; a ; Stuff to do when Windows Explorer is open
u4 v8 D' i& n- @ ;
$ G+ A9 V" E9 ~/ s& {9 j2 M #IfWinActive ahk_class ExploreWClass|CabinetWClass- ?2 F4 A+ `" R* Z
; open ‘cmd’ in the current directory
$ M' \1 F( g% Z3 D$ H! D1 E v- u! K; b ;$ e5 R8 n _& b" L
#c::
- d1 Y; z, e$ A OpenCmdInCurrent()
) D f$ B% g3 A- g; {0 P0 c return8 g* y# C8 }6 |3 H$ T5 j
#IfWinActive L( |" a3 ^( g* G! ?
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 G8 A1 }3 U( W8 U8 V0 H+ u
; Note: expecting to be run when the active window is Explorer.
' k0 Q! @1 H, ~( z6 E4 u ;
# ~* ]5 s3 A- z2 y; j OpenCmdInCurrent()
8 m8 n) ]: U7 N0 e! o; ] {, ?" r: R7 H1 a# v/ y
; This is required to get the full path of the file from the address bar, u; Q" u2 L. q# ~( q
WinGetText, full_path, A
1 Z; W/ a6 a$ L% s: d( C. C2 V ; Split on newline (`n). A/ g/ }" W; F# d* T0 R6 X/ p
StringSplit, word_array, full_path, `n+ _$ j& A# L/ W/ {. b$ N& Q
; Take the first element from the array1 h+ U3 g, f1 s- [2 ^8 m( b
full_path = %word_array1%
8 l4 \6 I5 k# r3 ] ; strip to bare address
0 T5 N+ L8 M% ?: k: |9 `5 e4 u full_path := RegExReplace(full_path, “地址: “, “”)
3 x6 x! ?/ R7 z9 T) h$ }/ T3 { ; Just in case – remove all carriage returns (`r)7 a/ x% \- ?* R
StringReplace, full_path, full_path, `r, , all
1 e+ k8 f2 O1 U4 _( q IfInString full_path, \5 ?% }' X* d& V. {% T
{# l" X" |, f# a6 ?' U
Run, cmd /K cd /D “%full_path%”
, u' K9 q- U4 A+ G& S" v }
7 N1 u/ I; @( @) [0 X4 ` else- c5 W, r; }9 D$ G2 O
{8 U4 y4 V$ H4 S& N9 Y
Run, cmd /K cd /D “C:\ ”2 i- l6 Q. U! l/ [: K
}8 R# `. ? ]1 i0 y
}
. ]+ ~# Z0 m O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. C/ F( ?1 M% [1 Y 这段小代码肯能有两个你需要修改的地方( E' b$ W: E: ~: C8 h6 t$ V
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, o) U- _* G+ t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 _! Y2 S% K# \! E/ \ |