此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; w1 [2 f& \9 J2 A' n 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 Z+ i1 x; ^! ^) u6 g) I, e 方式一:
1 {1 N% c" H: g$ }2 \1 } 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 `2 t* W% @* ~) ?% @2 X/ T7 y [0 U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! Y" ?% t. `: S; B! n3 J
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" Z% t% b0 J1 `( }2 E
方式二:8 n% \' T; i x# R2 M$ b
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( N, {) M! _" B; } SetTitleMatchMode RegEx
, z6 j4 d$ l' A) r9 u( w return
' R. p& N5 f$ N _8 e4 Y ; Stuff to do when Windows Explorer is open& q# j- j+ G9 t: M0 C
;$ m2 \. O% }3 v$ R3 I; s6 G1 `
#IfWinActive ahk_class ExploreWClass|CabinetWClass( @9 p6 J; K$ R$ H3 ~& M
; open ‘cmd’ in the current directory
$ n& s I/ j5 i# n ;
" `8 w7 S: e9 L' z1 v& J #c::
* O4 h2 C* i" z1 L# ?1 b9 ] OpenCmdInCurrent()
D: q7 m( }0 i8 J, c- H return
0 k$ o: P+ b( S6 z #IfWinActive
8 d3 T# X% d, g" q- x! t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: P/ T. _+ F9 H& H$ p ; Note: expecting to be run when the active window is Explorer.
# m0 i# p. B* U U. F ;$ B* L7 h- d/ q5 g( G" v0 {
OpenCmdInCurrent()
4 `8 |7 ? Z2 B! b3 h {# d" o5 i% O( m0 m" H# S) F- j
; This is required to get the full path of the file from the address bar
3 f* U9 R, \: Y( Q' V+ Z9 Z1 u WinGetText, full_path, A( A. s6 X; `; l, ^4 s M- k
; Split on newline (`n)# _& Z9 B* A& `
StringSplit, word_array, full_path, `n* }$ M U. i8 e* n7 Z
; Take the first element from the array
, J% w/ s0 \/ ~+ ~: f# v. K full_path = %word_array1%
- U- T1 ^8 l$ C' a7 h ; strip to bare address# c! w J y: x% F2 F
full_path := RegExReplace(full_path, “地址: “, “”)# L c) t3 T1 ~8 L
; Just in case – remove all carriage returns (`r)
2 A: o- r \6 y; e StringReplace, full_path, full_path, `r, , all
, X) z0 v2 C: G" l IfInString full_path, \
7 O6 M, j6 C! `: I: H1 B7 z1 @. f {
3 B+ w2 ?; U" a" R2 P Run, cmd /K cd /D “%full_path%”2 j9 `2 V; D2 g1 D+ U7 H$ U
}
+ y% u' H& O6 y' T else
2 O0 r$ U! V- J m5 O4 o {& z% c" l+ {. E: S
Run, cmd /K cd /D “C:\ ”
8 `* b8 _( j- H9 e7 H/ c }
* J: F! e7 O& ?0 e9 y! ?: E7 N- T! d }! s9 ^1 c; I2 w5 z! P
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 B) Z0 V! `0 Y1 z w
这段小代码肯能有两个你需要修改的地方
/ m& r" c2 Y% i; {& x, x: z8 [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, N' W) W, E" M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ k4 m I- C" I# A7 p( g/ i. H
|