此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# ]# v9 j5 R) f0 { 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 _& t/ ~: I) p 方式一: T5 q2 s: j8 L. f
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% M; d; p# r- b3 n2 C+ z3 q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* R$ U! n; x. a5 o2 M2 A7 p HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) C6 a0 d+ Y2 R: L! x
方式二:
1 b& c+ N, e3 |% s+ ? 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 q* |$ O5 g& \$ H SetTitleMatchMode RegEx
. D. G# K* e) ~- { return% a3 S' M ~6 l0 Z; g5 {. E" x% u! f
; Stuff to do when Windows Explorer is open
8 x1 t" N! z# W+ k ;. C; X% q" q* l# z% t
#IfWinActive ahk_class ExploreWClass|CabinetWClass( j3 [3 ^) I1 c$ e6 p" n
; open ‘cmd’ in the current directory3 u: g* F4 I9 L* V1 S
;
5 e0 K0 o% j4 Z: W6 a #c::
7 ^" A% H# ^8 [/ w! U7 Y# ~0 ^2 P OpenCmdInCurrent()6 ~8 T- {5 x% O
return
2 S9 g: B r I3 I+ _ #IfWinActive
y! H9 |8 G0 \6 f' t" b( U& E6 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
s2 r8 x' H2 n" B! a3 k. ~9 b ; Note: expecting to be run when the active window is Explorer.
7 L1 L; w( D$ Y) A5 G3 Z5 p, E4 A ;( }+ {6 W/ z. e: l" A+ ?+ _# i* T/ `
OpenCmdInCurrent()) W& P8 W( E5 @( y% n; ^
{
6 i1 S3 y! w9 M$ D9 k; ~ ; This is required to get the full path of the file from the address bar
, h' N- Z9 T. p2 e0 g0 d WinGetText, full_path, A
6 s m% |+ |2 k( N4 g: G. O3 S ; Split on newline (`n)
0 `! t' h' e. Q4 o7 ?) f StringSplit, word_array, full_path, `n, ~5 _( X/ O C4 m, S
; Take the first element from the array% {: a+ }9 q4 _ K4 O. d5 ]* A$ S0 n8 {
full_path = %word_array1%
: `: B+ _( K6 U: ?$ x ; strip to bare address7 [( p# A0 D8 P; w: F2 \
full_path := RegExReplace(full_path, “地址: “, “”)7 K" j0 p0 L3 T& \
; Just in case – remove all carriage returns (`r)9 d4 l5 I t4 R/ a! s, H, \! q
StringReplace, full_path, full_path, `r, , all& n3 U. a, d1 Q3 F2 `
IfInString full_path, \
6 Z# `8 p6 X3 r/ `% R {4 v9 l/ }+ T, b: j5 Q
Run, cmd /K cd /D “%full_path%”$ o* y/ ]" O O) {' N4 `
}. a4 g' U9 t) e
else0 G4 L/ x3 R4 D& r- K
{
+ r2 r3 N( m' ]3 o1 E Run, cmd /K cd /D “C:\ ”9 {* @/ a; N7 b3 {6 G
}, b6 x/ C: k; o* ]9 U
}
* r X5 J" {' D/ r+ @8 X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
T3 Q: q# c& ^. }0 B$ s: W2 E1 ? 这段小代码肯能有两个你需要修改的地方9 q# y* p# ~0 Z% j4 ~+ a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
2 l9 d8 c7 P0 i% J( H9 n* u+ @9 ?; a6 y 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 D) P T! o# H6 [ |