此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
' m: p! N# B" r/ g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。# {5 {/ q! N, t4 h
方式一:
2 I" {4 R1 d+ i/ L 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
+ G4 e9 l; H1 k# r0 @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) r8 c6 [, ?' \# Z HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 y& O; n( \. W- C; b( q4 S
方式二:, i8 @7 C5 k' _. [" D, s8 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 T1 I; i3 ?( K: d SetTitleMatchMode RegEx% j9 R1 a: ]: U% ^+ S
return9 ^. f+ m8 ]" S+ J0 J4 Q
; Stuff to do when Windows Explorer is open7 l3 T! N d2 [
;; q( w6 f5 y! C; o( T. r+ z! z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
5 Y- E8 ]- g: d& h+ \ ; open ‘cmd’ in the current directory
, \# t4 Z' Y4 K: n! { m. C8 W ;1 {# h; W* I7 Q' z6 }+ U
#c::( e; z& T# R& |5 R; ]. e' J
OpenCmdInCurrent()
; i( t/ @) [" M, Z return
) w- J; R; E% @3 f) v3 i0 t #IfWinActive
' c+ |$ P1 C- C: o/ u; y# Z ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 ~" i# B. V( m ; Note: expecting to be run when the active window is Explorer.
+ _0 L- u& o B$ l8 J( _ ;$ N; ^3 ^$ q( x+ B( z. }
OpenCmdInCurrent(), D) p G# x9 _# p& [4 V
{9 G& \, `* s4 u; i
; This is required to get the full path of the file from the address bar& C j5 V6 H _; K$ C
WinGetText, full_path, A3 h1 M) Z/ O' u( H
; Split on newline (`n)$ Z8 m1 D% _1 P
StringSplit, word_array, full_path, `n3 c: p" i9 g/ ]0 ~7 }# \* B
; Take the first element from the array
" k5 n. ^4 r" I" s, L full_path = %word_array1%! M8 y) _0 v3 `2 L5 q
; strip to bare address5 `, G! f/ b, S
full_path := RegExReplace(full_path, “地址: “, “”)& q, F, c. G* h3 p$ C5 h
; Just in case – remove all carriage returns (`r)0 |) \& Y0 O4 d6 ?7 O* ?- q
StringReplace, full_path, full_path, `r, , all) }/ o7 `- n' F; Z7 D/ ?
IfInString full_path, \
$ a7 h+ Y/ d# a9 V: \9 [3 t {" M' x$ I* c6 \
Run, cmd /K cd /D “%full_path%”8 f( e/ H9 g' b( B6 P; H" M3 ^% }
}+ ^& T$ y! L0 L( O% L; V# N
else
7 C# P5 T/ K3 L. v7 ] {
% x; g2 H3 \- n7 F5 D Run, cmd /K cd /D “C:\ ”
" c! _4 c0 D# n- { }
! A1 c8 \ ^7 s* U( G3 C }
' S- w" K0 F- }; G0 _ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# R" u! v" w8 v5 G7 z* k* _ 这段小代码肯能有两个你需要修改的地方) t5 @+ ~8 d! [( B& _9 W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ j& w5 _1 R% v! O+ f) w7 ]: e
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “( z! H! Y- M$ H: w5 Y
|