此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 C- c, |7 Z: M6 i 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 T( c6 _( w5 T& ^: ~! u4 D. a) h 方式一:
% ?, r; Z# Z8 y& W$ K6 D4 s& _; J 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
9 f% d1 I% M. \7 a8 }+ | 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 s& V* A" R( {* @$ r' g4 X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& ^4 ?- w1 I# u4 _5 `* n 方式二:# p+ n/ _* ]' w; T$ B( M* D
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" o3 p: J& P& H8 ]8 X SetTitleMatchMode RegEx
( j2 V* U+ z! H5 O2 M return
4 C. Q8 p0 H" y$ { ; Stuff to do when Windows Explorer is open
4 ]+ n7 g8 M0 ^ ;
7 N" g* K* d. Z; D #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 v6 B7 u- E# D1 Z0 f( g ; open ‘cmd’ in the current directory
( N# s s5 y% i( J Z ;% M7 P3 J2 I5 m2 a' z
#c::
) P+ y) ]& L, ^ OpenCmdInCurrent()& [+ q' G( m! ]: I: d2 P* Y
return
) I T7 w- w" o #IfWinActive$ N; ?4 Y5 R4 D4 L; F, G
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
# q8 N4 G; g8 S, y ; Note: expecting to be run when the active window is Explorer.1 t. `+ W# J7 X9 L1 d1 P
;
, i% B$ i" N6 v( U. a OpenCmdInCurrent()
' l+ e: l! k7 {/ K {
" d' ]. ~, D' J& _ ; This is required to get the full path of the file from the address bar' ] `( P6 S! g4 _( u
WinGetText, full_path, A
; ^) O, O1 p# |9 o+ K ; Split on newline (`n)
/ y% _+ A+ Z! Q! s StringSplit, word_array, full_path, `n
1 d5 S/ m* m) M Y# l ; Take the first element from the array* h6 x+ _* e, s
full_path = %word_array1%4 T- A ~( s3 x! K" s0 z4 H
; strip to bare address: @- k4 D% B- y5 k8 q) X' W
full_path := RegExReplace(full_path, “地址: “, “”), d+ R5 q/ v' r) D: u2 g' a( L2 N3 [
; Just in case – remove all carriage returns (`r), n/ i6 }5 ~: H; {' j! T
StringReplace, full_path, full_path, `r, , all, N* y! c( l5 ]4 f Q4 S
IfInString full_path, \
7 {( B/ U2 R' x$ x v, ~ {8 X; S- `; F' I" n
Run, cmd /K cd /D “%full_path%”
6 r6 i4 `5 H. i; X9 B+ b }
' G# u" S ]: l$ |4 K. a else& Z% c7 p% k: d
{
: C9 w. p7 j8 z' j' h Run, cmd /K cd /D “C:\ ”( Q1 {* c; V8 k% F' L0 k- v/ q
} T+ N# ]% l% z1 _* T
}5 ]1 S( R7 m, _+ U* D
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
' d3 K( e. a8 D" n _3 p 这段小代码肯能有两个你需要修改的地方
2 Z$ \' Q9 v* V ]" y5 k! t5 U0 o8 |5 X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- O, J: t1 m( v2 A+ b
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 p8 V3 r. i. U9 X2 N3 C! P; t/ z
|