此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& W t7 E) P# e# N
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ J3 e; F5 A( h# R
方式一:
0 w) w) L# j( h! R# y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,9 o- K3 x. c) j5 L2 v1 J& v, y0 C' C
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 M8 C- e- J" h, B A8 A HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 M C% T! K) H; u, G 方式二:% M+ V/ T1 M4 z+ J B4 H" k' z; z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
9 l8 K5 v7 u$ n- \/ k n0 u" H! d SetTitleMatchMode RegEx
7 A% R @' p: o1 z9 J# q" } return
% M' G# }; w8 U! I% a8 E) i; k- f ; Stuff to do when Windows Explorer is open; `+ Q+ Z A% ~6 [/ H
;0 s1 M9 T8 J, a( E, ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass
. s4 M0 I% s2 b+ k ; open ‘cmd’ in the current directory
0 o0 m$ p0 U# m ;" b) B( ?, P" j/ P& F, A
#c::
2 ]) s6 C, _- v ? ` OpenCmdInCurrent()
& G/ E4 M \( l9 E% k+ Z% P! o! h return
9 M( s$ X: n2 s! ` #IfWinActive- s" Q5 j0 ~3 k* d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.5 u) x% _# H1 s8 b1 W
; Note: expecting to be run when the active window is Explorer.
# C- e1 i, g$ l/ Y& Y0 a' k F ;5 X# Z2 t7 f3 c& U. T- U
OpenCmdInCurrent()2 y1 J- H# P3 c( N
{
/ [2 _8 s3 {3 S9 [. z { @ ; This is required to get the full path of the file from the address bar
" u: ^% C: C. U4 f: O" P* [ WinGetText, full_path, A
# @6 U& j8 H4 E; A( e Y0 A ; Split on newline (`n)$ v ?/ R: S" S% S% U
StringSplit, word_array, full_path, `n
5 t6 @2 i) O% B0 t1 Y' O ; Take the first element from the array! m0 e4 L4 M( |1 x" g9 c$ g
full_path = %word_array1%
6 f7 l5 K/ ~* O! H/ ^2 A* R ; strip to bare address
5 |7 p( N5 a. n5 R) }( O6 x full_path := RegExReplace(full_path, “地址: “, “”)8 M" c+ o0 x$ u# Z* l2 w* |
; Just in case – remove all carriage returns (`r), C* U1 o4 Q' G4 R2 d4 d/ u+ }8 S
StringReplace, full_path, full_path, `r, , all4 T/ Q! `' s5 M }$ S) u" G9 {
IfInString full_path, \ h2 C* @5 z: Q5 f0 Y. {
{6 ?/ o: z! ?6 X% G4 x1 S* i" i
Run, cmd /K cd /D “%full_path%”
: c, w. `5 l* t& _0 D" H( x9 P }' t% S" s B' T( o* I- i
else
, `5 O* \3 J, v3 `' V, ?! D {, c5 E8 J. n, u+ E0 E+ r/ J( x
Run, cmd /K cd /D “C:\ ”
% H6 b7 H/ F5 s: ? }* a% N0 u2 S8 X! ?9 ^7 U$ o, N
}
# }6 B0 e) U8 P6 P' x 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% Z/ L2 J+ E) s+ p1 k
这段小代码肯能有两个你需要修改的地方" @0 C h/ d6 c6 j0 A" z7 U1 |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ ]1 U, x1 P* n2 }- C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* B' O/ T& Z! } |