此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
* l$ D Q- {! e0 `1 g0 u5 }) D 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。1 F0 i! a) T3 t+ u3 {( B% ~& ]0 F
方式一:4 e. d4 x6 h# u" t* M
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' T0 `. u; |& G' v o+ {9 q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 v" L# z% E' l/ x4 k$ c HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
; F: }: r6 i! n c/ J 方式二:# A" k1 G$ v9 y' V7 u, F
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:' J1 q# H, D- g3 \$ q
SetTitleMatchMode RegEx: R$ V, M8 x* E# ^' `
return
5 Y4 z0 U' T, R% t. v4 Q' U7 n8 l ; Stuff to do when Windows Explorer is open
7 s& x* U- d; S4 G6 N ;
( s, R4 S% a9 M: S #IfWinActive ahk_class ExploreWClass|CabinetWClass! E/ Q* k; A8 C s% \
; open ‘cmd’ in the current directory
/ C0 `- D2 _* ~% ]) i8 B" d ;2 y& D3 b v5 T8 }6 k
#c::
" j# Y6 z" n |$ c: e* g OpenCmdInCurrent() ~& i# Q8 v& n0 T! P1 s R# k" q O
return0 _. {, J1 J: _% L) m( R7 }
#IfWinActive
, P7 F/ W6 ^4 e: L9 V4 { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.2 s) c, \0 j7 `" D
; Note: expecting to be run when the active window is Explorer. H: _( _2 r: |: Q( h
;
" ]% u m3 [/ l6 X' s* @ OpenCmdInCurrent(): B& {8 r1 y. \" W8 Q
{
+ D& d+ @# T2 m* \/ j6 e# y& t ; This is required to get the full path of the file from the address bar
9 _7 [( K( Q4 w9 F; w" d. I WinGetText, full_path, A5 i% k5 E( Z) U+ ^! X" m/ D# y
; Split on newline (`n)1 [3 T( D& i( v
StringSplit, word_array, full_path, `n
* l8 B/ |: P& i/ ?6 K; [ ; Take the first element from the array' B4 ^- i3 L8 T" @8 I+ r; d1 @% ^6 o8 R1 }
full_path = %word_array1%5 w# o3 S' k5 N: Z! @" y
; strip to bare address& Q. d! R3 Z8 d& B5 B" m0 p
full_path := RegExReplace(full_path, “地址: “, “”)7 l6 K1 h! S" N; V/ q% P
; Just in case – remove all carriage returns (`r); B; M' O& `! \/ D# g; N
StringReplace, full_path, full_path, `r, , all
& W- i) R3 O) z+ @" B) W8 n IfInString full_path, \5 U( v @6 t/ K( b9 J
{4 D% u$ ^. H# ?
Run, cmd /K cd /D “%full_path%”8 m- U: I) }7 h& r- L- B4 U* r
}
2 n0 ~0 {( j7 E# W/ y8 | ]4 w6 |/ M else( W- ^& z6 u. m- G3 c, f
{
9 w, ]4 m1 c3 t. W Run, cmd /K cd /D “C:\ ”
% B+ {: f' ^4 X6 w. z G' h4 q }- G( C% ~7 x% M" z" }/ |+ g
}
5 w- H6 i1 z( J* c. H: E, D4 H5 K/ ^ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" o$ A* q; \: t; [+ \7 \* D 这段小代码肯能有两个你需要修改的地方/ w5 C3 I! t# p' Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键1 j' W7 ~/ o4 R" p" ?
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ \# w% q4 ], J& R
|