此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; s! O& f, J* j# S1 {& ` 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 s( S- m. F" j
方式一:
5 b( Q: i. z) F7 f# v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 D- W3 a" v4 ]% s! ^1 R
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 t6 {, a7 F6 c" A6 e HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 y* Z2 r! r, W% N
方式二:
" Z' h6 @9 v, u5 k3 @" c; u6 X9 b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 J% Z0 ?8 t) D# \0 \
SetTitleMatchMode RegEx
1 z) \* {" s7 l& v( r- x, N! i4 a return
: T0 _2 W# R* G9 z S7 u ; Stuff to do when Windows Explorer is open' f3 u1 z2 A* B
;
3 P! n- w% @' {$ ~. L& ^; B #IfWinActive ahk_class ExploreWClass|CabinetWClass7 l# F% C4 W' |6 L. Q C( E
; open ‘cmd’ in the current directory* ~# S: X" P9 |" `; ~$ a$ x3 N
;8 i& t6 |4 s! [, d/ v# I3 Y$ x$ X
#c::
* v+ E! s( ~' _5 H& _2 k' E* J OpenCmdInCurrent()
C# j/ A0 P* H9 Z7 X- T( g return s% m3 e5 C/ r3 d" w
#IfWinActive
5 F& l3 ~- X9 f8 c& I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
* C$ i4 U0 U% j; d+ x; `' Z7 ` ; Note: expecting to be run when the active window is Explorer.
6 w" Y& q2 w$ [$ ?6 |) O ;. s- P" j4 m" o2 A, D
OpenCmdInCurrent()
+ h ^0 r: |* c% }8 p7 @& H1 D) I {
0 r4 G9 A# w( N7 h1 x# S ; This is required to get the full path of the file from the address bar' k$ U t+ U6 [+ U9 U5 P
WinGetText, full_path, A
5 e" k' a e; l9 o: f ; Split on newline (`n)5 s$ T, C6 T4 q- M/ E
StringSplit, word_array, full_path, `n
, L$ n) E2 U! I( {0 n# X ; Take the first element from the array$ H( A$ _3 X- w9 P0 J3 {) ^
full_path = %word_array1%
/ ^: h" U* S* {/ \( F: f/ d ; strip to bare address' D( O6 i; c+ z% ?
full_path := RegExReplace(full_path, “地址: “, “”)
9 W: c, U$ C# c2 ]! i ; Just in case – remove all carriage returns (`r)
- E1 [" O8 a; ^! c Z StringReplace, full_path, full_path, `r, , all
6 n: I1 ~/ M: [) X0 @6 Y3 l IfInString full_path, \
! z* N9 J4 N) x2 o+ C1 L' t5 y' n% u- A {
$ i6 Z! W* n: d1 d Run, cmd /K cd /D “%full_path%”
$ G H9 s+ W0 @: S& R }
$ r. w! n) r+ A; M2 ?* t else7 q& ]& w3 a9 g6 \
{, W# M% W1 d6 ^% x, D2 i1 h
Run, cmd /K cd /D “C:\ ”+ O7 g: |+ u% z( y5 m ^
}/ |0 c/ b' ~! r+ C5 N4 r
}6 j7 A' X$ J! Z6 y2 N& t
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* i' j9 C5 j% \8 s 这段小代码肯能有两个你需要修改的地方6 ^: v s1 q' g7 }: }$ F7 m& q$ r
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ b0 x$ q9 N0 H% \- y" G
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “1 ^: t; ^# O$ j6 `
|