此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 m& y3 C% K/ g6 l/ v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( u# x8 H* {+ k
方式一: v) E, \% R3 L& f) F* P1 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( C& \( i: i7 ]) c+ ], \$ z. s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 }. B( i/ q, l8 G( N8 a* R HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 }( ~6 g# Z2 z$ G) u 方式二:
' J: T% c5 e0 r8 D 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) v" O0 D8 k4 S- @' W r. K- M SetTitleMatchMode RegEx
. e$ n: s+ y7 T return/ A- Z& x3 _' @- A: k4 N
; Stuff to do when Windows Explorer is open+ [; S+ [' r: ?# z! _) V: N# p' U
;& g$ m( Q I% r( _; ]" n
#IfWinActive ahk_class ExploreWClass|CabinetWClass
! j5 Q, m$ T! _+ V; o1 T4 F ; open ‘cmd’ in the current directory
* n( s& |8 n" J* g8 \ ;
0 c7 }( ]! W" _, S/ T; J. P #c::7 x4 ` }3 y( q) D; V, ]/ r; d
OpenCmdInCurrent()
3 u) M4 ~/ h$ T" i1 E return; X) s3 f6 U) G! c$ C% H2 ~4 K/ x- e. Q
#IfWinActive
0 j+ k+ m j2 u4 o. r/ A6 ^$ ` ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( f: Q% R5 m( _6 x$ Y- s
; Note: expecting to be run when the active window is Explorer.
9 w9 N1 C2 G" p1 \ c ;0 d9 ^% c3 C$ O3 A! J4 z8 H8 L
OpenCmdInCurrent()
0 w& G q0 b- e5 n7 [ {/ O, y4 M. o) F* [" \
; This is required to get the full path of the file from the address bar0 p0 n2 g' }1 Z) H6 a* D. _2 j9 q8 g
WinGetText, full_path, A
1 U, F1 i/ k6 n. o: a; E! \7 ] ; Split on newline (`n)
: O, P8 m; M7 s% c; k2 o- c! ^ StringSplit, word_array, full_path, `n
) E8 A7 D5 @9 h( N- K0 v" e! ^ ; Take the first element from the array8 [& m# t! L. _' s2 l
full_path = %word_array1%
& r2 u3 V3 f C8 ]: F1 L ; strip to bare address
) i1 }6 u. h" s( `( n full_path := RegExReplace(full_path, “地址: “, “”)
: g ?7 c7 x0 j7 A: h3 @ ; Just in case – remove all carriage returns (`r)9 y2 {6 h8 i) J4 u
StringReplace, full_path, full_path, `r, , all
9 Z" i. L; |% |2 U IfInString full_path, \( k0 V9 c- w2 F$ r6 M9 ~( S
{
& C& Y% `! Y) a2 z3 s Run, cmd /K cd /D “%full_path%”
2 _- c3 e% R9 ?9 B) w+ T D }, b( P, l0 K6 b1 W- c1 j* P
else% B1 Z: [/ k( D# }: n' H) j
{
- l0 T, t9 L# t! o+ H Run, cmd /K cd /D “C:\ ”3 Q- y2 B v: R& V
}
1 G& B: O0 k# c+ P }
8 `2 N% ^) K, L1 k 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# C1 z/ c# x. _' u- _ 这段小代码肯能有两个你需要修改的地方' v6 e# L* Q- {* V& C7 s+ v
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 J3 j& _5 I( V' S9 r! E 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, K: b) y# H* i. v1 C; e1 w
|