此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! O$ K9 S, k) h( N# Q! I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
6 d4 V) `$ }4 Z! R1 T* h7 M; q" g 方式一:# h+ k% v' V5 `) l, w
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
! B* J5 ^ H& e5 N- x L7 j& `# m" i4 Q/ ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" m: F( l$ `" U8 i& z' f
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 W6 a* s6 f7 v
方式二:' b4 \: T) t& a5 L
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 V/ p" A3 {$ z7 a" Z
SetTitleMatchMode RegEx8 ]- G0 k- W9 Z/ R" N/ M9 S5 R
return
0 w1 V4 N! G0 m; J- b* B ; Stuff to do when Windows Explorer is open1 S: V* w9 Y% P) c
;/ @1 u! [: U: R
#IfWinActive ahk_class ExploreWClass|CabinetWClass9 f _# c# m$ x' S' y9 P, J) U
; open ‘cmd’ in the current directory
7 g- S! X: m6 f% k m% O; S ;% t1 r, o0 {2 [
#c::8 `8 H& @: @$ v
OpenCmdInCurrent()
( S4 e* S4 Y) o: n# \# ^ return
% t6 ] p1 ], P& ^ ^& i# j+ j& S- l #IfWinActive
) R/ v5 B1 Z2 y7 r% v. Z* J9 w6 ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
3 |" \8 w( [4 d# m* f, f6 e ; Note: expecting to be run when the active window is Explorer.
; U, F/ j- D. s9 j) J ;
& D$ j1 A# Y9 w; |. A/ D* ^9 ]3 o# C OpenCmdInCurrent()
$ p& `. b' c9 k, D4 }. G {( Y; P" N4 J3 w+ Y& Z! q/ y4 R
; This is required to get the full path of the file from the address bar# K5 B( G/ N( p$ P
WinGetText, full_path, A
$ u: J0 ^' B+ o# u ; Split on newline (`n)
; P* i5 q( {- ~+ ` StringSplit, word_array, full_path, `n. H/ w" v- {' u- Z, |
; Take the first element from the array
) n" `& [ \# ~+ @7 ^) [0 i# G full_path = %word_array1%# w' ^, K/ s* F+ S) H8 a
; strip to bare address& ]& ]6 b# z# T: s( {0 X2 s
full_path := RegExReplace(full_path, “地址: “, “”)
: O* y1 o4 ^; `! |1 v# q0 G ; Just in case – remove all carriage returns (`r)5 f- n2 V7 _7 y3 [0 N& M3 b6 T) f, R
StringReplace, full_path, full_path, `r, , all
$ J6 A) t- V1 i: i/ c IfInString full_path, \4 p' v7 Q/ l- {. {+ P7 {1 c9 u4 K
{" Q0 K; P6 K. E9 N7 m
Run, cmd /K cd /D “%full_path%”- u$ P8 X6 U7 P& g5 R' D
}: E5 T* }) j8 ?& }6 u; n
else3 N, g O7 S2 f! n$ m0 D5 N+ F7 c/ A& d
{
5 H" ?2 W7 z: X Run, cmd /K cd /D “C:\ ”3 ^0 H: p/ i5 J
}
0 |3 [9 H- E: W1 G* c5 ? W }
1 ?% v9 U. T3 u P) S9 X ]) L 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: I9 v/ F* o) I( u
这段小代码肯能有两个你需要修改的地方; b6 N f; l7 x8 G( g/ X4 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ }! F- ]: v H; p7 v 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: P2 ~# E: o T$ c |