此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
) S' Z$ M0 I" h1 |2 N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! @# F: m* \, Z6 H' m4 j. M1 v) ~ 方式一:; _2 I9 m2 G+ ^. f$ q" W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* C9 \' a* m; \ N, J& v3 R5 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ }2 Z1 o' s) W8 h. }
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& r5 r$ a4 d3 ~5 l: ^! A
方式二:& Y" e* q7 X- J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* s& c; b( \# q& V1 `
SetTitleMatchMode RegEx
7 k& Q3 K# c: x x9 R m* S return
5 U' p7 c$ }5 V. e4 F ; Stuff to do when Windows Explorer is open
6 c0 a; k& J0 y- E. z( C. S7 y, \ ;3 \% J q1 f" v0 ]. s$ ^' Q
#IfWinActive ahk_class ExploreWClass|CabinetWClass
S( i9 M: k4 m" E, ]$ w ; open ‘cmd’ in the current directory, e i" l6 ^0 K5 y* k# w/ S
;
0 h1 ?5 c7 Z4 y* T6 R #c::
/ f: Z, s+ f3 V {, l8 M! R8 J9 y" k OpenCmdInCurrent()
* v% `" u# f9 P H, p return
1 k) R; g* r9 q6 f* C #IfWinActive, m% m, C, x0 x/ K) k5 [( j. o
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 L9 p' c( x- E# J
; Note: expecting to be run when the active window is Explorer.
$ S( l' e9 }) m( S- K9 p+ r: K% K/ A8 J ;* q5 o" e; }+ }( c" T
OpenCmdInCurrent(); w2 M2 L! ?; s5 {( v6 R
{
/ T9 A. g$ R* F6 p! W1 \ ; This is required to get the full path of the file from the address bar
( l# M0 E% |- k# k& H WinGetText, full_path, A
8 G% ^0 |6 ~! l. d4 L ; Split on newline (`n). V; y0 H+ x v9 u+ O
StringSplit, word_array, full_path, `n
! P0 n! f9 s$ M% q9 |+ R2 I ; Take the first element from the array
x0 h( Y1 M# m. S) z full_path = %word_array1%
5 `0 k- v+ k+ [9 |6 p ; strip to bare address9 T2 `: R( G/ u$ d
full_path := RegExReplace(full_path, “地址: “, “”)
7 O* @0 D+ T" g, _* C6 c ; Just in case – remove all carriage returns (`r)
: B: f$ W- e: c4 U/ R StringReplace, full_path, full_path, `r, , all
( V& X, Z" U! d/ Z$ U5 N7 V. n IfInString full_path, \
0 l9 ]* k- K8 e$ o. a& W {6 L1 ?7 E8 H6 F
Run, cmd /K cd /D “%full_path%” Z' K5 }) a# h7 l+ M
}
$ _# [0 _1 }' e# X4 O else
2 S' E9 r, R5 C {1 @7 v! Z0 q% u$ D e
Run, cmd /K cd /D “C:\ ”3 H( D V) z- L2 X
}
; P* S) o% j) C- k$ M }( G" D$ v7 h6 V# E$ \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 k g. i T- \- L' A7 F0 [* r 这段小代码肯能有两个你需要修改的地方
% _$ r9 ~5 O$ x1 S 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ F, G0 V: U: K3 l* A. G 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( {: t; l4 P; v2 M' f/ P& _
|