此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。% Y) k: E6 j; p& f E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 u1 F8 @8 M! | }, Q& U* | 方式一:
' }9 @4 C; H! G5 W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( G" b7 j& J* m, J5 u- `
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
2 s: a0 g* k! S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- e: u% x% I: z! L' f4 q
方式二:
. F* ~0 w5 b p! x5 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
S$ h6 T: H# i& d SetTitleMatchMode RegEx
* R5 \1 L2 H+ u) V return9 D+ b1 i$ S, C$ h# K' L" t
; Stuff to do when Windows Explorer is open! u' s6 ^6 V7 Z/ b3 h2 @
;2 m, u9 h) `3 M0 W/ K, P
#IfWinActive ahk_class ExploreWClass|CabinetWClass: b1 ]* Z. ~" a* w
; open ‘cmd’ in the current directory' h3 e3 \! H3 J! k- W
; I! N0 S! G. s# ^! l; L2 p9 H
#c::
' s7 \: b0 s% H8 x, F4 I8 @ OpenCmdInCurrent()# G0 L# r$ ^6 j) z- r; j3 G
return$ |9 H4 N# V9 ]. F
#IfWinActive6 i/ I) M1 L: G1 _) o' d
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) w4 Q$ j2 O3 [; c7 ?1 ]
; Note: expecting to be run when the active window is Explorer.+ b+ N, d8 I; Z! A
;+ z9 h' ?2 e2 l3 `7 M/ x
OpenCmdInCurrent()
5 Q$ _5 W8 {/ N, P {
! c! W) q! T3 {, J, [& m: B$ k3 `1 t ; This is required to get the full path of the file from the address bar9 X0 F: k0 d& o/ K; N) m
WinGetText, full_path, A1 W- |1 T$ j( B: I$ C
; Split on newline (`n)
' a7 f) Y! B. p, E2 ` StringSplit, word_array, full_path, `n) E5 s t6 u0 ^: z$ y, s
; Take the first element from the array
2 f4 D/ G# p% V full_path = %word_array1%
( O2 W5 I/ i+ ?2 z! L: f ; strip to bare address
8 W: A6 A" s- ^: |, ~' i full_path := RegExReplace(full_path, “地址: “, “”)
# Z( S5 H6 @3 \ ; Just in case – remove all carriage returns (`r) n. _3 ?6 z( A
StringReplace, full_path, full_path, `r, , all) O( N# l' E! u- G4 N% O) O' _8 {
IfInString full_path, \
7 @6 ~+ `! O2 N0 a2 r) ? {
4 E7 A' d& i5 R) v2 [ Run, cmd /K cd /D “%full_path%”
. |, S' P/ Q* V! h }! }+ V/ v2 e! ~/ G- d1 H
else
+ @4 Z* h( ~8 @4 X {4 Z* Q m0 k) A, r+ \2 s3 U- |
Run, cmd /K cd /D “C:\ ”
' }' D/ K1 U' f$ U8 b/ ] }! U/ D# ^0 {; R; m
}
* n; j) _( E1 ?& Y g* M: y5 v2 ~ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! G8 C$ O9 ^' ]! S8 `1 l
这段小代码肯能有两个你需要修改的地方
" C; x. h x$ c; j2 t( f 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# o4 i$ s: o# q7 E- Y1 k# N: p- E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, q2 j& q" ?" A7 F* z+ Z5 g+ z
|