此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。2 g0 _2 @- h t6 w; x
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 u2 O+ f' v% F, J- j9 t: W9 A 方式一:( K, h, \; Y+ F/ u
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,8 w) ^# |/ D& @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和$ c) Z1 }3 `8 ?
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。1 T8 F0 i) G X, i/ W* Q, o
方式二:
! R, D* S/ `: E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:: x7 D2 `* S$ r' ^ t; Z
SetTitleMatchMode RegEx
: @ J7 z* Z4 i# p0 u5 g2 f return, {, Y0 c; |7 \# V' A
; Stuff to do when Windows Explorer is open. N2 T5 r0 |$ @' |$ D
;
: g5 |7 ` d" F g, A v #IfWinActive ahk_class ExploreWClass|CabinetWClass: S! e7 N3 b& j% I) Q6 D
; open ‘cmd’ in the current directory+ k0 Q" [1 q% f. e' T
;
* M2 W v6 b; A, N, ]8 t/ t, { #c::
# j' B' y# ?4 H/ C OpenCmdInCurrent()' B; D; v5 L8 F6 j* @ @: p
return
& ^7 f+ N& b: I- w' G' k7 ]; w #IfWinActive. N: K) G6 y) B4 \0 s+ J& s
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. x! L" L- O) b x9 _; z ; Note: expecting to be run when the active window is Explorer.
7 d v# `5 a+ E4 J1 J5 w ;
1 q; {3 E. D' K9 k9 ^% P5 s OpenCmdInCurrent()+ G4 r. j& X s7 Y, ~4 b( w
{/ Y+ V; _3 w4 ^2 T5 B
; This is required to get the full path of the file from the address bar& p1 ^4 |5 ~9 }2 _
WinGetText, full_path, A, F! h" W% a* z; C# }4 U
; Split on newline (`n)* g; d, `' X I0 {
StringSplit, word_array, full_path, `n
. t1 r* S- B- t9 `1 d8 O9 n2 N7 Y ; Take the first element from the array
6 a" s, _* J- y5 |& l& O5 s full_path = %word_array1%9 O- I* s5 n/ q
; strip to bare address
2 |2 a0 ^6 H: K; s; y7 R full_path := RegExReplace(full_path, “地址: “, “”); i5 [4 W" O1 y G, O
; Just in case – remove all carriage returns (`r)
- {. x% H" h3 T+ _4 O1 K# i( F0 k StringReplace, full_path, full_path, `r, , all
! a9 h+ C" P; k* ]6 J" }5 G IfInString full_path, \
8 o0 g0 C9 O7 x# J {# ~# m1 p8 a9 a8 l. q
Run, cmd /K cd /D “%full_path%”
# R2 \" I0 u1 H( Q6 k0 v }( B _ P8 j5 J% B
else; e1 q2 Z2 t t& Y( H
{* `6 n; U% ?* G* ^
Run, cmd /K cd /D “C:\ ”: b2 T; W4 x# ]0 ]5 x
}
* A) R2 L6 U" S1 N" e }
$ X& h) Y {' W) _! C 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) ^1 c8 X& p: k% d! K& [
这段小代码肯能有两个你需要修改的地方, D, _1 H2 T+ [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键' Z3 x1 V6 v; F! t, K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “, x5 O8 t2 ~8 N- V
|