此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 V1 B3 p# S0 |9 ? 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 K4 Q" M+ L. P& J$ r' v' {
方式一:
- }. ~; u1 z5 q$ L3 s! o; U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,4 ]4 a1 I' n. H6 o$ o: J( T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; x ^$ v% m' ~9 L4 w4 [ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! r% b- S8 a. X6 e5 J! B- f 方式二:
- }( l- P, S+ S' R0 V/ X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& ?0 Y" n& \. h8 u% R/ p SetTitleMatchMode RegEx
0 ^- x. m7 x4 ?0 `8 L. X2 v5 e return2 Z2 Z D3 W5 P- z
; Stuff to do when Windows Explorer is open
. s9 K; c1 ?# x: p6 B+ P ;# z; }7 Z$ A; x, u8 o
#IfWinActive ahk_class ExploreWClass|CabinetWClass/ V3 c) U7 _: X
; open ‘cmd’ in the current directory
. O) n, T! d1 x2 i: @& J: ` ;
8 _9 A: D7 g6 W2 w) X3 o #c::
) U& D; a! t" t9 g& m% N6 T OpenCmdInCurrent()/ C C( p& { ?, c
return
o @! `! ?$ A; \6 q4 |4 `2 E #IfWinActive- C; W- f7 l+ p! e2 }% b! S3 k: S
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 |) U" O$ O2 q. c: p ; Note: expecting to be run when the active window is Explorer.5 s# s1 L0 S/ G
;
1 _' l% a; a7 {7 E% Z OpenCmdInCurrent(), d5 M( p/ X3 ^) L
{9 ^8 ^0 B* [1 W
; This is required to get the full path of the file from the address bar* ?/ s- T+ C, P
WinGetText, full_path, A
`7 J ]" E, Q) T1 y# o ; Split on newline (`n)
* Q# l) S$ E! ~ R- p8 P5 G StringSplit, word_array, full_path, `n( m" b8 ^2 G: `/ i
; Take the first element from the array
7 b0 C+ a. z; P$ F8 m" O* j8 v full_path = %word_array1%5 }7 ~4 x0 i1 j7 G
; strip to bare address3 i& K g/ `: ~4 D
full_path := RegExReplace(full_path, “地址: “, “”)
3 x# a2 R) V9 { ; Just in case – remove all carriage returns (`r)* L( P! v' D. n: A6 I
StringReplace, full_path, full_path, `r, , all
" e s; q! F7 y: z7 b- A' F- P$ E IfInString full_path, \, g$ i( r0 U T5 ~3 F
{
0 B7 x/ t( a, [ Run, cmd /K cd /D “%full_path%”8 x/ K' m0 @- V/ G4 _# F0 W4 v7 Q* o
}
* G( A2 d, w3 a1 a! Y0 S0 J, t else
: X1 e$ ?; o" ^5 j: o2 f; J' u {
5 ~; m" A& h2 h4 e$ C) Z- Y8 q Run, cmd /K cd /D “C:\ ”, L0 C/ d( C/ @4 ~/ I" L% \
}
1 T( z! ` N/ I3 M& @# N* h9 _6 { }
) T" j: \3 s, R, U- ]; f S; e* e 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
0 L4 F- R% R$ V* m4 S 这段小代码肯能有两个你需要修改的地方
! `5 L S5 z# A% e% t- ~ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# f( M! w$ q( C" ` g- {
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: ~) l j# Z3 |4 L2 k( v5 e0 ^' o
|