此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ X9 x. m* p" T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
5 s' n- r. R7 |6 [ 方式一:
8 N$ ^5 O9 W. M7 V0 t 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 \ c6 v- R' Q3 j. K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ ^/ [0 C3 u' e7 K# q, K HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 e6 |! E5 l4 t 方式二:+ D9 }6 U' J4 Z D1 p. z
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% S, x' R' D" V; i% p( R1 q
SetTitleMatchMode RegEx
" ~0 D0 N- V6 t' w2 @; s* h: U return6 H' V/ M' _- m9 T. v3 Q4 @1 z
; Stuff to do when Windows Explorer is open& B9 \# h6 R- w7 O
;) K8 ]: O$ K+ ]" i
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 I2 E) Y3 u% Q/ w, e& O. g
; open ‘cmd’ in the current directory
# k1 j: c9 l2 ~2 n, ~ ;
& h+ C; R% m2 F #c::
4 S" ^2 Y8 V/ V, _% f T! G" k OpenCmdInCurrent()
( E4 Z' Q& b: C' @. x1 N$ [" J return& t) s3 x- b( I2 _. _( z" P2 ^! x
#IfWinActive* y% \& S3 {$ ^1 N* v. i
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; ] q- Q, ~' p1 k" i
; Note: expecting to be run when the active window is Explorer.% E$ ^- I0 f( v; A3 G. _
;+ |' G! J# E2 h2 J
OpenCmdInCurrent()! w, [5 q1 v9 q0 n/ i$ L; G3 [
{
3 ^4 g4 w! X4 D% H6 p# D ; This is required to get the full path of the file from the address bar
& K: p+ K0 U* h( e WinGetText, full_path, A
6 L" f" V2 m. o ; Split on newline (`n) y! ~ M; V0 U7 @2 S8 z) A
StringSplit, word_array, full_path, `n1 I# w3 L% `. K: x7 n: f
; Take the first element from the array- w) {' W% [5 a' n! r5 M; r
full_path = %word_array1%
v# m6 u) c" b% m6 F ; strip to bare address' E6 `5 F2 u- z8 K( l/ @7 e
full_path := RegExReplace(full_path, “地址: “, “”)1 H! d# l9 w2 r6 {1 _
; Just in case – remove all carriage returns (`r)
7 e+ a/ H& R* P4 a' D( @* s StringReplace, full_path, full_path, `r, , all
( [4 v7 D% S* ~0 p4 x" ?8 l IfInString full_path, \! R9 n$ i& D9 l1 C" w$ ~) ~2 q0 d% Q
{
7 U1 L5 k+ N( @9 P8 b; j Run, cmd /K cd /D “%full_path%”
' q4 u5 T* e5 c2 D3 ]% w3 X }( x# }' t0 Q+ B
else6 M# o2 L7 j1 ~) g; Q! d4 r4 g
{
5 }! @# a' ^9 @9 m) x3 { Run, cmd /K cd /D “C:\ ”
, _0 H, u; K+ z" l+ K }
/ N5 E9 _& \2 h }9 M/ f6 f% L& Y8 z: w: X, D
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
1 K4 A/ a2 t [( y# A! v 这段小代码肯能有两个你需要修改的地方
; Y1 U( F" |) W9 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
& _" s% G- D- G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 |: _' e0 Y5 o' V: g% u
|