此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# v% u8 {! _$ d
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- {; z4 M/ _9 E* ` 方式一:1 Y1 d7 n4 S( Q6 ?) \, _: ?# k
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 V( Y! N2 ?* w" b0 {* P$ C. r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" v) B5 `3 D* g9 U$ p: S0 h HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" \: Q6 s- R. I
方式二:
+ ], x2 B; W* ~3 U1 ]7 o. V# w7 d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ R X+ l# w) {9 d7 P
SetTitleMatchMode RegEx- ^! }. L. z9 O
return
% n& L m+ b m ; Stuff to do when Windows Explorer is open
9 \! Y8 U: F' X1 ] ;; \0 q! a8 ?" i9 T( W* F t5 r
#IfWinActive ahk_class ExploreWClass|CabinetWClass
( _, D/ ]) |- d* C$ s" |, a% H ; open ‘cmd’ in the current directory# D# L3 X6 `* i$ G, X
;0 Z* Z( L' ~5 t0 b3 G0 m0 h
#c::
; b. r3 z: i4 ~5 w/ x& Y2 |& K, U, R OpenCmdInCurrent()
. M' X2 A7 L7 l( D! E6 I7 F return
. c. B, R# x4 W" g4 h$ q( j #IfWinActive/ A4 ]& P4 z! M/ ?. M% h- s, [, b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' p+ \. L+ x, N' L- `) a% ^
; Note: expecting to be run when the active window is Explorer.
# M6 m/ Y, ^6 P" H8 e1 b ;
/ L; F8 s' q# B3 U: ^8 z! i4 k OpenCmdInCurrent()
- [( O# B* z. M. [: T {
0 ? C; o$ t$ m; | t2 ] ; This is required to get the full path of the file from the address bar* X5 M* E+ F. M/ j0 w- c; L u6 o* a0 \
WinGetText, full_path, A
8 G$ [, t' X q/ S ; Split on newline (`n)
8 e% n' r3 X4 M. D c/ O) S# a StringSplit, word_array, full_path, `n' ]3 E! I" D b7 V8 T2 b
; Take the first element from the array, B4 x3 T9 u$ D8 R3 u- T9 U; e h
full_path = %word_array1%
! Z8 O0 `, H, v6 W) V ; strip to bare address" b6 |4 B4 w$ R% r% z, q
full_path := RegExReplace(full_path, “地址: “, “”)! P, N5 K& m* q1 W& o& u- Y+ g& M! i- N
; Just in case – remove all carriage returns (`r)& Z, `5 m# _3 ]- S9 K0 Z% Y
StringReplace, full_path, full_path, `r, , all
7 l. H( r7 m4 J2 C IfInString full_path, \! u7 [, b/ m$ g, }$ P
{6 B$ e9 @5 N' d" Q2 Z7 I7 x
Run, cmd /K cd /D “%full_path%”6 w# Q0 E' u7 m+ Z1 V( q9 F0 a
}3 F9 g2 p [" t' t+ `0 d) A5 i! K0 I
else: X) ~ m* w# {: `0 F. N
{8 B+ u F3 E! T5 T( W: _
Run, cmd /K cd /D “C:\ ”
# T: D7 `1 H; F! r1 M }
9 e. ^# @: n% @ }
L7 ~7 C: `) Q" k( }! T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
9 s7 {! d( N* | 这段小代码肯能有两个你需要修改的地方2 _0 Z4 m6 Y) }1 U) S) ^5 A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! I2 J6 d& Z' g" I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
. F8 i7 L+ O+ y4 q& C0 Z |