此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ B1 h- @ w3 p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。/ \" x0 A' [, f" }, E
方式一:9 q% ?+ A+ f7 f& P. a
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,% L# h6 g) z( c: i7 v1 N- B8 B; G' V
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 c) `7 i. n' V/ z$ {- r HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 v/ ^" I' u4 u0 @4 U& Q 方式二:% A- P- V% T- K: k4 Z4 d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) i" L. ]1 Q2 f5 i& S SetTitleMatchMode RegEx
9 o' F( J) J/ o return
% l7 _' n9 E5 \8 l- y8 _ ; Stuff to do when Windows Explorer is open* c$ U8 r/ Q" N% ~0 ~3 ^% t
;: V e Q+ |! Z: I1 ~
#IfWinActive ahk_class ExploreWClass|CabinetWClass7 q* E5 ]' ]$ C
; open ‘cmd’ in the current directory
! Y# `1 _) u9 O8 b4 N ;* R9 h0 u% |. Y0 p
#c::
5 I5 |9 c( N+ i! J4 h OpenCmdInCurrent()# @* s9 Q4 e7 {" \4 A3 _" K6 F
return" p: V0 M7 U3 N5 |4 t" Z
#IfWinActive( v; o3 E0 w: h! B; n, f6 t. O
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% n6 _4 m9 @/ i" t5 \+ V
; Note: expecting to be run when the active window is Explorer.2 Z2 p+ ]$ C' I8 e |6 W- A1 x
;
9 T* K: g# S' }/ \& X OpenCmdInCurrent()
+ p/ ?4 }. K) J: p {7 ]$ K5 T) g, V% T; j9 |+ E! W
; This is required to get the full path of the file from the address bar
$ j$ k& \; X. ~) E3 x& g! s" r WinGetText, full_path, A3 ?. O$ e- J$ r$ B
; Split on newline (`n)4 Z( p' h, h$ H7 {3 c' D
StringSplit, word_array, full_path, `n
0 `" f( M: q' H" m ; Take the first element from the array# T9 N1 o1 ]* { f
full_path = %word_array1%) u9 k6 }/ k' R& y/ V1 P
; strip to bare address/ o7 h* a6 D: D/ T
full_path := RegExReplace(full_path, “地址: “, “”)
% [5 j# r# p2 s+ { ^+ n ; Just in case – remove all carriage returns (`r). h2 |8 W" W V; z% _) R
StringReplace, full_path, full_path, `r, , all
. a3 Z: D. X* h* m$ ~; u+ x# u/ H IfInString full_path, \7 i; x( F8 L( U. ^- b* a2 J- C
{2 t, ?' a9 Z6 K& u/ T4 d
Run, cmd /K cd /D “%full_path%”% u5 [2 K. W/ C' c5 _
}
/ J$ @) u) T) y else+ M& ^3 e0 O3 U! C
{
' {% t' b6 ^! p. ~4 ]+ V Run, cmd /K cd /D “C:\ ”
7 a5 F3 i2 Z0 S/ y+ d6 O u }/ \/ ~# R# _) b, r1 e
}
9 S- q0 H8 |5 a8 k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
, |" i' C4 ` ]# }6 A 这段小代码肯能有两个你需要修改的地方
v% M7 K1 f( C7 e0 S0 o6 P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键2 X' a! C0 x; s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: u7 d% i: A* @- |( e |