此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ b- t8 Y7 b1 F3 ^7 x$ I E' f' ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 b7 e! o( m: t4 o9 G& W. e, v; ^ 方式一:
) Z: v& \4 L" k' \/ T. B+ y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( ^( X3 c8 s" ^- M4 U9 k4 O, R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 _ `2 o$ _/ _' B6 q7 R. } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& v9 T; `8 D* H$ v- o' H3 Z
方式二:
7 {% B* a5 N& k. {% B6 U- i# y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% N8 t: W( W5 X) N$ y% B0 c1 u
SetTitleMatchMode RegEx
8 E& @: d% e3 E o; } return
& i- J- N5 d2 h4 a+ P ; Stuff to do when Windows Explorer is open( V" C6 E; j1 k
;; q' D, Z( F( ?3 k6 L' S' i
#IfWinActive ahk_class ExploreWClass|CabinetWClass
' O9 b% @2 e! \+ f# ?: p2 J5 j ; open ‘cmd’ in the current directory) e1 Y; A0 f" Z7 w- j
;% e! I0 |3 f& L# U6 [
#c::6 r. f) ]. T! B, k1 c
OpenCmdInCurrent()
2 O& |. t$ i5 S return: X; {$ o( X9 u% X8 f
#IfWinActive
% T# Y% ?9 l5 S( o$ ]; m& L) e2 U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* N5 `5 E6 }: ^( a% q7 d1 z+ V+ [# e ; Note: expecting to be run when the active window is Explorer.7 K% e; a+ \* f: h9 @5 `
;
$ f1 O8 Z. X( V* s# o OpenCmdInCurrent()
; b! t7 v& Z1 G* _, ?" _ {8 f2 Z1 R' z3 B/ z9 H I
; This is required to get the full path of the file from the address bar
. g! t( L- Q3 e0 F( f2 S. v0 k WinGetText, full_path, A- C" ~" R% g! i2 B
; Split on newline (`n) V$ z% o [/ Q4 d* { B: q
StringSplit, word_array, full_path, `n9 Y/ W+ v4 r& B; v! k* z
; Take the first element from the array7 @& n7 ]0 n/ _4 d% m' y( b; ]
full_path = %word_array1%/ X# Q7 F- A! m: k+ g6 ?
; strip to bare address
7 }; m* N. I3 b4 H0 ^4 O full_path := RegExReplace(full_path, “地址: “, “”)7 o* w2 Z3 `3 y i8 V
; Just in case – remove all carriage returns (`r)$ D j8 X) O% s+ G
StringReplace, full_path, full_path, `r, , all
' b. o5 T2 [( m& u IfInString full_path, \
$ F' `. k5 s* }4 d* W! \" z0 M! t {3 g5 @/ O- L( i1 Z. b# ^( C4 A
Run, cmd /K cd /D “%full_path%”/ m. v& |, i1 Q( M* {8 Q3 w! y1 _7 u
}% S7 N" r/ N0 V" d- u
else$ e% ?$ O% X! J, G/ G
{6 N7 S1 F* b* N
Run, cmd /K cd /D “C:\ ”8 W" }* }$ h. l' C6 p
}7 U, L- _! N2 ]( M( L8 K
}- W* x; v6 e1 Z4 J# h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
8 i5 h0 {# n0 i2 R9 ~; m& [ 这段小代码肯能有两个你需要修改的地方, \% \( C) ~4 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# }* I* j6 L$ H7 e: P 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, h4 j! M* c# I: `
|