此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* N' i+ i1 G L, r. x& O 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。" `: n h7 S( o. w6 T3 m$ E
方式一:
9 B, }( V5 s" G+ ]( k. q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. s1 d3 l* u6 Z' K ]# j. n
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 c! G5 k8 u1 Q" i% c; q; F! q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
/ E' T' p& v% G9 Q 方式二:
6 |6 b, P! d1 O& [ 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
3 N- k/ e/ `2 _6 P SetTitleMatchMode RegEx+ \( a; D% Q4 t" B9 _) B
return9 p# D5 g$ o1 b1 t
; Stuff to do when Windows Explorer is open6 G# s7 {/ c0 Z& i& v: L
;" B# s' a5 d& D4 Z
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ f6 p1 m7 a7 u' p' S; u# Y" X ; open ‘cmd’ in the current directory
/ |) z0 f5 H( Z( U. k! n ;/ c$ d" S' `, }2 n
#c::
. D3 J N0 T1 X/ `# K' v OpenCmdInCurrent()# `/ a; n- A! V' g" X; a
return" Y# O# o" U. `2 ]$ |7 |
#IfWinActive
8 V3 ] D f( p5 N$ \4 N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 s! @; e* `* P0 x0 _ ; Note: expecting to be run when the active window is Explorer.+ z* T; L0 u. T L6 Y) B
;
) d; R/ v! W8 I# B, l OpenCmdInCurrent()( i1 O8 \7 Z. K, o1 D$ y: q
{
) Z5 q; Y/ P# u+ f& e, V6 i/ E, g ; This is required to get the full path of the file from the address bar
& R6 o$ w+ s; U% g6 O WinGetText, full_path, A6 U/ t; X+ X( b. y; \9 B' }# m
; Split on newline (`n)
: g) Q2 W1 B: j/ H( T StringSplit, word_array, full_path, `n2 v( L; S$ R5 Y2 M' Z' ^
; Take the first element from the array
/ s9 D" U' ^3 O- o6 N6 d0 ^( Z full_path = %word_array1%% b6 s& |3 w) Q" I: B8 E& j
; strip to bare address
8 ^* d# [9 e) V7 w: q9 D2 U full_path := RegExReplace(full_path, “地址: “, “”)9 E5 V& p0 f! A
; Just in case – remove all carriage returns (`r)
1 V: l2 Q1 d& k3 V: K# a& @ StringReplace, full_path, full_path, `r, , all$ j) D6 |2 h+ W4 o
IfInString full_path, \; X9 P- X" t* [8 ^, V; D# D) N
{' h/ h+ K$ r/ U8 e8 m4 P9 r
Run, cmd /K cd /D “%full_path%”
2 B8 b/ u0 Y+ Y4 R1 J }
; m" P# f8 V( d$ t3 H else
% A8 a( |2 G, C/ X5 H( p7 E {7 f9 T' M: h e7 E% W5 ~
Run, cmd /K cd /D “C:\ ”
( N+ o [' O8 { }
0 f1 H2 {, c' D0 v# n }( W2 v1 s( u& n* [) e6 P; j
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 N. W! D# s" S( {! N
这段小代码肯能有两个你需要修改的地方+ S1 z: q' R, E) j$ r6 L& |
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 |+ U: C0 g$ d& } 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “9 |* y! l5 b4 ^! |% a
|