此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
|2 M3 n0 e2 A6 I' \2 h$ W* d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! @2 d. R; K1 L' P8 ?& F
方式一:
& b# c% O9 l$ t4 N 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% R5 S) m" ~2 a 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
$ t, ^3 |: x( O2 l, \ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
- \& ~* }# D1 _( c: k$ Y4 h* Y$ A 方式二:
L+ t8 D( [& w* V: t" N: Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:- ]7 c1 N) I& c& A& c+ g' ?# a
SetTitleMatchMode RegEx0 y* r9 {0 T# q9 n
return
% p$ v# Q: L8 _; Y' w ; Stuff to do when Windows Explorer is open; X& g% l5 D! n
;) [4 w# f- K( a
#IfWinActive ahk_class ExploreWClass|CabinetWClass, u+ K! O' H! O2 e
; open ‘cmd’ in the current directory
+ w1 J9 E) u- s5 l ;
5 r9 t9 q1 y$ x' K #c::
" i% I" L* f( b8 c& V0 T- a* t A OpenCmdInCurrent(). b" T G& t" {, S E
return# Z) Z4 U: i0 V C" v
#IfWinActive" H: d, N$ [! i' _/ ~5 `
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% M$ p# E+ j) z% j5 h ; Note: expecting to be run when the active window is Explorer.5 {5 p7 R& V7 Q4 @+ [+ F
;4 L) K) k4 }# Z2 n3 ^
OpenCmdInCurrent()& s. F7 ^. I. E! `" N
{
& S' R6 r$ A& Z# i% R ; This is required to get the full path of the file from the address bar
- Z2 Y3 J5 M9 a6 u/ T8 i WinGetText, full_path, A0 a. ?$ {! |7 G
; Split on newline (`n)+ v0 r% q' G6 z- U0 R* Y) X- B9 V
StringSplit, word_array, full_path, `n
4 }. X0 E! q* r1 `# K1 w ; Take the first element from the array) E4 M# g5 u1 K
full_path = %word_array1%
" P; A# h$ I# v1 q: C: _ R ; strip to bare address
" C( Y, ^% L7 L: D full_path := RegExReplace(full_path, “地址: “, “”)
& z! C: U+ _3 Q: l3 _& K ; Just in case – remove all carriage returns (`r)
7 ]3 L! o0 R; E& i4 ]1 K1 z5 y StringReplace, full_path, full_path, `r, , all
6 p3 a8 n) C& V IfInString full_path, \
6 v8 M, `+ E! b; D+ I3 {% B) V {& s8 y( k& z e1 |" O9 i
Run, cmd /K cd /D “%full_path%”5 ^$ t3 Y! d& e/ e# Q$ Q b6 b
}: P) n n. Y+ H) x2 [
else8 p' j2 @# v9 d
{+ J. c! f8 U, }
Run, cmd /K cd /D “C:\ ”& v! v7 i- {( x9 z2 x% B
}
4 n5 K$ v' t9 _3 X7 v Q, ~) x) j }( [. m8 R {, Z6 r
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。+ R$ _3 a& M! L/ m- w
这段小代码肯能有两个你需要修改的地方* n6 @ T5 g7 [
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
5 c0 e/ k5 t, _% P; ~2 M 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ r6 g& k- H; j2 ` |