此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( m( i# o, ?' ^; i4 O& Q z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
7 S g( a, {, O/ k" m# H5 _) L 方式一:
2 q5 n' |3 y; p& e6 E ]5 o/ l5 Y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 U1 r; b+ P) }$ Y9 n- u 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和1 m- `* u3 }; Y1 t* H% q0 T6 y
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ v) u5 D* ]; [8 V1 [$ @, J
方式二:
@3 Q8 Y. _% A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:& L, p: d4 r* b3 G3 z* M( l; y
SetTitleMatchMode RegEx# g: g3 C, G: o5 z( I
return) Y6 t2 Y2 q, X% `
; Stuff to do when Windows Explorer is open
2 s; J, i9 j4 M. y$ y, f ;
$ n; o: e! n H. W' Y #IfWinActive ahk_class ExploreWClass|CabinetWClass" k$ ~9 V$ T9 }( l
; open ‘cmd’ in the current directory! r$ w+ [6 H8 A. w
;: S( M: p$ i, I F7 l* ^1 N
#c::
( K& a/ ^; |" v* t+ J OpenCmdInCurrent(): X+ X: ]3 V- T/ D# l. T
return+ D, I+ V0 ]! Y3 E
#IfWinActive" q. Q5 N/ r, ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
/ I+ \6 s' R) q2 f; T+ C ; Note: expecting to be run when the active window is Explorer.
, o" x9 y; `0 E! L1 c; d" n! |% n ;
# n; {0 @( Y' Q OpenCmdInCurrent()
) t, z' k+ R& q& r" E9 Q- [ {; w; q7 T- P, [+ [) r' K
; This is required to get the full path of the file from the address bar
- C4 z; t& F* g3 K) p! i WinGetText, full_path, A" n# @: m6 g, _+ b( v3 M8 l0 T: |
; Split on newline (`n)' |' K f7 e: W$ k' k5 h
StringSplit, word_array, full_path, `n8 c6 H4 o8 @8 @7 V
; Take the first element from the array/ F7 d- ] e3 n
full_path = %word_array1%% v! I" b5 c; i3 V
; strip to bare address/ E+ ^4 I r5 [: v) Z' r. S' J
full_path := RegExReplace(full_path, “地址: “, “”)
5 W$ ^- e j! W ; Just in case – remove all carriage returns (`r)* `7 B; M9 }: W
StringReplace, full_path, full_path, `r, , all
6 P4 g2 t3 T) j/ r0 U/ M9 j3 P IfInString full_path, \$ ~+ U# e1 ^3 `; P. F
{% P/ k% Y& O+ ~* b
Run, cmd /K cd /D “%full_path%”2 j$ `5 E6 z$ }- z
}
0 ?$ q: Y; k! K* G else
. P) Q$ [8 z# I3 z {+ E7 N( ]0 l5 r! A" M4 q
Run, cmd /K cd /D “C:\ ”
; e. [! [3 K( e; N" v }" P! {; l% B/ z9 I) J9 b" b/ ]- l
}
; o, f) o+ N4 A, j 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
; j% ?- v& m# ]8 C3 e 这段小代码肯能有两个你需要修改的地方
2 M) l# Y+ T4 ~+ M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键 b7 l4 ]; R9 x: ?3 b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 j6 H5 S. @/ Z2 c; Q5 y4 [0 J |