此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- ~# b! d7 f& x# }8 O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 A( b( h, x8 U& d% n 方式一:
2 Q a3 u3 t% {% U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; s- e7 u7 J/ A. n9 E e2 k: ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* \0 U" N/ h9 T2 o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 r, X4 e# s# V. J
方式二:6 L4 R3 L7 `! H4 v6 b3 ], o
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
8 ^% ~$ E3 x5 a2 s8 H0 R- z SetTitleMatchMode RegEx
+ T A" _6 a1 B0 {# N. b0 O return
! F8 |1 |! V9 B& Q1 }8 l ; Stuff to do when Windows Explorer is open. u Y. [: ^( B% X6 O* ]2 C
;. b; @' q/ ?5 [5 w5 n- P2 b
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ i( m2 o' x' N$ T, M ; open ‘cmd’ in the current directory$ s7 ^7 l3 k0 y
;
6 s i" [8 P: Y" J8 h) H2 u# Y #c::
5 l9 N- l8 K, j OpenCmdInCurrent(), N: U- U4 }4 X0 V r
return W9 z: x0 h9 W7 Z3 S n
#IfWinActive
" s# Q* n* l: x( y t ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- o2 h0 H) A! E$ B, Q ; Note: expecting to be run when the active window is Explorer.
2 `/ n* m4 @- d u ;
* f8 d( l5 x- V! h; {) Z9 T OpenCmdInCurrent()
5 w% Z, O% G$ A2 E$ B, ` {: m+ F1 `: D, T" l5 Y& m& Q% z
; This is required to get the full path of the file from the address bar7 \+ Q" |1 ]! ?. k3 v
WinGetText, full_path, A1 o1 ~# G5 r) h4 W! ?9 R
; Split on newline (`n)0 Q& o! s% [% d2 R0 Q
StringSplit, word_array, full_path, `n
% R! d5 d4 E3 @; M* ]* s' S ; Take the first element from the array
; j; v; W2 H8 w: T full_path = %word_array1%
, r! K, `9 T1 j. q" d- N4 B ; strip to bare address# q$ F4 D" K& x6 }5 u# {+ b- X
full_path := RegExReplace(full_path, “地址: “, “”); i. O" Z4 u+ T- |2 X
; Just in case – remove all carriage returns (`r)
4 n4 |! F# S; B3 f StringReplace, full_path, full_path, `r, , all
0 F8 g K5 u: R$ V8 v4 `& I+ ~ p IfInString full_path, \
3 P) H( V" w! v9 _: b) B( a {
P4 m4 a% s T9 t- l Run, cmd /K cd /D “%full_path%”) e+ W3 V/ e b) b* k
}
, s! `! ^* O" A9 ^" B else g$ A8 _! V7 {* W
{! C5 m/ [7 [9 h
Run, cmd /K cd /D “C:\ ”0 S7 h. o, t1 H' Q- V% y5 ~
}7 ^/ J4 g! j( p
}
4 p" c& U- d* P. ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ M/ v1 K6 Z( ~7 Y 这段小代码肯能有两个你需要修改的地方
% ^# a% E, h+ x. v+ O v4 E- C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% W4 @% n9 w; j% e2 b& H& K 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 x! l$ s0 _1 s |) | c9 v7 a0 [ |