此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ P$ t1 g; t z' \8 |
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% H& g, S& H- s
方式一:
1 t9 G3 k7 R. L+ a5 L# o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, B5 I6 F8 l% `: V0 l1 E8 ?* Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 n2 Y9 n$ x" p5 W( t
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。, S U# s8 X1 {5 o) G" G; L" U7 ]
方式二:
( e6 Q' ?" A9 g' } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" w, j* v5 r- B$ Z: ]. C
SetTitleMatchMode RegEx! ]% O; R: L2 N" x1 U
return8 h2 k: N& V' }# z
; Stuff to do when Windows Explorer is open
. o3 ?) j, T6 S' U1 v* F* } ;
) o! {4 H# Y9 @ #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 P0 k$ |& Z; N$ [5 W: q! k+ Q) } ; open ‘cmd’ in the current directory# a, C8 E$ j2 W7 }% q# i
;/ K# q5 X. ] t1 h N
#c::
( @! A, X5 o% e% C* F. L2 B+ y OpenCmdInCurrent()
3 h; T) i, u8 n0 X& X$ m return6 m0 |; f/ `# q, i) ~) I# r( b, e
#IfWinActive) B. J+ N5 G# h5 B% C; k
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.: d8 l7 U( i. K
; Note: expecting to be run when the active window is Explorer.) p5 B) b: @3 k* S* P+ Y- j8 M
;
- }* [7 k0 n5 t OpenCmdInCurrent()$ L/ p7 g$ a$ ^* C
{
5 ^3 y4 g5 G3 \+ u ; This is required to get the full path of the file from the address bar
0 W7 W6 M* @2 F% b x WinGetText, full_path, A
, [5 M5 R, h6 z ; Split on newline (`n)
+ r) A1 j; y# n9 U9 G ^ c) f f StringSplit, word_array, full_path, `n
4 k" f+ o2 x3 H8 G3 u. I; e8 G. S ; Take the first element from the array
( }+ D2 v2 y$ D: i D full_path = %word_array1%) [' O+ b0 R/ T# f4 Q) `) n
; strip to bare address9 i# P$ h' v/ Z( P, @; C- k6 O
full_path := RegExReplace(full_path, “地址: “, “”)6 W8 _" r$ x& I/ N+ O
; Just in case – remove all carriage returns (`r)5 x6 b5 l' W' S. p
StringReplace, full_path, full_path, `r, , all
' t/ T4 `: M. w7 z* K IfInString full_path, \! F7 Q8 W {* q+ K* \
{
" {$ x# F% K' v+ P1 H: i! Z Run, cmd /K cd /D “%full_path%”
4 g$ G" F4 K- o9 `7 D& t7 u8 a }
6 _# l2 P' @8 s- V. ^ else$ x8 E: B% n4 d5 v' H7 M
{. U6 w7 ^( s. l$ a( b6 R5 w
Run, cmd /K cd /D “C:\ ”
- {0 {$ h S) q3 T" C7 { }
; R* U8 Y' b( U# ] }0 n1 x7 o3 W6 V& z5 y
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
- F4 b4 n, C* }& b; W! ]9 I 这段小代码肯能有两个你需要修改的地方5 u4 X U0 S2 \" z& P& `
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' m2 D$ A* E9 w! E
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ q" Q& [0 t% e5 ? |