此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
0 x5 Z' T- ]. i7 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
, ]9 e0 `8 l- J4 X! R# i 方式一:! |% f, E$ a! L
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
1 w, @4 _% V4 y1 U4 v 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# V6 M: N! F6 V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ f M8 y! o5 e) Z 方式二:
/ s9 D1 `- \- n( a+ r& U% d 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ P) `) p5 x# A6 j% F `) X SetTitleMatchMode RegEx3 u* V/ V3 |: J W% A
return1 k1 {% r& z: C, q' H
; Stuff to do when Windows Explorer is open3 ? s' b3 `( H! i1 n; X
;4 d7 w8 _, V& n2 T" j/ U' C: [
#IfWinActive ahk_class ExploreWClass|CabinetWClass
; N' R8 j* P/ |: R* e' n2 ]* ? ; open ‘cmd’ in the current directory
% s; M+ J( Y3 p3 @ ;- d/ B! `& U( |# v
#c::6 f/ K& `) m" F( [( F3 V! q
OpenCmdInCurrent()
3 G N- v: f6 A5 z; g4 W1 F8 o return
5 l9 B7 ^- B1 x% j1 `8 B/ N #IfWinActive
9 s* u3 `/ I2 p4 ]) W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ D$ z" C9 [. o& p' S8 X ; Note: expecting to be run when the active window is Explorer.
* F7 T% e+ w( [4 h' u: t ~ ;% i; Q" o! N; l" ]0 c! C* c0 P* c3 L$ w
OpenCmdInCurrent()5 |* {+ N, y2 J6 r
{
+ f3 J0 z- _. ?% B ; This is required to get the full path of the file from the address bar: `& ^; U% T9 N1 V+ N
WinGetText, full_path, A/ p+ p! k: H9 J/ V1 R2 j
; Split on newline (`n)) j; s$ c. | I* N3 @+ }7 R
StringSplit, word_array, full_path, `n% C6 ?8 A9 r2 \- k2 Y4 C& _
; Take the first element from the array! ]: @; |3 j# C, @( ?: F. r! K/ F
full_path = %word_array1%
4 d( ~1 F+ Y5 M) @! O9 W ; strip to bare address! M% q! n( B8 w! P" j
full_path := RegExReplace(full_path, “地址: “, “”)
0 Z% ~" _3 F3 g- C) |% C$ N ; Just in case – remove all carriage returns (`r)! p+ f& L1 f" N" U! D) R/ B
StringReplace, full_path, full_path, `r, , all
i% ] {0 }; z. Y. g8 l IfInString full_path, \
1 U! w) M0 u$ y0 K# i* d {
. v8 X. P; a" P2 H' E Run, cmd /K cd /D “%full_path%”* T% }6 a, j) M% E! ~ m
}9 u; m% `. I t/ _$ h
else- q% J# E. x, l& L ?: }6 z
{. ^( F3 }3 X, d$ `+ X- r
Run, cmd /K cd /D “C:\ ”7 T6 N9 k/ S7 O4 B
}( b* y; i- O% R$ H1 F& \
}
8 D) V/ K# R, V' | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% O4 L1 H( E8 I1 |* L; h 这段小代码肯能有两个你需要修改的地方
9 b( ~5 A) {4 K2 c( @ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键) P" R2 k+ b. q; }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; A6 N9 q, E. h/ J1 L# a
|