此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) f- Z( d! `# O7 g. [& j* O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) \! I0 m4 G' Y( r, u+ }
方式一:: k$ k, m$ B2 j$ y) U0 b7 x# N; m4 _0 m: y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 A& U, V$ ]/ d. F+ [6 n" N. I 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: L7 W$ E+ U* H- M; | H
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& J; z* G4 T' ~/ n4 @
方式二:
) ]# ]/ g5 }& [* Y, u 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 s7 o$ o; w/ J: H* j7 ^ SetTitleMatchMode RegEx
( j8 x( Z3 D8 v5 s return
# B; D0 o+ Y" j* j- T- G ; Stuff to do when Windows Explorer is open
- ^% { s$ v) A% c7 t5 ^0 Z4 Z ;
; L! Q6 ]# Q0 `/ O; T9 b$ ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass
; j1 E: C0 {$ d3 f; @ ; open ‘cmd’ in the current directory
! V' H) ^4 C+ \ ;
! ^( ~' j8 G J8 r #c::
% }; M" r/ @$ Y% ^# N5 z OpenCmdInCurrent()
0 q9 \4 [3 t4 y; H3 ~ ~ return! Z- b8 ^- y: ?1 c
#IfWinActive3 y4 f3 ]+ N* U; a1 L, }' V; g
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 w3 ]6 q' [; T k
; Note: expecting to be run when the active window is Explorer.
4 j. s4 o, k! h1 ^ ;3 O0 X8 w9 x7 _% J. W4 x/ n
OpenCmdInCurrent()1 {, m% `# I5 o/ U* K& q1 x. ]' \
{, o: Z* _$ ^6 t
; This is required to get the full path of the file from the address bar2 d9 | Z" O# @* b
WinGetText, full_path, A
5 Y# N; q6 v R$ K ; Split on newline (`n)) V" |: Q! V! E" p* _7 v( v; A
StringSplit, word_array, full_path, `n
/ K6 o5 J7 r! ?8 |4 ]2 Q4 {' z4 o ; Take the first element from the array; S( t6 g+ n! U( `% e
full_path = %word_array1%7 [- x1 k4 J2 O. e: [& h9 `
; strip to bare address9 m$ R4 i: \2 i% H; S
full_path := RegExReplace(full_path, “地址: “, “”)
2 B1 V0 D5 L* @ ; Just in case – remove all carriage returns (`r)
0 Q A5 Y0 W5 H$ G5 w* i StringReplace, full_path, full_path, `r, , all
; u# R7 s A: K IfInString full_path, \
1 z+ F3 d+ u/ ~ {
3 |& O% b1 ]. b. C0 q Run, cmd /K cd /D “%full_path%”8 q' j) ^' E( d5 h: r
}
$ O9 _3 `3 Y/ I1 f$ D T; u2 ]& m else
$ K7 ^% q2 n" O- H/ ]# ^ {
5 q8 \# t7 ~6 G6 d2 h9 ] Run, cmd /K cd /D “C:\ ”
- d# v. } n& V2 Z1 }! d, } }& T: `" o# \# D# L( k
}1 r: ^! Q. e" l; i+ G+ T, J
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
: l3 {% `7 ~" ], v( g+ |# w+ S 这段小代码肯能有两个你需要修改的地方% P. W. O8 B" B) N9 Q) A! ~! R
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键% S; \7 V. Y/ P2 p; I: ~9 _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ S( x' k% b9 b' R |