此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
4 g1 L1 O* C8 g: @# i* Z- N0 l' q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! J# t9 q1 M6 M8 G2 e; H
方式一:' i1 {2 J3 |5 X
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" _, `2 P9 w9 y" R' U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
8 k+ _& f! i7 w8 a: _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 Q" M) K" N7 p W7 q* D# D# F 方式二:
* v- a+ j- z; k7 \9 T# }/ } 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
; X2 U7 U% `+ f* o Y, F SetTitleMatchMode RegEx$ |6 H& o0 m+ T( U& T
return% l, y4 \( W9 b5 I+ b5 F6 q; P, G
; Stuff to do when Windows Explorer is open. K9 Y+ Y2 s8 Z& P' E) D
;0 D8 A/ `; X9 X! s$ @% c, O
#IfWinActive ahk_class ExploreWClass|CabinetWClass! ^9 v$ \% t2 X' V3 ^% V6 l, ~
; open ‘cmd’ in the current directory |4 ^7 r- [) F$ V
;
6 e$ S; K4 |& O+ [/ D0 ` #c::
4 p6 u f6 Y8 Z& {" F OpenCmdInCurrent()) O' n) @6 Y& i6 t# S
return1 [9 i$ W/ V& U" ], l n
#IfWinActive
2 Q( j8 L9 R& l- D) G( V8 I ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( Q6 h1 M0 _9 P: R- l$ M
; Note: expecting to be run when the active window is Explorer.
, j! I* A/ }4 H9 n1 e% R% G6 Z ;, s( F* P& p- m# o
OpenCmdInCurrent(), x4 R% A @2 Y8 E) a' \1 r! E* l
{
% b. G. @- C/ } ; This is required to get the full path of the file from the address bar6 n* ]% [: _/ p4 N8 d7 `" f, G l
WinGetText, full_path, A9 G: [4 `+ s9 s( P0 n3 Q
; Split on newline (`n)
2 x$ b1 h' x" V StringSplit, word_array, full_path, `n8 n) ~9 H, z2 t
; Take the first element from the array
7 }% h K5 f" c) ~2 Z full_path = %word_array1%
& q' ^; M" {2 ~. p. Z5 u/ X ; strip to bare address
7 n, T8 o, W, i' j: z6 G full_path := RegExReplace(full_path, “地址: “, “”)9 ? s. ^1 p+ Z. }% n9 B5 q
; Just in case – remove all carriage returns (`r)
2 e5 \2 E* J6 c4 Z" o StringReplace, full_path, full_path, `r, , all
. y2 `" t; K5 c! a IfInString full_path, \
! i7 u7 w- [- o( ^+ |& X {' a' k6 ~( E/ k3 T" M, i$ F
Run, cmd /K cd /D “%full_path%”
' g% g% x7 h c! ^* O/ q) _ }
" t7 F0 m$ S X. ] else6 i6 T i" Q) F0 ?" U
{
% s& a$ T4 ]$ Q/ e Run, cmd /K cd /D “C:\ ”
% n, D* o* I6 t5 t+ B }8 S* B$ ~- W4 v, S6 J5 B+ C
}: i+ Z) d, ~& C$ g1 X8 x9 E# k
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* f3 U6 G* r# I# T 这段小代码肯能有两个你需要修改的地方( m6 T# a- b- k( p# S1 S6 Y, g
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 D9 U7 e' ?; Z: q/ x 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 h- Y+ w( X& J3 j. G
|