此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 q$ O# W8 C% n0 m0 S0 J) G; O' g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 v2 T. R2 N3 V; `5 v% t; A 方式一:
! y3 h' }# N- x4 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
7 s9 _- V' {5 w- h i/ { 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ C# O8 S8 |8 B7 Z8 q: k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 n4 x2 ]; ^9 y9 A, h 方式二:
1 P2 M% i! K% @2 x 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
/ e) v2 {9 p4 }7 L7 G SetTitleMatchMode RegEx* m' F% q' R/ {, d/ {& m0 V
return+ {3 f: O; t" e5 w- {8 k9 c% m) ^
; Stuff to do when Windows Explorer is open5 H2 U a) f1 O" I: ^2 }: H
;; S7 w7 L0 C q( b @$ s
#IfWinActive ahk_class ExploreWClass|CabinetWClass- {1 V( U. T8 Z. e8 Z! B6 U0 T
; open ‘cmd’ in the current directory
o- B h" b. P ;
/ |+ s y8 J! i5 F: x6 b3 p #c::9 ]. y3 r6 e( _) q1 Y
OpenCmdInCurrent()
l; e/ J2 g* o return# B1 w6 z5 k- N8 V4 H# L' L0 g- ]
#IfWinActive
]. a9 m7 C# G/ `% D; A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. @! r6 F' d7 }! I6 k ; Note: expecting to be run when the active window is Explorer.$ q- b: m% K' c. @5 g, n
;- b9 A! K. M# Z- g
OpenCmdInCurrent()
* `$ ~4 A9 m X' T- i+ o {3 Z: E$ h4 w8 s4 ^9 Q2 c$ \
; This is required to get the full path of the file from the address bar
8 C' O9 K! \5 b; A. ~* A WinGetText, full_path, A% S' C- O! @7 p
; Split on newline (`n). V, n; T: ]8 R/ h; C
StringSplit, word_array, full_path, `n
$ q, q# @3 [" l) ]* w N6 G ; Take the first element from the array
/ {$ T- ?; I X! i full_path = %word_array1%) l% E$ d' c7 K0 ^
; strip to bare address
* D9 d1 `3 m# ~$ V8 e7 K1 C% h0 ? full_path := RegExReplace(full_path, “地址: “, “”)
- O( z4 o. D- G; O' q2 J, W" r ; Just in case – remove all carriage returns (`r)
" M4 B P( f. @" u- y/ B: Y6 ^8 z StringReplace, full_path, full_path, `r, , all
# H/ ]1 ^& ]( c* P IfInString full_path, \
- H, m! f$ l' r* O {0 b+ M/ Q- W: o' E* X$ i: i/ ^7 {
Run, cmd /K cd /D “%full_path%”
- L8 }- N; s9 t5 k8 X) I }
7 y$ N1 Y7 k6 @; Q, b& o2 c0 B: c else
/ R- |0 p$ ?1 C+ { {
( _$ K1 {& U: n" ~3 {1 n F Run, cmd /K cd /D “C:\ ”
8 ~8 q5 D$ x8 k* w: T- R }/ C+ [; g: k9 {' V+ s5 L+ T7 [* x: M
}6 ~! C9 k% k/ F$ Z! E- e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ S0 _+ \+ x2 n, F' A7 _! Q$ K( H
这段小代码肯能有两个你需要修改的地方
( n4 A6 c8 r, y$ ^8 T" r2 j. K 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
/ ]; v( J: @7 H* r1 k& y2 H% ?7 O: n 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “$ ?6 ?5 I4 V$ t( d7 l! i T9 i
|