此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- W" P2 v- x4 ?) V 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。& Z7 ]& j8 ]5 R
方式一:
% P( B% p$ U7 @ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
: ^/ k7 e- W& Y$ Y% W4 b: P/ ?+ e 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) l$ x) B; \* U6 S4 L; O+ w: ` HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 v' A; k) e5 E6 L5 V9 o6 E2 N
方式二:8 h3 ~' p8 c) \3 E- ~' T" ]
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 W2 Q* s2 y7 q9 T. d+ d* z SetTitleMatchMode RegEx
' F1 b/ S! `; Q return
5 w( x! G5 Y) p" V4 f( ?+ d' g ; Stuff to do when Windows Explorer is open- R- D/ n1 M3 I0 M# [& l$ E. b/ l
;; }% |. Z9 J$ M+ @
#IfWinActive ahk_class ExploreWClass|CabinetWClass( _- p* i% n! V; F" M5 D) L
; open ‘cmd’ in the current directory
: E! q: s- W j" W ;8 y2 z2 f% X. K* W' {9 G
#c::+ _ J4 A. W" x% k9 U4 f
OpenCmdInCurrent()) ?, z% z* c1 G5 j
return# i+ n$ h( @9 B! b" Q: _9 H6 t, V
#IfWinActive! x4 o' p! Z8 t% @9 ~9 G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 y" Q& M5 L' U+ o+ D$ \, u ; Note: expecting to be run when the active window is Explorer.
( d ?) k1 m5 [, Z- {- m, I ;
# C- p& h% E$ X$ `7 R, k' H; v OpenCmdInCurrent()
) e% O: }- g3 u( X( \! a {
7 t& h8 f. ~0 C2 s& e; c4 x9 p ; This is required to get the full path of the file from the address bar
! n* M' u7 ?5 Z( T WinGetText, full_path, A
7 `. f ~2 l% \1 K ; Split on newline (`n)# D! \. ?6 v: Q: z- i. R; C! R3 B; z
StringSplit, word_array, full_path, `n
- A/ Z" k6 ?4 k/ o+ z ; Take the first element from the array
, U% W+ t" G( i a! v$ s6 P full_path = %word_array1%7 }) C6 ]3 |1 }/ S6 N5 d$ l4 N% }
; strip to bare address
9 B0 n9 r1 J o P6 K: K% i full_path := RegExReplace(full_path, “地址: “, “”)' M4 G- y8 z1 Q$ o# O- z; f, e. y
; Just in case – remove all carriage returns (`r)
7 r5 ^) y- @! C6 v% A StringReplace, full_path, full_path, `r, , all1 T9 `- T2 a- M
IfInString full_path, \
7 M, X4 H/ |2 X# F! o/ J/ I% q$ m: ~+ W {, m7 X6 k6 _2 F- T% x
Run, cmd /K cd /D “%full_path%”
2 x! L! n2 A& u; D }
. w* P1 w( U8 h! M5 ]2 l# Y; _ else
' O+ I' X" F2 s0 l- j {# e u S- u" V9 a+ T. p
Run, cmd /K cd /D “C:\ ”. C% L. S6 n" ~: q7 Q
}
" t6 n+ P4 f0 } J+ K" I5 l6 l! O }
0 ~( P* c( T. n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 n$ r3 b3 g8 z$ f9 ]2 ^% L% @
这段小代码肯能有两个你需要修改的地方
B# Y( i8 {4 O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ C4 Q) `- Q% C5 k) o! r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ h" u$ f. X) r- G4 u8 q
|