此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ [* c2 G- R l7 a1 ^- W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。4 M- B! z$ Z- k7 g) \* t4 N" }
方式一:
- p+ I$ o' m; H# y0 h( @4 p5 a1 ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
- N1 d, F; D, y 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 V% ~4 m1 p9 t! P8 y HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( E& {4 A$ Q2 Y( x 方式二:
: F* ^8 n* ?6 F1 t4 b& D$ N 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
- w; c8 Q7 U% p; _1 a+ C SetTitleMatchMode RegEx+ j) i$ P3 A4 K* v4 R: @9 ]2 E. r
return
% Z( [; Z; K1 _/ w) {; P. T0 F9 s& b ; Stuff to do when Windows Explorer is open# C4 P) t5 Y- X0 G# N# _! Z# R
;, ^0 h8 L/ Z8 X# w m
#IfWinActive ahk_class ExploreWClass|CabinetWClass
) s* j1 m5 I3 T- I a4 c ; open ‘cmd’ in the current directory" }' p6 @4 J$ c) c c7 G9 a
;% U8 ]8 T6 P: p) ~$ j3 V
#c::+ p+ D1 b% C' U" Y+ e" H3 U
OpenCmdInCurrent()% i/ T' N0 W3 W9 [ v% ]# d! T1 v9 Z
return
* j9 E9 J7 v4 w3 U #IfWinActive
+ W y4 {0 v! C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' H/ k, R8 J% \3 x$ I7 K- H- _% ` ; Note: expecting to be run when the active window is Explorer.4 b1 P& `: U6 x/ X
;( t' Q5 g1 e+ u: c0 v
OpenCmdInCurrent()
! R o, {/ d3 K$ f; F8 l0 @ {
: B! c6 g( y# {' b ; This is required to get the full path of the file from the address bar# T6 y$ V: O) w9 V, g
WinGetText, full_path, A4 q, }* Q5 h! I; U0 R% t1 Y
; Split on newline (`n)
; `+ j; G% B0 `( E4 R* [6 H StringSplit, word_array, full_path, `n+ }. H4 x- E' R! t ]3 W4 |1 V: h
; Take the first element from the array7 T& {. e) f& B5 @
full_path = %word_array1%
% ~! e7 O% ], f- K ; strip to bare address
0 V! o! Z6 [% N: L) a C' Q9 h" k full_path := RegExReplace(full_path, “地址: “, “”)
3 v9 e# p* d. g. r ; Just in case – remove all carriage returns (`r). E8 R: y1 c/ X3 i
StringReplace, full_path, full_path, `r, , all
9 P3 q) p, w: Y: z* } IfInString full_path, \
. d$ @1 F* Q( y9 Z {: I. ]: d1 N1 D0 v+ H
Run, cmd /K cd /D “%full_path%”
% J: T2 N z+ P9 C, U }
. A/ ~% ]8 y# d1 v/ s2 z* ] else
# f# @; o2 C$ X. `& K- ^ {2 d( F' ^- F8 p+ P: T4 {" n9 C$ V9 }
Run, cmd /K cd /D “C:\ ”6 }. [& y0 E `+ p# }
}& d) m% n$ f: ?3 Z3 ^3 Y9 {5 Q
}
" L# W9 q2 N1 Q" C" [/ Z- w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" o2 d. R4 h P$ n7 z
这段小代码肯能有两个你需要修改的地方
$ Z2 H, L4 t$ } 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键+ s0 ~" G8 r( _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 n3 I# t6 R3 M+ A
|