此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. h' B0 ]; m& u0 x* w; Z. t- }
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 c0 A/ U0 } u7 Q: y; H 方式一:8 R* {3 D. y+ O7 R0 ~0 u# k' Y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! Y9 h4 k/ c: z1 X 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- H- e: h/ ?; }: S& G
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 \0 V) j. b% ~$ t; l7 F) P, u
方式二:
3 q8 T+ }4 Q: Z8 G. j9 [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ L) l1 N! I4 o2 W4 F3 d1 p SetTitleMatchMode RegEx7 h! X. I# _; E9 z, H
return
& V- ~4 B; K* y, M, ~! d, P, h ; Stuff to do when Windows Explorer is open4 Y9 P' S1 K$ z+ x) ?8 |% b) J4 b, p
;2 I, x8 J3 i0 J2 i, O
#IfWinActive ahk_class ExploreWClass|CabinetWClass H7 H2 G6 B4 Y7 V8 Z
; open ‘cmd’ in the current directory
8 h6 e6 C9 t3 N$ g ;
0 P( N" v3 M/ F7 i7 O #c::
- M, ^, L2 h# J x1 } OpenCmdInCurrent()
* u# M! r( r2 N" n4 r5 Q" G return5 g/ m2 |; h; r
#IfWinActive
5 \6 H' J' f) I, v6 |3 B7 t% P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. E* O1 V7 b5 i7 Q" V8 y ; Note: expecting to be run when the active window is Explorer.( v1 G4 G; \# I5 H( E0 E
;3 U3 X* C6 C; |! g, W& m/ p
OpenCmdInCurrent()
5 Z& y( o' L) X {) q& M6 l: {6 H4 P( N7 P( s; U
; This is required to get the full path of the file from the address bar
/ w' U+ Y# O7 f* ~5 r8 |' Z& O" j WinGetText, full_path, A" D! k) r* ]" h/ b6 N
; Split on newline (`n)" V4 b" x$ J& F* W0 D
StringSplit, word_array, full_path, `n
0 N$ V& J' T) ]' m5 p ; Take the first element from the array$ A3 f5 \# ?5 l. g) J" n6 l$ n% [
full_path = %word_array1%
! u' ~$ Q1 W6 o$ K! p ; strip to bare address/ Y% s/ y ]) Y
full_path := RegExReplace(full_path, “地址: “, “”)
3 N" m; T9 c) A9 @6 o# e9 B5 R ; Just in case – remove all carriage returns (`r), S$ w- d$ I& P0 D. i; F
StringReplace, full_path, full_path, `r, , all
. D8 U' p9 b% t$ Z4 {* M+ n IfInString full_path, \& r+ j' B: E! O' }4 L
{
7 }+ A+ e5 P4 @- H+ _0 b+ O; Z/ H Run, cmd /K cd /D “%full_path%”
4 [; x; |- r! A, W6 y5 p }
( y j @) I5 I: k* ?9 ?! B1 ]0 P6 \ else, o; f5 r3 C$ r/ K9 F/ e, ]2 w
{2 T" I4 c" d1 C
Run, cmd /K cd /D “C:\ ”
3 t- f4 C1 C' X( R8 r6 p }" @6 i( Z& F: i7 b0 c
}( q. ?0 a+ T0 N6 a" m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. p: c$ P8 K! G( H: W 这段小代码肯能有两个你需要修改的地方: ?+ H U- i+ a5 }, M0 a
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 g0 \4 }- ?" m9 X# q
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 P o. R7 \ i/ D4 x3 z% S |