此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- C- k5 [9 u0 B5 b5 h! @ 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
! n5 k) X: ~6 ^6 b5 V 方式一:
- Q8 a5 D" a; b' C) j 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
$ u4 X+ h5 H; n3 G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ S8 `( v. ]7 c: f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
& }0 M9 [' q2 [, H$ W 方式二:8 Z8 E& N/ W; s* F/ Q4 n* f! A& z) o- s
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:* a0 L5 F; M8 S3 R& o" M1 d0 a
SetTitleMatchMode RegEx3 {; Z* J# B# ^" B/ U9 G; J( a$ \ F
return
6 `8 O* |0 D& ?. g& S+ O" g ; Stuff to do when Windows Explorer is open& d; H [ k( H! {9 l# a$ `
;
3 B" N8 g! N8 b, s4 C" f( b. h; K #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 Y3 s" M2 `3 T0 b7 C5 o+ ~ ; open ‘cmd’ in the current directory
2 r# R/ X. m$ e1 U$ U: a9 J ;; ^& _3 k* y! A$ m6 s
#c::& ]- L9 O+ f% s$ a: m- }6 H
OpenCmdInCurrent()
2 Z0 l' N8 {) d' x, G return H4 ^, t2 U. _$ h/ d
#IfWinActive! a: ~3 w ]. u3 X/ Z7 X
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.' P* T% A% K$ @) c# M* I
; Note: expecting to be run when the active window is Explorer.
/ E3 F" g& m/ t6 P3 c ; ^8 G" k0 u# S( z6 K3 m
OpenCmdInCurrent()$ n6 J' e+ y) M8 F) f( d
{, y4 }+ P) q O" t0 L+ j2 ^! k
; This is required to get the full path of the file from the address bar! M4 x" n3 [% {
WinGetText, full_path, A6 n, R2 v% q% c
; Split on newline (`n)4 m) A! Q, R& z; p8 D
StringSplit, word_array, full_path, `n
3 w! w% |5 O7 g/ h/ W M ; Take the first element from the array4 N, A5 ^' p" F% E: h! S
full_path = %word_array1%
3 R5 x; A; \& b1 J6 R ; strip to bare address" E& t, u1 v1 V' P4 V) R, v1 G8 U$ r
full_path := RegExReplace(full_path, “地址: “, “”)
& d, s" w* q# A" a: r% ~; E( S% v; e6 h ; Just in case – remove all carriage returns (`r); b& q6 m. `( F; d4 E6 v% g! _
StringReplace, full_path, full_path, `r, , all
2 m' k9 E/ i- u7 M; r2 \ IfInString full_path, \$ \: N8 Z" j( f
{
# c* a1 j& @/ E! p: i2 A7 Q8 K Run, cmd /K cd /D “%full_path%”0 ?5 Q1 m9 I6 e( e
}
" E1 [1 y9 e5 m- n3 ^+ Y- ^ else
; G5 U! M7 c8 o( u4 [ {/ J8 U& S) E5 l- y5 t
Run, cmd /K cd /D “C:\ ”
& e) {5 C2 y, X. s* T }' ]4 O3 X V3 |. r, E i
}
* q/ D0 r" V; u" C3 O 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
* _1 X" [( \. v4 \% w, o% R 这段小代码肯能有两个你需要修改的地方
; T( k0 N; m/ W- j 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( B8 N! h( @: U
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
8 v6 N0 K8 J! z* A2 ? |