此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ J7 Z! v" k4 P3 L" H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ [! O0 d4 y8 V" o, ? 方式一:, I4 _1 f/ c. {9 r$ ], k% H9 w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
\ D: ]: Y. X# c' ?; Z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ a) Q) B. u+ |0 P
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 B c% S0 j0 f. O. p4 f; J
方式二:, C0 T6 }' E4 Y$ U, Q* v3 u" M% G
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 M9 r% h" ]3 F2 p" [ ? ~
SetTitleMatchMode RegEx' ~+ Q: i1 l0 C; u4 r7 t' i
return
: M/ n. k1 n7 L6 |8 U9 f1 Q ; Stuff to do when Windows Explorer is open; I9 ~+ x- z7 @/ S7 R
;
0 {' z, ^; o& B3 W7 T* V/ G7 t3 A0 ~ #IfWinActive ahk_class ExploreWClass|CabinetWClass0 D+ ~7 e9 s8 t0 U ?" E6 B
; open ‘cmd’ in the current directory
1 B) U, t5 s1 j/ R$ o! l ;
* i- r9 v& R, C1 p #c::
7 |7 U) p0 h" h/ f8 s; C. M6 | OpenCmdInCurrent()
; Q& c. P* J6 c3 d2 x return7 K: f. x! Q2 b, U! Z
#IfWinActive
( ^! u' T9 V2 y8 L. |/ l ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 ~7 C2 g7 d, E' f* d5 p/ N) t ; Note: expecting to be run when the active window is Explorer./ r2 c$ J2 X8 T6 E* A' L- ]- _# ~ l+ q
;: Q) Q: o. P% S. k' Z
OpenCmdInCurrent()
7 V: A. ?3 a' Z6 r0 r t {! N }- B3 t! O$ h
; This is required to get the full path of the file from the address bar8 Z* b8 k! i) O' r, G9 }
WinGetText, full_path, A
6 c6 H7 P, e% d7 ` ; Split on newline (`n)' `6 Y: W) D4 I# v& y
StringSplit, word_array, full_path, `n
( ]. l0 w( U. y* o0 V ; Take the first element from the array; e& P! | Q+ c. T, @1 ^6 l, T
full_path = %word_array1%
" Y$ G+ X! ], \4 \ ; strip to bare address
4 m. K) `4 r" M full_path := RegExReplace(full_path, “地址: “, “”): G( I) A( c; a% A% W
; Just in case – remove all carriage returns (`r)+ {) b$ I& r" {3 i( l# w1 F
StringReplace, full_path, full_path, `r, , all+ d( p, M! H. \: O3 P' Z
IfInString full_path, \& }& G( `; k: t$ v5 V
{
/ H5 h: P/ J( y- s3 ]3 F Run, cmd /K cd /D “%full_path%” L! v" I; x2 b0 b9 b) q( a
}/ V- ?' ~% f" x2 Y
else9 I/ T2 O d, @) L% J
{, N5 E, i; R( ]/ M' g0 ^6 v
Run, cmd /K cd /D “C:\ ”& T0 R) {3 X$ i8 x' t
}
9 E5 S8 b- [& }: u6 E" {" p }
* H! p" E: j) T- a5 D( B$ C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" z4 r0 U5 k4 n h+ B! c1 x+ { 这段小代码肯能有两个你需要修改的地方
; T1 r q( I! o7 f+ p" z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# S }( ]. T; l7 [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, D8 R+ M/ Z; v7 a. ?, j
|