此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。# K4 [# e6 ~5 G/ I5 K3 v4 n
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* T2 v" P" y |/ m" ]/ T 方式一:) q1 S8 g- S2 B9 }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,5 M9 t o+ v! d# T- m
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" x$ u0 X( g8 W' {2 c* t* a
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% d2 H/ y: _- l8 d/ F
方式二:
# Y) ]( U" x j/ @5 x! o2 }4 C) J 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. M& B1 ]2 k% T1 L/ O
SetTitleMatchMode RegEx
6 [+ {" v1 Y6 m" X& K return
! p' U" s4 W7 L ; Stuff to do when Windows Explorer is open
( U/ J- i) J8 a% v- m/ E+ G ;
6 |% b. L% M, q- x" ` #IfWinActive ahk_class ExploreWClass|CabinetWClass
|9 h# u# F2 n+ k2 { ; open ‘cmd’ in the current directory- v" t# r6 U& |# P1 |! ]9 y
;0 w! q* H9 d; R7 r# o
#c::
3 _6 i7 i* G# a+ q3 C- n- x# R OpenCmdInCurrent()( p7 h$ r7 O1 |" w
return
7 [/ R4 D1 b$ O #IfWinActive( `/ Y2 l3 b" q2 k" l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. v8 ?% i0 o+ y- I
; Note: expecting to be run when the active window is Explorer.
; A+ o# d0 K. q! @) Y% d ;/ \7 c" F$ |) S' Y5 E$ R4 M+ M
OpenCmdInCurrent()
; b( C% p5 @! G {
K9 L! g9 h9 D1 I) h5 d, t ; This is required to get the full path of the file from the address bar
% w: E) h8 y+ Q1 }9 X WinGetText, full_path, A8 |, {6 K+ e4 ^' i
; Split on newline (`n)
; l" Y; S1 m5 t3 q StringSplit, word_array, full_path, `n
4 S9 W$ t# |# y$ n# U, W% S ; Take the first element from the array
5 o. t5 K" }# n+ y full_path = %word_array1%8 h( }1 n5 H# k5 \- \3 X; I
; strip to bare address% d3 B, k6 @8 o" l& l0 I
full_path := RegExReplace(full_path, “地址: “, “”)
8 S+ x, E2 G3 i: O ; Just in case – remove all carriage returns (`r)
5 l* {1 r7 U1 {/ G9 d" W StringReplace, full_path, full_path, `r, , all# W; M; {" c3 w7 F" Q" _* H6 G; P
IfInString full_path, \
& b5 {- W, t% I ^ {
3 h' f4 f2 E$ ]& N2 `2 C Run, cmd /K cd /D “%full_path%”6 L3 D# }3 Y( w, V# T. e2 S6 C) O
}0 t+ C$ |* c0 V p" }0 N
else
/ J- ~; D. q# h' H {0 v% [. b3 ^: T" v& c5 b7 u2 R! v
Run, cmd /K cd /D “C:\ ”
0 w1 h' J' j) E6 y: \ }
2 C/ a7 p: {9 Q/ X" n8 N }/ w0 [, L) U# ]* e) C9 h
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。& B0 ~9 U4 Z+ Y- ?) |) c
这段小代码肯能有两个你需要修改的地方
7 t2 J# M* P7 B 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 l/ ]' y! P2 F7 V4 [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
; b& ?* o* {" o- n9 m9 o& B1 L2 M |