此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
8 }9 g1 U$ n/ l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' {! D% V$ J0 ^5 Y0 Y 方式一:. H6 j2 g3 X2 [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ L6 M; C$ t9 j* q% o/ V) Z, }2 n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 U. t( q$ g- G4 d+ l/ P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 `- V" S2 U2 o4 r
方式二:
. s+ u- U% K1 d( A/ L8 {9 H 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! d8 a1 q& f% N; ?: @7 c" J0 T/ @
SetTitleMatchMode RegEx
5 Q2 y& P/ }( U2 V/ R: e return
! G0 a0 A1 P2 k' S: C ; Stuff to do when Windows Explorer is open
2 W& z f1 J' `) I$ P( H% a9 \( R% i ;
3 I- X/ O D% b! b6 C$ ^" z #IfWinActive ahk_class ExploreWClass|CabinetWClass
% _; J: m7 H( @% u3 t: R" C4 S- e ; open ‘cmd’ in the current directory# W1 [: n Q% }# k. W5 P
;
$ W0 _6 p1 U2 A S' X5 S1 F #c::# _9 C0 {' y: |8 p
OpenCmdInCurrent()' h J+ X$ ^% S
return
- D8 R; G2 M. |1 l5 c9 z #IfWinActive3 H7 Q; J0 T3 H$ F! ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 C7 ]2 g: L3 x1 P1 O, c; a2 `$ W
; Note: expecting to be run when the active window is Explorer.
0 p. Y* v8 Y0 W ;
- t, j& b0 Q7 A7 F3 V- r% r* L8 l OpenCmdInCurrent()
& ^* G9 y5 a7 f+ V# N {
" u" m" N& A( a) O0 t: c1 q2 c. n ; This is required to get the full path of the file from the address bar
" R' D2 v3 Z6 N% C# n9 M/ J; O x WinGetText, full_path, A
" W# b. l3 w: q ; Split on newline (`n): @+ }; | n* D' z. l. |
StringSplit, word_array, full_path, `n) q/ o8 V$ U; A% ^. E3 n
; Take the first element from the array
) H4 w" D2 N4 F, y/ n0 Q. N8 y) ] full_path = %word_array1%7 ~! f( x' P, k0 {, j( W1 O
; strip to bare address1 ~- }2 q8 \) ^$ P
full_path := RegExReplace(full_path, “地址: “, “”)
: ^1 O" Y9 N, @$ Y5 A# X( f0 x9 D ; Just in case – remove all carriage returns (`r)" _/ R; U0 |3 q# l& \
StringReplace, full_path, full_path, `r, , all
9 f3 H0 x3 ?* m# z IfInString full_path, \' P7 [! N9 g' ^
{6 @5 f$ Z% \: T) K
Run, cmd /K cd /D “%full_path%”
M+ Z1 E; y2 p' U } m* W- c' k& T9 {2 ^3 O
else
; n: Z6 p( E, w! }8 a9 f {
3 B; o, `, N) i Run, cmd /K cd /D “C:\ ”6 O3 Y" W1 w4 U9 ]4 y& k: U& D
}) [' p ]( e. W$ n& M2 t
}6 W# F' D% P% s/ }8 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ T o! r3 J! o9 R# \) d 这段小代码肯能有两个你需要修改的地方% r# Z. B K$ M6 z7 f
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 i( G6 f$ |, h/ p( j
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: d8 P% V8 g9 b x4 n: ^- O |