此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
( S) e9 b" j$ A8 q& `- O: h0 D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。0 z" r* X! j3 ?: U
方式一:
; `, N% ~8 L5 |2 Z9 u3 I9 n; S% ~% O 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 o! k+ u3 _: _' h. ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; g% p4 L6 I: ^7 o9 E$ @$ P HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ ~* {9 u! d- p7 k8 H
方式二:4 g( L, b+ N5 o# Z- l) t0 q
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 _4 b3 Y! t& o, Y, }
SetTitleMatchMode RegEx
( N8 c. I' D- Y& D return
4 Y+ x6 s5 h2 K1 G ; Stuff to do when Windows Explorer is open# Y; J! C3 ^) o! P$ C
;
) `9 Q; T. o- }8 g1 A #IfWinActive ahk_class ExploreWClass|CabinetWClass. X' w4 ?9 {6 d7 ?+ j, D+ \$ e
; open ‘cmd’ in the current directory
' i2 Y c/ W. A( r5 ]0 x ;
( ^& S1 s) Q: i+ s; H% } #c::
4 V& o+ M/ r6 z- f3 L2 u* J3 [ OpenCmdInCurrent()0 v: D" u N7 D: p2 z. z3 U7 x/ a
return
& A" m% E& N( O3 ?4 q+ q G7 ~0 ^ #IfWinActive, L' s5 u0 t( \8 N1 r' S5 P! m7 l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! A& K O, _+ w, q' O
; Note: expecting to be run when the active window is Explorer.0 I" s# h! W+ W# W
;4 m/ ]5 _! u. [# o6 y6 o
OpenCmdInCurrent()
( C j) `2 _& J% O {) R0 o1 @/ r) k# g9 o9 y& ?
; This is required to get the full path of the file from the address bar
$ d- E& i5 i/ e. K# ^* g WinGetText, full_path, A
* T( Q1 c0 Y( x9 G9 x9 v% f ; Split on newline (`n)
, Z1 j, w" ]; z8 X. j) O! m9 g# K StringSplit, word_array, full_path, `n
; t+ h1 Y8 D. ]8 b6 M5 _ ; Take the first element from the array
1 O# |7 e( s: E6 {9 m- @8 @ full_path = %word_array1%
. O" F8 V0 f" H; \ ; strip to bare address
/ Y: [6 w0 J! C& x( g full_path := RegExReplace(full_path, “地址: “, “”)
N4 D' {0 G) h$ s1 E0 _5 Z# B7 ` ; Just in case – remove all carriage returns (`r)" B# h$ I- j; i5 Z% t+ E
StringReplace, full_path, full_path, `r, , all& ?- N8 r# v3 _) M" n1 l
IfInString full_path, \
8 A7 y& \- k4 J: N {7 H3 u! M! E; e$ w
Run, cmd /K cd /D “%full_path%”( ?6 u8 w7 `( H% t& u; M
}
8 P! T8 E% w1 d# k( K else
3 G( R/ A. G7 K9 h {
4 T: Q6 v( o1 D* Z: m" {8 M, R Run, cmd /K cd /D “C:\ ”$ X4 I5 P6 M3 [6 B& `+ w# \
}4 ^- C( U& z, B0 H- A+ `7 T
}
0 }( \& o' q1 b; v6 T1 p& Y- ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 ~ j! M0 P* H, u
这段小代码肯能有两个你需要修改的地方
" {% k9 b1 J8 Z9 v% | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键/ z0 V/ a5 c, ^7 t
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
0 L4 E, i4 I( c |