此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# V8 ^4 v- f* Y( E) x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, K8 t. b7 j- B) Y+ I- L
方式一:+ O! e# n6 g- k+ c1 K. S
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 I: u) U9 D: l& w7 t$ S 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 G6 s" ^% T0 e* E; P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 C. t+ v1 M& ~* G- N 方式二:
& {$ A& m" q" R+ G+ M$ w* m2 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) x1 I4 M R! V SetTitleMatchMode RegEx- p( u; U/ _6 o
return. j+ @5 X6 s1 S& ` {6 t
; Stuff to do when Windows Explorer is open/ s. E; Z" `+ q# k- o1 J, i4 X
;- w( J' i- m, e [! [, b1 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! a2 v$ ~# E4 D ; open ‘cmd’ in the current directory( O1 K8 Q5 ?, `$ m
;
, O) S5 W3 L: y7 [/ z2 z' n #c::
% V: }* [' A8 R4 ` OpenCmdInCurrent()
% i) @3 w. F8 R# x+ G0 o6 X; f" F1 k! i return
$ Q8 w d$ G% P) i; f #IfWinActive
, H2 @% T; u4 p2 u* Q% a9 b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 x P- `7 x* h% | O* A
; Note: expecting to be run when the active window is Explorer.* |3 z/ d+ V6 W% T
;/ C: n. e/ U" r4 `# Y
OpenCmdInCurrent()
: P' H+ ?. l1 N1 @ v9 Q {9 } X9 Y' k1 x q. \+ ?
; This is required to get the full path of the file from the address bar
O$ E8 ~- j, g& Y$ b WinGetText, full_path, A2 U. U; U, Y( O' M& z% Z( P4 _
; Split on newline (`n)( U$ ]6 V. ^" X6 T" R* U% k% \! S
StringSplit, word_array, full_path, `n
, H' A3 S! l G Y; H0 T- T, R ; Take the first element from the array
( G4 u) W" V# _, l2 j# O full_path = %word_array1%
. l# n5 [' ?. ` ; strip to bare address
' Z* ^2 S8 w* c! e' \ full_path := RegExReplace(full_path, “地址: “, “”)3 x [, Y7 Z# r' D8 a/ S$ f
; Just in case – remove all carriage returns (`r)& H! S8 K" t' @% q
StringReplace, full_path, full_path, `r, , all+ n J+ Q$ ~- ~, `5 P5 l! x
IfInString full_path, \ c( s# D% r/ v4 K7 [; I" r
{4 G6 M/ D3 T9 e' {, V0 L# N
Run, cmd /K cd /D “%full_path%”8 H/ y5 s9 E5 h2 o9 y
}) v, P" f; N5 t, L! F9 B0 k( W/ ?% G O
else
6 w' g2 T( r( q- d, {+ W3 b {1 c' H: B5 E6 f4 M# [' m6 l- A) @& X
Run, cmd /K cd /D “C:\ ”8 `# X/ q" T* I5 F( `
}9 p% t/ H! O p- a5 _, g
}$ ~4 q0 I7 d) M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 ] t& ?% |) {% P
这段小代码肯能有两个你需要修改的地方
# c. o& ^- f D4 l 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# N0 B- ~7 J9 N
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 u( Y. s7 A0 k2 w6 e, N3 {; p) b9 C |