此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ W4 p+ D4 u1 L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! M+ S2 f% u2 }8 _) H* h( v
方式一:
, ], l+ y. M" `1 D/ W: L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 y& |9 D8 ?* ]( ]0 ~, ?9 H
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 Q* x+ J% K: _# R( [; V8 O S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ q) ?8 u L8 [+ f o F9 }
方式二:
/ A9 k8 O9 @1 `$ a, r8 b' ^- P 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 ? D9 {5 J, D! I: R5 w
SetTitleMatchMode RegEx z8 g; y! K. t2 [
return" N$ P/ R$ t8 x# V" g' Z9 _
; Stuff to do when Windows Explorer is open
8 n. h6 b; K/ n7 o1 I% E0 u ;
1 p j2 a: z# V+ V$ M& h #IfWinActive ahk_class ExploreWClass|CabinetWClass: s/ w0 S" S9 z
; open ‘cmd’ in the current directory7 u& B: _& i6 }" c
;$ D- M& L! B0 D" s$ ?
#c::
4 _) \2 A. H( m* b OpenCmdInCurrent()' s. J$ L, T( S/ l$ ^
return" X4 r6 j p. L/ s G K, C
#IfWinActive
* H& a r! l0 @; p& n ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, c" U$ g* ?5 t3 Z: M% E; E ; Note: expecting to be run when the active window is Explorer.
& e% F5 y' ]# Z" p ;/ I( X( [, J4 O% F
OpenCmdInCurrent(), p! u+ v- T, k; [- ^
{- y5 p$ z. h/ c6 p5 ~: z; T0 I! W
; This is required to get the full path of the file from the address bar
/ ]. A: k6 B. Q2 ] WinGetText, full_path, A9 k" l( Y' E9 ~* ^0 C2 R3 F) h
; Split on newline (`n)% u _( F p# H- ^, o8 \* j
StringSplit, word_array, full_path, `n
4 u( E8 Y- `3 j* d- p. ? ; Take the first element from the array
# K0 V7 O1 e0 H" b; W full_path = %word_array1%
" c: ^0 {+ i' ~$ ?: k! J4 ~ ; strip to bare address
/ L7 ?1 P z# s* e6 ]0 Q full_path := RegExReplace(full_path, “地址: “, “”)5 o: P& [, D. }6 o) Z# u2 C
; Just in case – remove all carriage returns (`r)
! S' U d! z$ C( h) b5 y, b StringReplace, full_path, full_path, `r, , all
* d/ @8 v6 s @* ? IfInString full_path, \
6 y, ^0 K! M P- S3 Q4 O/ Z {4 q; L; V1 C* q. P; `0 U7 |6 z7 a
Run, cmd /K cd /D “%full_path%”
: p& e8 ]7 [" Q! `$ z }
9 ~5 \, y* b% Q! M: t else
% }- q# ^& h* P4 E) K+ p {3 z! {; c+ x5 |0 _
Run, cmd /K cd /D “C:\ ” [; z% B5 @( w
}
" G, I1 v4 b* E" g }
" m1 g6 T7 s! g O9 n% {9 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ _1 r4 C& D# {* s 这段小代码肯能有两个你需要修改的地方
0 L3 t$ F7 @( ~% I' I2 ~# }2 s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 C2 Q( r$ S. |7 S5 L 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
! c. B' l+ F2 ]" j |