此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
+ G9 e, @6 \3 u3 P5 x* K! n+ Q: V7 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! M) @' b% t3 E% W
方式一:
4 F5 b. r% E; ]0 m9 t0 o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,; ?3 o3 @. S5 Z% c: i; F9 Z6 z) T
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
. z$ v2 ~3 I# R+ C' d1 C2 V HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。2 m% q: p7 j# b3 t
方式二:
* S' e( w% ~+ w2 K, s+ @. r 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# g: e6 A% J. T9 P4 L2 ` K SetTitleMatchMode RegEx
" g" k' B$ P- O' d ] return
h7 G) H% ?% Z# J+ h% \ ; Stuff to do when Windows Explorer is open
2 Y" n9 V a2 |% W ;
t$ f5 r @2 b) U, J! O #IfWinActive ahk_class ExploreWClass|CabinetWClass& C" Z6 r# _0 M. r a+ X8 b" x; v
; open ‘cmd’ in the current directory
4 Y& N/ @! N7 N* D4 R ;
" ?' E! Y5 e5 u' o2 n #c::: b! `* K. }+ }: l8 W( H7 Y' h
OpenCmdInCurrent(); |. V) n- I- V9 b
return. i7 l3 v, a( m X
#IfWinActive( n- \7 Y' @3 y& g- R/ \
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; M' Q9 f# q# R; Z
; Note: expecting to be run when the active window is Explorer.
* h' Z3 l- R: A' q- o, M4 E ;
) f. I1 n9 \. L! a OpenCmdInCurrent()0 `) K8 B6 N3 i1 Q/ `
{" W& ^" w( Q1 n$ s: l/ ^8 [+ f
; This is required to get the full path of the file from the address bar
5 v6 v5 z _0 y- P$ ?0 v WinGetText, full_path, A% K" v, E# m P
; Split on newline (`n)
! o* a& [. O8 J$ W4 N StringSplit, word_array, full_path, `n
& u( A% j/ R/ ?) a ; Take the first element from the array/ }* m8 y* Y& i5 S* @
full_path = %word_array1%& @' l$ P7 n9 O# T! j( l! @" c
; strip to bare address
: Z, h- f$ Z6 g, a. d full_path := RegExReplace(full_path, “地址: “, “”)
/ V3 V, i9 S1 ~# K( l; n% }% ^ ; Just in case – remove all carriage returns (`r)
* ?& o) Y3 w6 V" X StringReplace, full_path, full_path, `r, , all
+ W: o7 J9 J! r: S IfInString full_path, \
" v3 A4 s+ f8 R {
( f" C/ X% b( E! @7 M* l9 K Run, cmd /K cd /D “%full_path%”' }- d5 `8 [; L) ]6 }8 h
}
: u1 t7 Z$ e* f+ c else0 _5 c8 I5 F' d1 x+ M
{
& A3 c( q$ K) M9 ` Run, cmd /K cd /D “C:\ ”
$ B3 M8 J Y* I# | S; v }
: n+ Q' W- X6 ] }
0 X+ V! Y8 b4 l# Q# w 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。 r1 h1 l. l3 \8 S* x/ k
这段小代码肯能有两个你需要修改的地方
- o* h$ N+ k: C% S+ R 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键$ \) |7 f& _% v0 S) k5 P
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “: y u. W. ?0 T- z. c) _
|