此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- p8 N& }0 B6 f 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 N1 J8 `. [7 @# K9 e ?
方式一:
5 }9 ]! p3 T4 ?1 u9 d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,# j4 q" C0 O9 _8 q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 D2 p; t3 r1 t% j, Z2 S) O HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。; ?; u, a7 A. C/ O. ^$ Y8 j+ E
方式二:/ H9 {+ w7 r, Q4 B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' K+ g' a2 r: V% a4 l SetTitleMatchMode RegEx
" J. `: c" F" G1 V A+ h return
/ `4 W0 G( M) ^: n" c: L ; Stuff to do when Windows Explorer is open
6 E$ s6 v9 }9 W ;
V3 a# P/ ]9 I: X- c$ ^' x+ L- H$ n i #IfWinActive ahk_class ExploreWClass|CabinetWClass
. h! b9 R% q- I7 L% T7 B0 L6 q/ J9 k ; open ‘cmd’ in the current directory
3 z% M6 o8 |" \( s2 J! h- d' b! A ;# S- M; ~$ W3 g/ K8 z J
#c::
# l. ]/ ~ a, [7 Y5 l OpenCmdInCurrent()' `+ O& K: U- n- [
return
6 N+ `8 }$ @$ M# ]( s7 X5 v* @ #IfWinActive1 J% f* }6 z$ x4 [6 b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( @6 P0 S" T$ n1 r0 p- s" s# W
; Note: expecting to be run when the active window is Explorer.3 `4 a7 H; R# B7 A+ Z7 f/ Q
;$ t0 u& ^, e6 `5 w$ i
OpenCmdInCurrent(): q: M& ?& E! J I& ^! V
{
' q, B, ^7 M( d6 S, t ; This is required to get the full path of the file from the address bar6 I _- q# |' [2 T$ J6 C8 C* t
WinGetText, full_path, A6 n" C9 D3 f2 b y: N" x& u1 S
; Split on newline (`n)
8 V+ E% ?$ T! I2 R3 T StringSplit, word_array, full_path, `n
( K8 D+ x& D3 B ; Take the first element from the array' f$ u" d% T1 q, A$ p
full_path = %word_array1%, t/ q- v# ~: ?
; strip to bare address
$ [4 @0 E. t, `7 T' a full_path := RegExReplace(full_path, “地址: “, “”)/ i1 [! P' X3 L
; Just in case – remove all carriage returns (`r)5 |9 {9 l3 [+ F+ B9 ^
StringReplace, full_path, full_path, `r, , all/ Q, ^$ A2 G+ W/ D7 |" s, a$ s
IfInString full_path, \/ e, k. e7 c" N2 I
{
6 ~% ?8 c, f, k8 t* p2 T Run, cmd /K cd /D “%full_path%”, [* J! K6 C/ |) q5 s9 Y7 E
}: o3 J8 x# z( i) y' S
else
2 v# z n9 t9 _! i9 I; s* p {# E9 `4 s3 U1 J2 q5 m
Run, cmd /K cd /D “C:\ ”
# M2 V1 u4 I1 H! W5 Z# e }1 }. |( M9 W2 a0 Z. z
}" B7 f- u$ s: g; M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。5 j- i; u' P% _6 ~1 m8 h
这段小代码肯能有两个你需要修改的地方7 N# u z+ t: D O
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键* Y% g% g: X& M/ a1 ]; p
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; ?( S7 a7 U: T: Z* @
|