此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; T. q/ c5 u" k# s 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
% C( h8 t! Q# ~ 方式一:
% p4 x8 f% I! B9 j, Q7 g/ { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ \* x3 f8 d- Y2 \ r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; Y I' n* Y. [; V7 D6 {! G" ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。+ ~5 H) q0 y* q- G9 y' M! I
方式二:
$ d, v8 _" T# H+ O' c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% _3 n) D) a0 [ g3 S8 m1 _+ @
SetTitleMatchMode RegEx4 b& c6 X, W8 Q2 h, e3 z
return- t( O. Q2 C9 Y7 h& W% a
; Stuff to do when Windows Explorer is open- h! w! E8 D7 u. A% {
;
- e3 F0 L7 o' y+ {% T8 M #IfWinActive ahk_class ExploreWClass|CabinetWClass9 h/ `: ?+ S# m! b% x$ M
; open ‘cmd’ in the current directory
* ?. r) }; `( ^$ O; E ;4 n1 G$ p8 P) f: l5 o/ M
#c::5 R }; t2 W. l: y
OpenCmdInCurrent()
* T: N* e5 X: T: B: j: V return
* \2 b& z0 d1 ]3 v8 U #IfWinActive$ b( |8 O" J- i7 W3 T' @
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* X% {8 A4 z) J ; Note: expecting to be run when the active window is Explorer.* T2 X8 E0 S, l P
;
1 [9 m6 k# D1 m' d& x OpenCmdInCurrent()4 b& @6 M. v/ z: f% {" l
{
4 r3 v( [- F& w) G ; This is required to get the full path of the file from the address bar
, l/ @. s& F: r8 c5 T7 u4 ~, l. h WinGetText, full_path, A1 t- R( o* ~' P
; Split on newline (`n)
$ A u' |* U+ I& J StringSplit, word_array, full_path, `n
: s0 L; ^4 i+ w# P ; Take the first element from the array3 T8 [9 n2 V6 ?4 x# }9 ]0 A
full_path = %word_array1%% B2 d- c8 h8 F
; strip to bare address
" F* N2 e; e8 T# R* _) o. T full_path := RegExReplace(full_path, “地址: “, “”)
4 h6 B! T; y3 J5 `4 o4 [* t2 y) @ ; Just in case – remove all carriage returns (`r)9 U" w+ ~8 q, s! v% O
StringReplace, full_path, full_path, `r, , all
1 }1 X. Z) n' ^; |/ O8 S IfInString full_path, \" U$ a% ^$ P7 f- T$ S0 Q0 J& b, y
{! S( N2 P8 v5 l/ {( X! L
Run, cmd /K cd /D “%full_path%”
, Z$ c( w! K: S }
8 t f6 A& |- l4 q% L else# e, {6 M. F: b4 K
{
! g* v. O1 R* a& | Run, cmd /K cd /D “C:\ ” o9 l ]; V- C4 M; q- j" P* e' a
}' O$ C: a3 [% X/ R" a$ G- _
}& Y& L9 L2 X5 j( ]. d
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! x T: d' N0 I: W6 o: P2 a 这段小代码肯能有两个你需要修改的地方1 k7 C2 k# b" q" |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ P% K( X$ X0 Y! Z C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 S/ U( q6 s" W5 X |