此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 j9 v. d5 W9 a5 o# _, P8 e 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 A" _3 Y( [ ?7 }
方式一:0 w" ], }0 N! M9 N% V' ^/ C
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,1 M% B+ \( ^. v* ^7 j- U+ K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和" j: a3 a8 A- N' ?* O; i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( g' Q% n c1 y
方式二:
" j' l6 f6 z2 w( D1 j 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
$ _9 \# w9 Y ?" q! I SetTitleMatchMode RegEx- g( O- H0 G6 i1 G# R c4 b/ F
return9 v' Q; F) _2 {6 \5 B
; Stuff to do when Windows Explorer is open0 T6 V0 V0 F) l
;
- m E1 s+ @: {/ B; N" w #IfWinActive ahk_class ExploreWClass|CabinetWClass I; d5 G) I5 W$ I
; open ‘cmd’ in the current directory
! p0 l9 h7 G$ V) {2 K3 Y1 M ;
. @! y# X& S; x" ~ #c::( J; S; J* C# y
OpenCmdInCurrent(). Q0 G5 M1 ?1 e q. y$ Q
return
) U, |0 n# K- G J( r8 M. a #IfWinActive6 I8 r) P S, Q, I
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.! T3 |: o) U; K; t _
; Note: expecting to be run when the active window is Explorer.
! H# I; {0 m' M$ K ;
" S* c' ]$ ^+ n1 N3 h* n2 h OpenCmdInCurrent()
% s9 W3 y, `; @& w0 f% o {9 Y n) a! B* D3 ^# `
; This is required to get the full path of the file from the address bar2 ~( v% v3 ]1 Q. o Z
WinGetText, full_path, A6 H& j: U% a' |1 Q1 ^
; Split on newline (`n)* v1 Q3 h, ?7 h) j- i! M5 |
StringSplit, word_array, full_path, `n$ @4 Q# G4 v: {$ @6 S
; Take the first element from the array: v7 T$ {1 t& S6 j# H
full_path = %word_array1%/ g) _8 l; M8 u) @2 d
; strip to bare address B4 |9 X M7 `7 ^
full_path := RegExReplace(full_path, “地址: “, “”)3 f- u+ X! {5 m" @' ~9 I5 Y$ }: \
; Just in case – remove all carriage returns (`r)# [2 p& |5 n1 ]( M
StringReplace, full_path, full_path, `r, , all
( g& Q1 v6 g7 M$ u7 M IfInString full_path, \
3 t( g7 x- t+ Z( \4 G {1 V, J' [1 L6 \% u5 Q
Run, cmd /K cd /D “%full_path%”
$ e; ]# m Y: t: b; L) s' P }7 m+ e8 ~* d# K* c2 U
else+ o5 U% |8 N+ ?: A# d; v( ?
{5 h2 _+ H' z$ G* }. t- o+ X$ p6 b- W
Run, cmd /K cd /D “C:\ ”% U2 Q/ \+ F+ K. D! l& D, n/ R
}
* z! T3 o3 h% Z, t }
( g% i4 L2 J4 o4 d 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
L5 Q: ^* Z5 g% G& d: K0 l" j 这段小代码肯能有两个你需要修改的地方, G1 g8 d3 b: |- `7 O/ `5 T
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
* n) D% [' G' a9 t 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* L, Y: ~3 V n+ E |