此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 p9 q2 m& j& F4 M& k" }* z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- m- f" B5 b, y
方式一:* B- q8 ~' |) x5 c% Z$ @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 w e/ j! ?8 { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
, t7 b2 P9 ^( X7 f) H, m# } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 ^- E2 U+ ]* v& h 方式二:
0 t }2 D' z: W& |) j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:8 t, p# p# P7 _' k* r
SetTitleMatchMode RegEx/ n, x* ?* c. V: {* A# ~* A, L
return
; L+ [/ G8 R l8 C ; Stuff to do when Windows Explorer is open9 }( ]; ]2 c( e: W
;9 p, U* J3 K" X) E1 S
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 u$ u+ y6 t. @6 v
; open ‘cmd’ in the current directory
0 j+ _0 f. S* q, I2 b% u$ a; m ;
B% {9 e! m3 ?" D #c::
) x/ M6 K* v6 c+ }/ V OpenCmdInCurrent()
/ _. I$ ? h; | return
6 B% {' t5 X% n# D( b #IfWinActive
1 r* Z1 y0 L9 z( R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% ?; q. I& [$ K4 A6 Y: b ; Note: expecting to be run when the active window is Explorer.
# m4 V0 c$ t- a7 j8 I/ K ;
2 z* r: M, K) A: v/ I. ~. t OpenCmdInCurrent()
. R' j8 v$ B' Q, n. w {& t @! d I5 @* |
; This is required to get the full path of the file from the address bar* e# ?+ X5 Y6 F; M
WinGetText, full_path, A! f4 z3 N+ ~: g- j
; Split on newline (`n)
- o0 {/ g2 v( P5 R" c StringSplit, word_array, full_path, `n- n) a" f( c7 J$ x" d7 ]
; Take the first element from the array
2 \0 {8 k5 f: U y' \ full_path = %word_array1%
% n3 w! s B. u1 m' q4 B ; strip to bare address4 V) g3 \6 s0 L( S
full_path := RegExReplace(full_path, “地址: “, “”)
u. _3 F7 y5 v9 _9 _ ; Just in case – remove all carriage returns (`r)
# f5 h% L2 S" ^5 k/ O# q7 ~ StringReplace, full_path, full_path, `r, , all3 h, B1 N( [' u' s
IfInString full_path, \
/ M e O6 B6 H3 ?) V$ O, { {% O. X5 @) r9 h i6 m$ q" o
Run, cmd /K cd /D “%full_path%”
% O9 V3 ^( N6 N0 |! _ }
& J8 j6 y& {$ X+ ]3 s- q+ Q else
2 s! ?% ?6 T- F4 V( u {
Z! s. B+ _' A5 W' y# @% u P Run, cmd /K cd /D “C:\ ”8 J" {. f# \' \# H4 l( D) Q6 I7 h* O* J! M
}
4 ^* g: G0 d% s }' s- Q/ g8 ~: A) h' S, @! k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- }' e3 w% L& U3 L$ G; J 这段小代码肯能有两个你需要修改的地方
' P6 u0 c" I2 ]1 ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( Y% Z$ e5 o7 d) A+ d, k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, R- T3 V/ m- Y. |; z; Q
|