此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。: H- L+ S; M4 l0 w ^" F! \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 b: @6 I# A. _& j7 t 方式一:4 e. q3 i: g/ X- W1 n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,' ~1 ^ _6 U6 L; `! _; N% O
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
4 M: B+ e1 x5 M9 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" e+ e+ T; _) A' K
方式二:
4 [/ f( W% W6 E$ i) [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
7 q7 g1 @3 P* [: Q/ u- C$ {/ j: G SetTitleMatchMode RegEx
! X% j6 x8 T, j return
, l6 Y, N8 ]) s ; Stuff to do when Windows Explorer is open9 @5 f9 D. g3 m1 Y# C, h
;# d) m5 n9 C5 e# _0 z5 H0 _
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ r$ [6 h8 q! x: z+ z& D ; open ‘cmd’ in the current directory
2 u/ \! o: B9 i ;
2 b4 }4 u2 D+ t2 w; u #c::: f6 z B' q3 |, E O3 F% K& C
OpenCmdInCurrent()
4 @! p! F' o1 v2 V* P4 k return w/ r4 W' x+ U3 Q. m% f
#IfWinActive
, M3 v: d6 W! W/ m! ?1 q% M ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., i' B% j3 R3 c$ s: D. R6 y
; Note: expecting to be run when the active window is Explorer.3 T4 O( R5 h, O: Z3 H
;) n0 |& J' c2 H. K0 P6 W" S+ A
OpenCmdInCurrent()
; m& \2 v1 H0 B6 m9 r {; G) O; f: ` i3 Y4 E& D
; This is required to get the full path of the file from the address bar
( ~: o( c0 N% b9 y9 i- M WinGetText, full_path, A
. g- E0 K `9 I, K: J7 ` ; Split on newline (`n)3 ~2 j" N5 G0 p1 K7 w2 J
StringSplit, word_array, full_path, `n5 c8 h( Y- D) @; X
; Take the first element from the array
( \) m1 t' e1 b full_path = %word_array1%
3 P9 W/ J3 S3 A2 H6 N1 b ; strip to bare address
3 @6 ^0 q! X5 u9 G full_path := RegExReplace(full_path, “地址: “, “”)
6 Q- S- l: b; J2 Q8 I$ R ; Just in case – remove all carriage returns (`r)# \9 ?6 V3 `$ X, `8 `
StringReplace, full_path, full_path, `r, , all; z# A9 ?2 K+ x2 @. _
IfInString full_path, \" i% x+ L$ c9 m' z- ]2 O9 s: X8 X: `* J
{ z8 g$ Z1 P# _5 p
Run, cmd /K cd /D “%full_path%”0 V. v$ U3 }/ n1 B
}
! r# S9 A2 r, e* v5 N' O7 M0 ~ else
6 h1 m9 O' o: P. n; J* g9 _ {
- \4 a% N# ^+ K# m; V2 Y Run, cmd /K cd /D “C:\ ”. S! O, R1 @9 e3 Y6 S
}
% a0 Z" B: Y' z' i }. e) k7 z/ X8 _7 k, {1 i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* @! r; {& F" o+ N& Z9 I6 |; y: _
这段小代码肯能有两个你需要修改的地方
3 p/ f/ B" w4 a% y1 t! [ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ C0 v: }$ n; Z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
_. y/ w1 v# f% ^ |