此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 e9 K( m' S; a8 {9 {( |5 I4 l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 O+ ^3 ^/ H+ p5 ?3 k/ G 方式一:
0 z9 ^* ^* C4 }& N3 z' o; z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ L/ c# o s/ {
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 J" A, p! \' {9 f% I HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 \# Y8 J, B9 G: D 方式二:+ I* F1 {# k- Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- U! M0 q0 U/ Y SetTitleMatchMode RegEx( v- N k0 ~3 ~2 I: U* z
return
, L/ h& g; Z( V* t ; Stuff to do when Windows Explorer is open
7 M. s% d7 | Z2 d, B# | ;
% E9 ` h! ^) Z, s b) B #IfWinActive ahk_class ExploreWClass|CabinetWClass" b$ d+ S" G" ?
; open ‘cmd’ in the current directory
* P# y1 a2 O3 i: `0 K ;6 H* {, t8 ]+ I5 \4 k
#c::
1 p: x4 G2 H+ y* ~! M5 E- \ OpenCmdInCurrent()
+ n/ S! ?& k. U return
& x9 Z' o% }$ C7 B #IfWinActive) B8 e: l" V( d- h. Z# u
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
5 p# `4 A; C' n2 w) g7 ^9 k+ V ; Note: expecting to be run when the active window is Explorer.# s) K# D9 P/ X
;
6 c* o z, H+ |# e" P7 b OpenCmdInCurrent()
' R% ]* T9 j# ?1 v2 y+ b: X( z {& V) v, I6 E: p! N
; This is required to get the full path of the file from the address bar( S) N* t r6 v# k3 o$ X, w9 d
WinGetText, full_path, A
( C6 _! q# L; I3 Q ; Split on newline (`n)
% ?8 I) r. V& o' t StringSplit, word_array, full_path, `n: b' f0 ~9 A8 V2 K
; Take the first element from the array8 j- V- L" A; N3 w/ J: s( m
full_path = %word_array1%: V- M/ J, a5 J" }$ d
; strip to bare address
/ p e6 x+ g ^5 {' f full_path := RegExReplace(full_path, “地址: “, “”)
9 f! ]1 k% m% { y, o+ o$ v ; Just in case – remove all carriage returns (`r)0 _8 R( t; X. h m& f- r9 Z
StringReplace, full_path, full_path, `r, , all
0 I) H5 U6 C0 V$ @5 h) d7 z IfInString full_path, \7 g0 W! f0 p( J6 i) S9 H% f
{
" I- C' s0 w" Y8 w7 ^ Run, cmd /K cd /D “%full_path%”
& S8 o4 ?: W; P+ X }
# E3 |* P. w$ h3 o9 d3 Z else: B X% ~+ t2 z6 Y3 O
{5 A8 M9 ^8 h4 S$ Q7 D+ W# D' S
Run, cmd /K cd /D “C:\ ”' k$ v9 i) V" m4 c& W2 G
}
. ]( h6 [ V/ s+ Z% Y2 x8 _ }
. h2 K& w" j2 m7 ~5 H. K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 c$ T" g8 ~4 N0 Y( O; j: p
这段小代码肯能有两个你需要修改的地方
3 r* Q( x# ?+ ? 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
, `' U/ V6 x6 M2 Y5 f# {6 N c 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 n* m& f: P6 }& L$ w
|