此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 c% L2 J( P2 ~# ~1 c2 {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 w6 {7 j* L$ H/ C) ^) r) i* a( W 方式一:
, M2 E$ T- A+ K6 t. Z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, {% ]+ K1 v! G$ q' T ]: u- q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
) v. h1 h7 `, S* Y- r! N5 }* ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ u4 @+ Q: P' i' c3 H9 p5 o 方式二:
' w5 M, ~7 V+ `9 `4 @) z1 [ g+ S 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- ?' t) z9 l( Q! N
SetTitleMatchMode RegEx
- O. C8 A7 a1 q/ f: I3 d i- N9 Q return+ i6 X6 V# @- g+ `3 b
; Stuff to do when Windows Explorer is open/ p7 f$ l5 N( \) t; B
;
8 @* z5 {4 F0 y* Z& c: e8 I$ l #IfWinActive ahk_class ExploreWClass|CabinetWClass) a& i, N, D& I# B& U+ V1 Y/ f
; open ‘cmd’ in the current directory
% D- F8 S3 w) R' X# {/ u! K ;# Q9 Y6 ~1 E/ R0 F
#c::
) [3 M4 r- l* n) O OpenCmdInCurrent()
0 T9 Y) c% T) y return
+ r& y0 ?7 ]; b8 f4 O' y A #IfWinActive# i5 ~. B5 I: F6 g9 e% o; z: j" m
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 d# _4 P9 X5 b! t" K& u# X* r ; Note: expecting to be run when the active window is Explorer.0 B* V9 U5 L9 w: f" w
;
6 h) T0 y3 A- \ w4 E0 b& C OpenCmdInCurrent()
2 a- |( H! z" q {
; r8 a; R8 |/ \2 o ; This is required to get the full path of the file from the address bar
% k5 f# p) O+ l6 |6 S- u: u: | WinGetText, full_path, A4 q2 j& w) U. W0 d6 z
; Split on newline (`n), e& }8 Z6 T0 | h1 d5 [, f
StringSplit, word_array, full_path, `n
/ l% i: m* z+ B ; Take the first element from the array! y, d$ a$ P7 h2 J# a( ?
full_path = %word_array1%
5 {! x+ _- V. a4 v1 e4 B ; strip to bare address
9 x5 k S2 b4 z full_path := RegExReplace(full_path, “地址: “, “”)
! K8 o' n2 L+ K ; Just in case – remove all carriage returns (`r)
$ L4 e U2 b @% a StringReplace, full_path, full_path, `r, , all3 {8 I5 i8 ]/ c$ V4 y2 P8 i
IfInString full_path, \
- H6 X3 V' A, y0 Y1 [' _ {
% V- ]# O4 D9 e Run, cmd /K cd /D “%full_path%”
. H7 L, ~& G5 V2 V9 H1 Y/ o }
$ w! F# Q0 N" \3 m/ r, L else) m& Z0 S- D& ]. q5 b z8 y0 F
{! d: |# j) b0 z; K/ W1 \. Z! s2 W
Run, cmd /K cd /D “C:\ ”) ^3 S) ^. z. a1 `# ]" K! n
}
$ Q9 z" e# J: k9 d# j4 j) x }+ V; e1 O0 E1 L3 c6 Q; G5 Y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' w) I. c6 @) d
这段小代码肯能有两个你需要修改的地方9 V9 v9 o" r4 j _" S. K1 A2 k* e
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! n) y( t/ o' @! j2 C
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- D: k$ l, U6 f7 ~' I$ c4 W& ]
|