此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。- F* K4 F7 E5 i! a' i
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。+ p9 n; X$ P: h6 ~
方式一:
1 y) `% ^# v8 ?! u4 [6 ?& ^: I' W' _% ^# ~ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; B' Q$ H7 \5 b8 c- V2 L% R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
1 E3 U K5 k& `% A7 M: a X7 e4 a$ \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 H" ~; |& n& ^7 |2 [1 q ~. U 方式二:% s3 P2 ~, B# i! O/ a0 g1 G- p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% S+ E: b1 G0 j# O SetTitleMatchMode RegEx
0 N& q, Q1 ?9 }+ ?" R return
0 H) A6 M1 @2 P8 u ; Stuff to do when Windows Explorer is open
+ ^5 L6 K" k" F/ S ;1 d8 r* }' U9 V5 _1 O$ z- U/ P
#IfWinActive ahk_class ExploreWClass|CabinetWClass
9 i* I1 M. I% ` ; open ‘cmd’ in the current directory
6 [6 n5 I0 S; k$ x7 E! q ;
- `% `( W9 R8 c, M #c::
# H+ p; o# L2 {5 U OpenCmdInCurrent()
4 H1 @6 e E ^2 y( e0 ~ return$ P# k6 G* D1 a0 K% I
#IfWinActive
6 D1 ^5 q/ c x ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
9 H/ q, w" V! l7 s {9 p6 B2 d) n ; Note: expecting to be run when the active window is Explorer.
7 L% Z, _( R5 j( V" ]/ I/ ~4 G* H ;/ O' C( g$ x& q5 E l. q
OpenCmdInCurrent()) f6 W. { N* c+ `6 B
{( l1 j( T+ Q# B
; This is required to get the full path of the file from the address bar. m8 r' A& Q+ t
WinGetText, full_path, A
9 ~" K; h, I( d) c3 M' p* S ; Split on newline (`n)1 r% D9 B' k& @1 y, ?2 K
StringSplit, word_array, full_path, `n
& H$ O) @, [; F+ T* n ; Take the first element from the array
' e0 \ }$ C- X full_path = %word_array1%
! v6 }9 \' ?0 F; X+ v, N3 E, \ ; strip to bare address
Q5 P) n# [7 a. D$ e full_path := RegExReplace(full_path, “地址: “, “”)
2 r4 r' p C/ a/ h5 @5 z ; Just in case – remove all carriage returns (`r)
* t7 N! \) s0 `# j0 I3 F8 \ StringReplace, full_path, full_path, `r, , all! L! R" Q) X- P3 {* l! e
IfInString full_path, \
7 q/ [' w8 o1 ~8 g9 w {
5 E% g" a9 b2 g4 }# F Run, cmd /K cd /D “%full_path%”
' R. G0 z6 E0 B! C0 L7 ~/ U }
+ P1 M, o; k/ M else
) r9 h! Q0 H2 o' f; F9 V {2 p. }# F4 ?0 ~! F
Run, cmd /K cd /D “C:\ ”0 S* s. Y. E7 X4 p
}& b6 W G1 y( B+ u3 C' N, e
}; F1 i' c( x8 E) G* i' e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 J% a! l, n9 U6 t( }6 W, n. }
这段小代码肯能有两个你需要修改的地方: w6 V$ N8 O7 u4 i# R% p) \* g- Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' d) M2 b7 L8 D# X8 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% N; T, V. u; |8 b6 D" K
|