此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。6 ^: L5 ~0 B6 D* g: Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
* \) r7 a6 K5 w2 S# P. \ 方式一:- z7 Y6 y- H3 j2 J: R
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* w; s$ y% |9 M3 _) }1 q6 I
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和: `% `, y. ~0 f$ R1 W
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" d3 P" k6 R) J! S
方式二:
$ V7 l( V$ G3 i- b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:( K3 ~$ p( i, Y$ [
SetTitleMatchMode RegEx% e4 d: g' X* {4 X4 b
return
' m- P, V; X7 B$ \8 ~$ ?0 |( ^1 n ; Stuff to do when Windows Explorer is open
/ F/ o& Z/ \& z/ Q; { ;
! [# h ~8 P( @% f6 d #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 [2 E" k5 T. s ; open ‘cmd’ in the current directory! ^ @, ?2 v2 b6 N3 B2 s
;
) \* p- ^' ?3 N f( u- |/ A9 j' @/ v #c::! q, b# T0 j$ V4 O6 A) w& T) C% r* r
OpenCmdInCurrent(), f6 \5 |8 y' p4 X1 f. ?9 q" T
return
# p* i7 N t6 D #IfWinActive* }7 E k, d7 a5 z4 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.* m9 w" [! Y* {0 ]; T/ \! J
; Note: expecting to be run when the active window is Explorer.
8 \" a( y: \. C' m ;
+ q4 ?# R2 ?. Z9 @ OpenCmdInCurrent()
4 j* M* I7 b* E- \ {$ P5 f. X" l- p W0 S4 y8 k! i
; This is required to get the full path of the file from the address bar5 s* }% m9 V, ]
WinGetText, full_path, A
2 q0 G5 i" A, A, \$ ^" \ ; Split on newline (`n)* l I3 J& @5 D) p% v* Z7 E
StringSplit, word_array, full_path, `n! B9 M5 ]2 T% Q9 F# m( T9 F9 d
; Take the first element from the array
1 K. V( d! v* H2 x# o) C full_path = %word_array1%7 o% c, L7 P/ l! a& Q* y, H& H- c( i2 r- `
; strip to bare address
; E$ X Q# W9 }/ z- F' T full_path := RegExReplace(full_path, “地址: “, “”)
; ?" ~3 t6 W, M, Y ; Just in case – remove all carriage returns (`r)' Y5 q: D( {- K, `$ [9 y
StringReplace, full_path, full_path, `r, , all7 z% Z: U# h& L# O! ^9 D6 M* E; I
IfInString full_path, \
& H3 v; g6 g% s {3 G1 z/ ?/ U& a) Q4 D' ~ b( U
Run, cmd /K cd /D “%full_path%”5 h6 B v6 r% k, ?% r5 i% n
}
! @. E8 M1 m& T5 q8 k4 [8 ~4 p else
, w. V' ]- \5 C9 F' x( y {
: q( E2 O5 S( f/ q. L* s) S Run, cmd /K cd /D “C:\ ”- S6 F5 ?) F. p4 d/ S
}
; M3 u+ j2 k3 Z" k3 p }0 K+ Z% ?4 g# Y! l* e
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ A f' s! x) F9 y7 ] 这段小代码肯能有两个你需要修改的地方/ C. R$ b( B! T# B: A, ?
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) T: f* s2 V2 e; H) X. S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
# ]7 a& z- V7 s. `0 H5 _ |