此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 o C' Q# u( f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
T# p% S. J3 @ 方式一:
* n: @5 ]( s" B( x E 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 U. r. B, Z- F) v& E6 @3 s
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) R) p& J8 \8 K# g6 ^
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
9 h- m2 n; U; E 方式二:
6 V% C4 @$ p- j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- q; ` u9 E! J. ?2 Q0 c3 r1 n SetTitleMatchMode RegEx
. ^2 h6 y- Z1 }* X* [ return1 A0 }- x: D2 S& L6 \
; Stuff to do when Windows Explorer is open
8 w; \# B5 k5 q! c7 z% j9 | ;0 P% s+ w' b+ ~$ R& E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
/ W' U( N- m9 l) S) G ; open ‘cmd’ in the current directory
9 l. K' q# x: [" r& o2 f3 X ;
; V3 Q! B( A" V #c::4 ?* b8 m% a) I/ t9 u
OpenCmdInCurrent()5 W& A& L; U$ u# N4 N1 {- [
return
+ _: E; c* ~* u0 _7 j1 s/ w% F #IfWinActive
+ M. F& u4 R ], P ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 g/ k8 o3 g/ m+ N. B1 O. O ; Note: expecting to be run when the active window is Explorer.
3 j+ \1 @; d' A9 [! u" ~ ;. m' o5 [* Z* f2 s: T
OpenCmdInCurrent()
7 \# U7 B1 x9 A2 V7 S- Q {$ Z+ Q9 I6 m$ A. v% i T) A
; This is required to get the full path of the file from the address bar! f7 h- y! c. H9 x$ |7 w3 F
WinGetText, full_path, A
/ Y( S" ~( E5 S ; Split on newline (`n)
/ Q3 Y3 i A! J7 {% }1 n; _ StringSplit, word_array, full_path, `n
( K1 F7 e$ h; y7 g+ b ; Take the first element from the array
7 a0 X: b: j/ t3 D8 h0 E! T1 v6 z full_path = %word_array1%
+ a Y: j' U- X+ H! ? ; strip to bare address
& g& k- `9 B' B8 E- c6 p full_path := RegExReplace(full_path, “地址: “, “”)0 Y% n1 ?& u3 s( u$ S4 t# d. n8 n
; Just in case – remove all carriage returns (`r), a$ y/ K; R- ]+ c. O q7 V; c
StringReplace, full_path, full_path, `r, , all
& `9 ~3 R3 F9 p K# u IfInString full_path, \
6 r$ B& {' q7 s2 a* `6 s {
, | M7 Q0 ^# M8 O Run, cmd /K cd /D “%full_path%”
$ W3 o4 x( }' S7 n' X6 l }& @! T' R: M4 `- _; W7 H
else
- M* C" ]4 I3 X' v. f {3 Q4 D/ d! U9 {$ l" m
Run, cmd /K cd /D “C:\ ”7 d) b" i( m8 Z! ]' K1 n- M4 f
}! R8 B" j! x, s. k+ ~" [
}
6 z9 |8 w5 ?7 U- } 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ G4 H3 C" T6 o1 Z
这段小代码肯能有两个你需要修改的地方
8 H1 f% s. r9 D, X 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
- g0 Z- Q, O9 M/ z# X6 U 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 L- r6 P( Z2 s" F+ e |