此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 H8 j! a; x# R1 v
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. `7 m3 Y* L6 J2 W
方式一:
' r( V n6 N2 K+ G' q 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 q A: Q$ B' h/ |& k; e' n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 h; T; W2 K1 b0 q# M# g7 F HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
! \/ g# w& g+ l8 `' t 方式二:
- |4 h/ |5 D7 n1 D- v7 Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. X2 R- I" N" u& W9 F3 W
SetTitleMatchMode RegEx
" I E! q- T, d3 h+ `/ L3 i return
% \( k" u% q2 w; s' A& p f" ? ; Stuff to do when Windows Explorer is open
+ v7 M$ ?: i, H! L1 _5 m% \1 Z ;9 F5 b' V2 _ f3 W; s
#IfWinActive ahk_class ExploreWClass|CabinetWClass( X; B) |0 b' x5 L/ Q1 ?; P
; open ‘cmd’ in the current directory7 i1 }4 T4 s; w/ ]
;
7 e/ {, i* ?7 Z' L% a/ o# X' O #c::$ y+ f% N. y3 T
OpenCmdInCurrent()% `3 x% g$ J" Y3 S9 G/ ]
return, M, Y a7 ?9 q( ]0 S* ~9 T& M% O' B
#IfWinActive
* M u9 q' C" h5 a ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.8 {7 A; } g: X9 m9 D# M W
; Note: expecting to be run when the active window is Explorer.( c" @( B/ ^4 ~. J0 J( g3 ]6 F
;
8 o) J* d* D/ n7 \8 A/ Z OpenCmdInCurrent() L7 E/ `( L! v* {& _
{4 v# N5 g5 j: s" {( Q9 G
; This is required to get the full path of the file from the address bar
5 m* m/ ~/ ]! T4 u# j WinGetText, full_path, A
# S, G; K8 ]9 `( ]6 l: g ; Split on newline (`n)) a0 `! r" D- t; u' E6 G# x
StringSplit, word_array, full_path, `n
4 i( T' d5 _; K( Q2 P4 l ; Take the first element from the array
4 \; V% j% _3 W" H full_path = %word_array1%
, K" ?0 b N$ Q$ Y* o ; strip to bare address" m \6 B$ L2 x
full_path := RegExReplace(full_path, “地址: “, “”)
9 U0 M% g4 \8 j. Q ; Just in case – remove all carriage returns (`r)! ]) |8 k# A7 N" J4 Q
StringReplace, full_path, full_path, `r, , all% r4 X6 r& H. r: I) n
IfInString full_path, \
9 s5 u Y! \, Y+ J3 T( i+ Z {
3 ]& E2 m$ U9 q& E& ?. E' m Run, cmd /K cd /D “%full_path%”
4 Q9 \! L) W; r b! v% m7 I- S5 K* h }( ^% |; m9 W4 O) l1 n; |, E
else
: x7 T% q6 Q0 C+ p& X+ H0 ? {& H: \ T6 y, ~# B! C
Run, cmd /K cd /D “C:\ ”
- d+ u& o6 r; S0 U u2 h P# ~$ n }
& }/ D$ `0 J, Q0 E }2 [8 z0 w" T: D* N+ ~1 Z6 J/ `( G
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。% V8 a' K% w. M1 Y! O& N/ _7 O w
这段小代码肯能有两个你需要修改的地方
) t; e+ e. L. ~* a7 r J) x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* s. y( b a1 R: V/ d4 j 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
5 ?) F: p- e9 M3 L. L# D |