此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" C8 D. r- u/ D: c! {
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
/ z$ a& K3 A3 Z/ r6 V( f7 g 方式一:
4 N" g( z& Z9 ] 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( { x* H0 {9 K
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: G3 f) C- J `6 y6 p
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 r: b7 C1 w5 p' Z1 z 方式二:: C6 B8 d; @% S4 { U
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:0 l7 t6 r' t0 ~; P& D; c- q, U+ |
SetTitleMatchMode RegEx
1 w2 J$ B P8 i# N) A' Z$ T return" y' U5 X" T N- B3 A" ~
; Stuff to do when Windows Explorer is open% z6 {4 \: [4 s+ n- \$ c3 ^
;& |) J1 _' ^8 l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 y* Y2 z( a: {4 ]; ]& u& d ; open ‘cmd’ in the current directory
# \, ` e, R* S7 f" ?1 m; e ;4 \1 c& ]: }, m, q, B" G) Q! u
#c::
0 F- @& `; a$ [3 @ OpenCmdInCurrent()
4 k# Z: Y' Z3 g; v7 _3 x return
) t. d+ D$ P3 ?4 m- L* m #IfWinActive
6 Z. ?5 X1 T, m0 R ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.( f) M6 s( ?: w- I# x9 \
; Note: expecting to be run when the active window is Explorer.
8 b' ~: o b9 _$ R ;
: H) M5 Y u! ?" v8 ]7 { G OpenCmdInCurrent()+ I8 r3 R4 W) B# W9 Y0 b
{$ k2 Z3 F+ G) n H
; This is required to get the full path of the file from the address bar
0 X! [. S4 s- }: t& j WinGetText, full_path, A, B. O4 p* d4 t. ~+ h' w0 R
; Split on newline (`n)
+ w* J; F v) F StringSplit, word_array, full_path, `n7 p; |! t6 u, |: j
; Take the first element from the array0 n! U6 S/ E7 N9 k% r& Q
full_path = %word_array1%
: V+ |4 G) `/ u3 i6 o1 N ; strip to bare address
: w& [, G+ T6 i% W- e full_path := RegExReplace(full_path, “地址: “, “”)5 Y7 d+ o7 |; a# O% o' U
; Just in case – remove all carriage returns (`r)! {! n, v# `0 ^/ ]4 ?4 l
StringReplace, full_path, full_path, `r, , all5 t9 _1 C1 g4 o
IfInString full_path, \+ V$ n/ t0 p6 _/ ?
{ M- ^8 C6 c; M1 m
Run, cmd /K cd /D “%full_path%”8 j# ^. \3 j" o; j; E, q: V3 y
}$ r- D& }2 p0 m5 C
else
' x+ Q- v) f# Q" |; J6 ~2 h {. s v% n; l4 A5 d
Run, cmd /K cd /D “C:\ ”8 ]/ ^+ ^8 u) l* f
}
3 ? h8 s* ~* D* _/ |% }7 J }/ L1 C& ?: D6 R# m7 f" \
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) }2 Q6 J2 A+ b9 z3 O/ R ?
这段小代码肯能有两个你需要修改的地方
; Q' j( @+ X2 b 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, q: g. v6 b& |1 I: ~7 T# z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
9 B) a' _$ u; n1 M' S1 l: o3 ? |