此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" q8 ~" ]0 X5 u) S# J& R 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 h9 X* `: S' w5 @& s' t2 V' N. ` 方式一:6 Q0 i# P- |6 p& L0 t# r1 W
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ |2 q4 d, @9 |: v9 K3 w1 [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# ~5 Q1 @% d9 j& S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 S6 j7 d. i" b" K
方式二:+ {$ t: C0 ]2 {7 P) j6 Z- W
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
2 k7 |9 l6 ~! \( U. {2 C0 k$ [ SetTitleMatchMode RegEx( A6 g+ P' K% E0 ?! @- j8 Y$ l
return/ L! N# M6 d- Y0 E& H
; Stuff to do when Windows Explorer is open8 Q2 l+ u* s9 N+ _
;
8 Q H2 \$ F1 Z, r/ G8 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass
- e7 U* w* |7 D( f ; open ‘cmd’ in the current directory$ W$ y. J! i# T
;; I0 s- P# g6 Y# W4 a
#c::1 W' a, A3 \3 s% d& s2 }/ C
OpenCmdInCurrent()5 X( `* d, }" L
return
2 `, C' ?, Z' \+ A; g( ] #IfWinActive/ u3 [5 |3 u: ]( }# n$ n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.- G2 x s) D" H5 d9 F4 g5 W' v
; Note: expecting to be run when the active window is Explorer.& m' a6 m9 H* `4 n7 t: a
;
, h y7 }$ m3 Y2 \* c6 u$ v OpenCmdInCurrent()3 I% k4 y/ O4 X3 o N
{
0 @, f! n$ e1 U9 U; d9 t1 u F& Y& d ; This is required to get the full path of the file from the address bar
% C( S# C# w) Z5 L9 ?$ C6 w WinGetText, full_path, A
: v d q0 R6 ]$ K. W; z ; Split on newline (`n)2 d Z+ D0 c! H, I7 {
StringSplit, word_array, full_path, `n
* b5 k# t) C7 a ; Take the first element from the array( Y3 r& u3 A% _/ d- O8 a+ D: l
full_path = %word_array1%
- Y9 c, |7 U3 g# E5 h* G ; strip to bare address
+ w6 b+ i9 e/ F. i. _1 q full_path := RegExReplace(full_path, “地址: “, “”)
+ Y/ m8 p8 b: R ; Just in case – remove all carriage returns (`r); K4 y8 q. ]7 {/ J& N* W% {. i7 X$ k
StringReplace, full_path, full_path, `r, , all
% {/ }3 y" E# W' ]& u# a: l" n% i0 x IfInString full_path, \9 _' A4 f' m* Y' ]- \) y7 L
{
9 ]3 E, l5 p. b3 i% A* M Run, cmd /K cd /D “%full_path%”
3 I7 J( L* z& W( L2 e6 V, k }
% ^# g$ M; x% w n else2 `5 R! [# h. e) G# n
{
6 G* G7 q3 \; V Run, cmd /K cd /D “C:\ ”
9 M" q2 V7 X1 i/ k9 G }
5 Y3 u) U% ?) I" S$ d6 ]! `: j }
, Z6 Y& D. B @ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 b8 N/ U/ }7 C7 I; B) y
这段小代码肯能有两个你需要修改的地方* f' V) v5 O; u H
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键9 k) z7 V4 X# c2 g/ C: c2 j/ {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 |5 l3 Z( b- y- @2 g0 E% ?$ _6 K4 R |