此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ \/ I& R: }5 k% m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! y5 q n: G4 G1 w 方式一:* k# u# e5 F( V
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ r+ [5 z) g7 B9 a/ I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和' `1 k/ `" v$ D1 Z, {3 K6 Z% d
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* o) y$ v! i! q, n3 G* h" w* v0 n 方式二:
6 d$ O7 l) X4 B6 o K" V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:! j# B4 _+ E! f
SetTitleMatchMode RegEx
# ]2 U8 h }: {4 w return
8 M5 a0 ^" ^7 L: O ; Stuff to do when Windows Explorer is open
9 K: R- N8 t7 {; ~ ;
$ Z" T$ @. Y6 Z0 O4 o3 M #IfWinActive ahk_class ExploreWClass|CabinetWClass' v3 m: S4 T! k5 I* _% y$ L
; open ‘cmd’ in the current directory
8 F, z) ^' K6 b' {% g) [7 R ;
# ]* K9 K) t. R #c::: ^( |1 V* ~7 q5 u& T
OpenCmdInCurrent()
' Q; O- y0 P; z7 F4 L return
+ b1 K8 e# c8 u- b% h #IfWinActive( N! x( U, o6 D: T
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 E. V, q- e9 p ; Note: expecting to be run when the active window is Explorer.
+ n$ V; `! \) U7 r ;3 E. ]5 l9 H8 Q# F5 }. v, m. O+ v
OpenCmdInCurrent()
; t# c, {1 y& s0 n {
5 x1 _/ L7 |, b* O, K- [3 d ; This is required to get the full path of the file from the address bar1 f0 X* P. V2 @, q! I% N) _
WinGetText, full_path, A$ O$ P! P- h8 a2 M. s" c7 j) Q
; Split on newline (`n)/ V7 H4 |9 }( }: L, D; g$ U
StringSplit, word_array, full_path, `n
3 {5 ]1 e1 e5 P5 R% y) D ; Take the first element from the array
% I# ?, } s# N5 V# O; y full_path = %word_array1%8 `, o. b- w% n" w* W
; strip to bare address
2 U! F3 j X+ u- o full_path := RegExReplace(full_path, “地址: “, “”); ? F0 W, z' v; D9 j3 l
; Just in case – remove all carriage returns (`r)7 x- b- [5 w' @$ `
StringReplace, full_path, full_path, `r, , all' ~/ h2 M7 x& o' a7 z" e
IfInString full_path, \; _4 t+ |6 G4 g) R! d% j
{) e/ Z3 s# N, a: ^9 K; S7 Y
Run, cmd /K cd /D “%full_path%”
4 s# H6 e1 }% e' b" i$ r; h/ w% N }5 k7 e; o% a2 r5 s
else
. m6 |' M# y2 J4 k0 P; X6 F' z- Y {% `0 U' g" b9 y9 u4 w+ {- {9 b
Run, cmd /K cd /D “C:\ ”
* T( C3 T. q9 | }
) D) ^: C% L1 B5 Q3 A* ]4 m }+ Z3 A" w0 J5 q* @8 J. j" P) m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" ?$ p$ c/ J$ R$ n* P6 f
这段小代码肯能有两个你需要修改的地方
; q% N5 ?; y: n3 k1 s 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. q4 x, c/ W$ y1 u 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% o4 Y. t) X( V9 N
|