此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。$ I6 E7 v. h* y* V) Z; Y7 M
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
; s N" g( Y: @/ }* H) q0 E 方式一:
) r. c- B& [$ V0 | 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
( F" s2 U8 M7 t% y) o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 Q1 @: T9 F# S
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。! b/ Z! n4 m5 @6 a
方式二:
; \ ?' g' @# \$ M 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( z. Y, P y' R SetTitleMatchMode RegEx! t, ^6 R& V5 T, F
return3 F( o# C, @8 U; |- y
; Stuff to do when Windows Explorer is open+ }8 G8 f% F1 T3 \6 S# r7 d( V
;
5 d( Q/ ?/ U2 F8 o; H$ L+ p2 r #IfWinActive ahk_class ExploreWClass|CabinetWClass, s7 Q3 k5 H2 x7 \
; open ‘cmd’ in the current directory$ |$ [& v4 G& H) Z- `" q, x
;% A* B3 V8 Y2 u0 H0 S7 B# F
#c::+ W; y- o) U7 Q2 N
OpenCmdInCurrent()
$ o/ U7 o/ j4 u7 N( ^, @ return3 y; e/ ~" L7 @5 Q4 N# K
#IfWinActive
5 L% X* {2 J, C) I; i' |4 q$ g ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 _1 o4 J, E% B; w, C8 b. i2 m ; Note: expecting to be run when the active window is Explorer.
' \ L+ Y0 F5 n$ K8 _5 E/ L- w7 r ;
! v1 h/ X/ g2 T/ J( x OpenCmdInCurrent()
0 W: l( z, D) v1 Q' K {
- O% H6 n5 g7 }) _* c2 S8 M ; This is required to get the full path of the file from the address bar1 W* i- v+ x6 K/ M* P, O
WinGetText, full_path, A
& J7 j* |# S* a8 s3 y4 Y4 w ; Split on newline (`n)
/ r7 p* V3 ^- O2 b: T7 G4 j& s StringSplit, word_array, full_path, `n
- b8 i- d' L* x5 I2 |0 w ; Take the first element from the array0 z V$ {. O! V* j3 f" h1 ^/ F
full_path = %word_array1%6 y/ x* O8 }7 |6 S, @7 y) F
; strip to bare address
' n. N' m8 S& O T full_path := RegExReplace(full_path, “地址: “, “”)5 A; b; o D0 I' T. q
; Just in case – remove all carriage returns (`r)
5 W' K& x V6 X( |$ Q StringReplace, full_path, full_path, `r, , all$ m. b2 x# R. N+ R: u+ n3 z9 t1 P
IfInString full_path, \% h1 a% N7 e1 g
{
2 Q \/ _9 D8 }7 e2 e Run, cmd /K cd /D “%full_path%”
& A( @: u1 a9 l }
+ i) m0 ^! [0 E$ ?" x8 ~# S else
! f& ~) A" U8 R" G: Y {: e. ?" M, [/ s1 P8 }/ h6 h- r
Run, cmd /K cd /D “C:\ ”
- e5 C1 Z, c/ x! s7 ?) p+ X: f+ W; `. h' J }
- s+ ~" Z. T7 g+ a } d3 p o. k' B/ o4 U2 M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. K5 @8 H, h9 `8 M( E
这段小代码肯能有两个你需要修改的地方1 ^ b& {7 e2 S! h6 A- C- X! d6 k4 D0 H
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& y2 \, k$ p% E/ P( M& ^
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 S4 G& `$ X4 l" E: b! ~- K3 F* `1 |2 H |