此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" v5 a1 Z% u! \" L$ I 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。2 m* k6 J5 I& A7 j/ l
方式一:
2 Z% T7 r) ?5 R- B' ? 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,7 g [5 H6 x ?0 ?5 N v( X8 W0 x
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和8 a% c- ^* `1 n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* k0 Z4 D- b; o& A: J8 J9 J2 j0 B 方式二:. Q" |/ T+ }* e8 c. ~ |
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
5 c* H5 a1 c; L* p SetTitleMatchMode RegEx! z: l4 O6 G: d; Y. c [
return
0 H3 s, J4 K$ F4 ~$ o7 b ; Stuff to do when Windows Explorer is open5 t6 `! q4 {8 b1 n/ J( D% ^2 Y
;& p0 q$ s E$ y$ y9 w/ B! b' }. w
#IfWinActive ahk_class ExploreWClass|CabinetWClass
# W6 q- L, n1 Q$ ]7 i6 H. N9 T# w) S ; open ‘cmd’ in the current directory
1 A+ P' v. T7 r- E ;
9 N" }( `* R2 |: k+ P5 ~* p/ @ #c::2 c) [6 c7 L! W0 `7 D
OpenCmdInCurrent()
+ s: n6 r$ }; y ~3 n return
, ~% W" i( Z4 e+ Y1 ? #IfWinActive
# s4 ]1 [2 P5 @# ` _5 G5 ^ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 }1 `9 I0 \" z- u% q
; Note: expecting to be run when the active window is Explorer.
! f' m6 m( c5 d J3 m ;
2 d. q$ H2 L7 v+ y OpenCmdInCurrent(), }" }( w! ], q
{8 e9 {$ f. O' e
; This is required to get the full path of the file from the address bar$ w% [; H) Z( p4 w' ?2 D7 r) V
WinGetText, full_path, A
/ K* O: M( y& B+ |6 y0 r8 V ; Split on newline (`n)
* U' f) B& j* N p; S StringSplit, word_array, full_path, `n
k4 o: m) l2 ~ ; Take the first element from the array. a/ q1 _' G' `% S9 H. ~- X- d' z. z
full_path = %word_array1%
- I2 v7 S: k2 w) t- [* f ; strip to bare address! _+ p- _: L3 v6 j+ d
full_path := RegExReplace(full_path, “地址: “, “”)2 A) J" G0 |' @) k4 @3 @8 u
; Just in case – remove all carriage returns (`r)
' ]. N$ A! m3 Z StringReplace, full_path, full_path, `r, , all
( L& s7 D7 c9 E IfInString full_path, \& }, i4 H, ^' E* C4 G: T
{9 Q: F9 i0 h+ f4 a' ~% r
Run, cmd /K cd /D “%full_path%”9 t* m# E' D2 E6 f9 i% e _' s
}$ r" }+ m9 f' @. d& D: P
else+ }9 V2 H) c: w. N- N3 A
{, y5 q! a* Y! b9 @( p6 [& \+ m7 N
Run, cmd /K cd /D “C:\ ”
' J" P- N' V8 s9 j2 t }5 }# s, Y) U2 c4 ^
}5 B( L% t! Y# ?7 X, |
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# q: H* z. V( K, C2 _ 这段小代码肯能有两个你需要修改的地方
. |, E5 v( Q' N2 \' e! C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 R4 c2 w* H+ W7 }7 |- z2 z 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “# R. u0 I7 C; F. y
|