此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。3 o5 ^+ ?/ i, O; i* ]) D/ \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. B: g7 Q& N3 e, m M- R4 t } 方式一:2 a t1 u, g7 m4 x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," W4 }4 c+ T6 B( n$ e4 A: i9 `, S
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
+ [7 u$ h* f* j. y* V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; d `5 Z. G/ N4 ~7 E
方式二:( V4 r( z& B2 U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
, e' u- V7 r# m3 W7 p0 r7 v SetTitleMatchMode RegEx
8 D/ l, B3 x( ^8 O- @ return7 z4 ?1 {! w$ ?$ l2 u5 ^' q N
; Stuff to do when Windows Explorer is open
* y% y, b, N+ |0 x; d# L ;/ P/ l- A" U9 I3 L$ @. H: l) {2 S
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 z' g6 H& g; x4 V
; open ‘cmd’ in the current directory
& k- B& H3 G+ C" B: U6 r7 | ;/ j$ Z Y& I5 B/ o
#c::
( S8 M9 o R O7 c# c: h4 x% m2 d OpenCmdInCurrent()
" \3 T- {1 x" a/ |! ^ return
; {4 ~, z( V, j: z #IfWinActive
( }) u- v l4 `" H ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# k- e: D8 C1 g( Q* J8 Q& V. K( Y
; Note: expecting to be run when the active window is Explorer.: j8 K2 H. Y u$ f, J6 O: R; Z' S
;' W, h% _; q0 ]4 d; l$ E) O+ t
OpenCmdInCurrent()$ r! `+ g' V( b) w0 t# w, K
{
: m0 u ]8 Z, y$ {# c ; This is required to get the full path of the file from the address bar
; c5 ?; c+ Z' v9 T& F. M. d1 A WinGetText, full_path, A1 n4 ~5 p- L0 \+ m. H E
; Split on newline (`n)
' R. i$ L- R% S; \ StringSplit, word_array, full_path, `n
$ L# P9 u! r4 T, A ; Take the first element from the array5 o& b% x" N# P, h- }
full_path = %word_array1% V1 a0 |: Y8 C" X; C2 z/ A
; strip to bare address; u& {7 x! X; r( ~4 Y
full_path := RegExReplace(full_path, “地址: “, “”)+ q1 d" M; Z7 z# @% b& \% Y, L
; Just in case – remove all carriage returns (`r)
! W8 m% r. f% x' h StringReplace, full_path, full_path, `r, , all+ Q7 G+ ^/ C j$ V9 n
IfInString full_path, \
1 I" j$ `6 x8 @( i {
6 f4 S3 m* n. e) q' s, u5 s | Run, cmd /K cd /D “%full_path%”( G$ d7 T3 A- F }
}$ w- o _6 f* r* r; J/ W
else0 ^( |7 C8 i0 V) Y, F z
{
; S- B& q/ V1 M, L7 |) R Run, cmd /K cd /D “C:\ ”
5 B+ ]# \& D6 d* J: s7 E' U/ a3 h }6 Y) Z# C# Z0 u) J9 `
}$ V" |2 T5 q; g( x4 D5 f
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" u( A ^* L2 }7 P
这段小代码肯能有两个你需要修改的地方
7 `+ I% a. _- j- i9 P) R) q 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
7 H7 l4 X$ N _- T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 G) W I0 T5 f& z; h7 x% I |