此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
5 M# ^6 X) W; t: s4 B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( L& R) {$ s! B& Y+ |0 ~4 k
方式一:
. j! g/ P h8 R1 Q; t! g, W 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, J/ w" t6 b' `9 ?4 G, l. ^ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; v4 D/ |- ~$ W8 j: J HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。% y5 y! W# K/ W8 [# K+ J9 H0 K; w
方式二:" x5 o8 X5 ~/ n
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. e& c, B6 [( w: t6 @; g. b: @
SetTitleMatchMode RegEx
' r- T! k' f0 a$ [. \ return
4 O* K3 w& h( @ ; Stuff to do when Windows Explorer is open( t( d$ k/ K% e) _
;: c4 h' A6 X4 A+ M5 t
#IfWinActive ahk_class ExploreWClass|CabinetWClass Q6 u) S" h& G+ u3 q( v: X4 G1 y& w
; open ‘cmd’ in the current directory0 M9 T' q6 p8 `. E' a
;
+ N+ o4 _% I* j$ j1 p* } #c::
0 B- g! z/ U! L5 O6 V/ \ OpenCmdInCurrent()
5 J+ W0 R# d/ Q; U6 d return
- X7 l$ V3 O4 p) r #IfWinActive
7 Y3 u% ]- Z( b! R+ F- k ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
- Q. \2 u7 @4 v* x8 f' o ; Note: expecting to be run when the active window is Explorer. n, l$ F( c" K I9 c. H
;
* n) P" _8 V5 e OpenCmdInCurrent()4 }( f& O6 I/ k- O3 q1 X# \
{- m: W- G* v) H3 ], U2 t- \7 o
; This is required to get the full path of the file from the address bar
4 w9 ?0 A/ Y! d" v8 B WinGetText, full_path, A
. o* W2 c0 n C7 ~* p* ~ ; Split on newline (`n)# k& k' d# R5 a, x* Z+ V9 L
StringSplit, word_array, full_path, `n
E0 E3 U0 R& O; a7 B( }# ]% ~1 E ; Take the first element from the array
$ k- ^- b) x2 E full_path = %word_array1%2 |1 c4 I( X D
; strip to bare address
+ i4 o5 \ b) d1 q$ o- D; u full_path := RegExReplace(full_path, “地址: “, “”)9 Q6 i5 W* u# h
; Just in case – remove all carriage returns (`r)* h0 |: F8 o! }# l. p- ^
StringReplace, full_path, full_path, `r, , all; D: K. W5 L. x9 x5 N0 ]2 C
IfInString full_path, \% o3 P+ t' |% Z2 K) m @+ U, j
{
- f2 I$ ]8 J* }" M- D) [+ w+ ` Run, cmd /K cd /D “%full_path%”1 J7 L. P* b0 `4 C, W
}8 P0 F- ?2 D) L3 O
else" |, L; b/ h% ~& F& H1 v
{" E1 ~* W2 m" `
Run, cmd /K cd /D “C:\ ”
( T2 L+ G Z. S+ L7 Z8 x }
+ i+ t8 O3 m9 b% a: Z" [ }. U+ r5 n t6 K0 H5 d* v
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ E! [, O. D) N7 B: j2 O
这段小代码肯能有两个你需要修改的地方
4 Q; M( T U% X" {2 g 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' |* F _9 M" | e( m
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “2 r, N* M" @$ _ g. W* S' v \
|