此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。* {# D- Y) c/ R+ ~) d9 Z( E% z
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 p; n+ a: F4 z 方式一:
! E$ i6 S( j2 O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 E7 W5 p4 T% P9 n( z 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: }" G9 M5 Y! J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) e2 L7 m3 Z0 {; M 方式二:
1 |* M5 y" i4 U% C% ~! { 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! C1 [) M2 G0 {2 O! V- p
SetTitleMatchMode RegEx! i4 {& D% Q: ?
return" ~% P3 \8 O1 Z/ Y
; Stuff to do when Windows Explorer is open# f' |: c* \, L
;6 ]4 J: d2 X* C; P! m9 A
#IfWinActive ahk_class ExploreWClass|CabinetWClass3 y s5 R0 [/ k
; open ‘cmd’ in the current directory
4 ^; p% W1 h0 p1 y) M/ l ;
% O+ ^7 q. r3 k- }; z6 t! | #c::
5 J# g* s- V. A OpenCmdInCurrent()
6 L0 `1 I7 q* e7 {% b) z0 Z6 v return
5 c! r4 V/ { Y2 [) n #IfWinActive
; d( z9 U& `% N. }5 @+ F. r5 Q ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.. ^8 v/ s$ c# ?$ i& n% a1 w
; Note: expecting to be run when the active window is Explorer.% y" b" G! C; p
;
6 l' A0 S3 g2 d/ Y% V; T OpenCmdInCurrent()
7 b- I) Z1 H8 j* G) C( i0 \ h0 F {
3 S% Q& a7 L: G9 C$ S" M5 c) m ; This is required to get the full path of the file from the address bar
5 Z a# P4 y, ^ WinGetText, full_path, A
! Y1 L: O4 T# ?9 M ; Split on newline (`n)! m( y! R. `8 f. q& k2 y
StringSplit, word_array, full_path, `n9 j* G+ c1 }$ T/ g5 c+ u+ `0 |( _
; Take the first element from the array9 u: g/ O! i' d: n
full_path = %word_array1%
' q4 k6 Q; M& x+ X ; strip to bare address7 j" h" v! O1 c' K% s5 y8 Q
full_path := RegExReplace(full_path, “地址: “, “”)
* I( |9 S. k3 X ; Just in case – remove all carriage returns (`r)
5 q# w$ l3 ]) ]2 o8 J8 d StringReplace, full_path, full_path, `r, , all; a9 h' b) e: x$ @3 K. i6 N
IfInString full_path, \
- s% D7 ]! \4 g, I' q; d {
& f1 ]# L7 @$ s+ h. L; v Run, cmd /K cd /D “%full_path%”
# M9 R. j7 |. J* [7 G; w }
2 J( b+ K h, l0 x: B else3 W% R7 a4 p8 v8 w0 a: ~4 f, q& v% @
{
% r6 X$ c' H; ^0 i S Run, cmd /K cd /D “C:\ ”
2 q4 g8 K2 { n. v }# F/ n5 x- e2 P5 r) Q& i
}
( {! `) S+ E+ u 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 x0 { b3 }' R) L* j- `" [- R 这段小代码肯能有两个你需要修改的地方
d: {3 c+ C2 T5 c9 S: E9 M& B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! L! `" q* k2 B; z& S8 I6 W
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 {, h) n$ h3 J& O |