此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ Q6 ]8 M2 A6 n0 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 Y' G* B( |6 b1 _1 @
方式一:$ K4 }+ J! v5 t
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% |( c% V6 M8 F 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' T# r1 O2 g5 r( ~8 Z4 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 O* W+ S+ a; ]' A6 l6 H( ~1 G; L$ t
方式二:& l2 B2 V+ z3 r+ ]5 e3 m5 j" A& S+ q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 H. ^. s/ D4 s6 ^8 ?0 p6 B
SetTitleMatchMode RegEx
5 A! @5 ?+ E! T$ l, } return
7 \# l6 m8 y" m* w# E! {( Q ; Stuff to do when Windows Explorer is open9 e1 z+ M8 i! F) B+ g9 K
;% b+ z! L# D) y- A& `6 D
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 @, z6 P0 m4 |4 X L2 R' s% h ; open ‘cmd’ in the current directory
( ^3 d7 C3 b5 {- |+ G ;! S) \, U0 f% l
#c::
& \8 D8 X9 L, s OpenCmdInCurrent()
) T8 G/ m' g9 @: y- n# O/ p, v$ C return" u/ H) _& \) ~. M- j. n
#IfWinActive
4 j* I$ ^$ R3 d5 c7 |& w, R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.7 O( s* i1 v, ?5 @$ s5 J
; Note: expecting to be run when the active window is Explorer.- i' R* K$ J% ~& W
;- B. \5 U7 Q- Q/ C
OpenCmdInCurrent()
, [ _5 D4 S( _ K {
3 w3 M& _4 s) m+ |4 ] ; This is required to get the full path of the file from the address bar( {) P) g9 Z$ O9 o ]4 h
WinGetText, full_path, A8 u5 A0 {, _0 f. O& L
; Split on newline (`n)$ r$ i( z) z# {
StringSplit, word_array, full_path, `n
" N: T5 B3 f F9 L/ v ; Take the first element from the array0 B# F/ U, y( d8 ~
full_path = %word_array1%4 Z2 D# Z& z/ @! _
; strip to bare address
: t# b: {5 X" ~' B, K% Y2 P full_path := RegExReplace(full_path, “地址: “, “”)
H' ?2 j# X5 p$ G& D ; Just in case – remove all carriage returns (`r)( f1 F, v, ^8 D |+ N
StringReplace, full_path, full_path, `r, , all
( u) n ~, P7 _4 @* B' | ]. h IfInString full_path, \
, Y+ ^, r8 X6 N1 N8 N {6 B) s, H; |8 k& N1 X6 ]
Run, cmd /K cd /D “%full_path%”
" a7 W+ G" L# |) f3 ] }1 C; n9 }0 h6 x3 t. O! H4 [ J* t( a
else
0 H4 k8 Q- U3 s! e! U; ] {
+ Q& c H9 S6 P7 Q3 i! h; N Run, cmd /K cd /D “C:\ ”0 P* O9 B* H: F' ?4 V& ?8 N
}
4 C5 ^; P# y" N" `4 |. P }4 B# f5 T1 B' v8 d. w" d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# E! i5 q, C; t 这段小代码肯能有两个你需要修改的地方% B, y5 s) l! F% |* ~% i* T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* Y4 i0 W# K& v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- N" b! Z5 L/ m" c1 S5 g6 W ~
|