此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 x3 |0 E* r# _6 [5 J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 O. @9 P* c. b% A 方式一:
, V7 J: n' z+ k5 ~, b: ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 H/ Q4 b) l, _ ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& d- o% d+ r' S% o, S1 j
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 m. ^8 w, b1 b1 I4 D' l8 d2 K
方式二:
7 [4 K/ G% S P- ?. h; W% O 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 a( @2 p% w3 t) E5 X. `) R1 u4 K
SetTitleMatchMode RegEx0 j9 M& f2 L! O+ n
return
; x, M; L) D" u- I3 [* p% @ ; Stuff to do when Windows Explorer is open
" [, J7 }/ R: X! M" t$ f4 g, ~( B ;
: F1 N2 N& L" h5 ?! s/ m2 E( s% ^ #IfWinActive ahk_class ExploreWClass|CabinetWClass, a9 [" x$ ]3 ~5 T* b v" b; T
; open ‘cmd’ in the current directory5 A3 y1 J- I, E; i5 y
;' W1 L5 J4 U( e3 M% P
#c::
7 o- Q- }; q V& O/ S# c/ U OpenCmdInCurrent()$ h2 m& {6 Q7 g9 ?& D" H7 I
return
2 L* C0 Y' o& v6 U; p #IfWinActive
5 R1 k" k& ^; p( C3 z6 r ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 g- `" b& H/ q7 Z
; Note: expecting to be run when the active window is Explorer.) ?9 G3 i' K4 I9 O! z/ H
;7 P7 h' K5 r @) e0 T) y
OpenCmdInCurrent()
2 v1 h( c+ K, A# v4 [ {
6 l. o$ o) x' G( L5 L% M5 d ; This is required to get the full path of the file from the address bar! ?* _. i0 V% }* }$ ~- O" e0 P
WinGetText, full_path, A8 j2 C4 N/ _8 U4 P0 L
; Split on newline (`n)
1 a, ~9 l* b1 E1 c6 ~- s) M StringSplit, word_array, full_path, `n
4 q1 {/ s* E) p9 o( m ; Take the first element from the array w3 b! V* x! r! ?' ~# X
full_path = %word_array1%' F$ t( D3 a" N$ C0 }
; strip to bare address6 K. ^/ e! g1 E
full_path := RegExReplace(full_path, “地址: “, “”)9 R& {" X0 F# |) U1 j; T- `( ]4 |- `) c
; Just in case – remove all carriage returns (`r)! d; x( }7 D U
StringReplace, full_path, full_path, `r, , all
8 E4 Y, f N8 t: {( X4 [ IfInString full_path, \
$ F& {- O2 |. [1 K' [ {9 v3 E/ k4 f$ {
Run, cmd /K cd /D “%full_path%”, W4 `$ [# |+ @9 @; s6 w. @' [
}
6 I& Z8 r) ~, U& ?2 X( p! q; } else, e/ W& @ V8 b7 X; e5 O9 k* D3 j
{
9 s' u$ _6 o, K2 u; ^ Run, cmd /K cd /D “C:\ ”% E4 I7 y: _7 B# k& k: K: U) I
}8 N; X6 L- H! M+ g3 Y. V. I
}
/ W# l& h: k+ i) g1 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 ]2 \. ~) m& e1 K7 i7 h, n2 U 这段小代码肯能有两个你需要修改的地方3 K, F: [$ d% U* o4 D; h
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( a4 o# V( n& @' u
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- D, w; [+ Z+ m% j
|