此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。! W: u4 C+ m p. n1 m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。% [5 }9 ]& S' j. k/ o5 A2 c
方式一:! P' T' ?0 H6 v: L$ M
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
, F; {3 @0 F' R: v( |4 L! u- Q8 W 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* ^4 o: Y% _1 Y" h. m6 w HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 z9 ~$ l7 y! ]( v
方式二:' o' b1 H" `& g0 w
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* \ [* {2 R9 c9 ]+ z- J; ? b* S
SetTitleMatchMode RegEx
! d5 Y0 S/ e' s return- a6 U. A- d' E, w
; Stuff to do when Windows Explorer is open
1 f- g5 [6 t2 P* N, e ;7 z1 Z2 M) A E2 \
#IfWinActive ahk_class ExploreWClass|CabinetWClass1 z+ I6 |. q5 I8 E: V
; open ‘cmd’ in the current directory
% h9 b8 F% b: q* e* t% X; z ;5 O; ]/ {, D; c$ V
#c::
5 H) j6 E5 S( U: j0 Q* Z9 D9 m OpenCmdInCurrent()4 c6 @3 i- w0 W1 x5 `5 Y
return$ `0 ]- w$ E8 c! z" K
#IfWinActive- @% i5 x- g# n# M( x+ b
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
1 I) T j0 ?* W4 W% U, L" F* d! i ; Note: expecting to be run when the active window is Explorer.
5 J! M: l4 o) K* h ;- M5 L% l, s' E0 a3 L, w
OpenCmdInCurrent()7 s& [5 u5 K9 q$ U' W
{
; `& [- g* v9 v# A: n ; This is required to get the full path of the file from the address bar
" G$ _* z+ ~! q# h WinGetText, full_path, A# V. l* A a2 l3 y' r
; Split on newline (`n)
1 {( D ?. A* q( M' J StringSplit, word_array, full_path, `n. U9 P' g7 T+ T+ z- `
; Take the first element from the array
2 ^7 R" i/ n( v9 e* M s- a' \. \ full_path = %word_array1%
% I8 c6 T% O9 W4 P& R$ N, W ; strip to bare address$ ]2 t. j# X, l- F
full_path := RegExReplace(full_path, “地址: “, “”)
" y& e9 x/ k% c$ q. i/ N ; Just in case – remove all carriage returns (`r)
! D, @4 `7 v+ S) ] StringReplace, full_path, full_path, `r, , all& X$ L; W& @( r/ \
IfInString full_path, \. u: c* p* P- U! k2 F
{8 v( {9 N& G' k# z, }
Run, cmd /K cd /D “%full_path%”' C. E& p( B5 I+ r
}4 w: ]7 c# X. D7 k! Z3 {
else5 e' k! Q1 C0 T$ u' E
{
! w6 C* b7 R) l) e4 s$ {$ H1 b Run, cmd /K cd /D “C:\ ”- E. @8 l4 v' M4 U# D" ~$ N o
}
) k Y& N/ K4 B3 e: G }, _( a( k3 g" z5 I4 {; S
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" u) j6 o$ @% y7 o
这段小代码肯能有两个你需要修改的地方
# b7 [( E1 J' h 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
3 J6 \% {2 X: s) F4 N 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" M; N9 ~ h/ i+ b- ^ |