此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 B! L+ T8 a1 m; j+ d# \4 g- Y2 `: m 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 R/ _# H" a# l& c! \7 ?
方式一:
, D. ?3 H5 g4 n; ~: U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,, D, g5 l( k: f D" }" O' j8 ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# i% i7 |7 X5 n- Z. t0 [. E HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。( s. G3 j& y. s7 ~, X5 w6 C
方式二:$ r& \1 g. B; h! M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ U1 \4 A& h2 q5 U- h8 [
SetTitleMatchMode RegEx% h; Z4 x; H* [2 y: o$ E/ E" L
return) h6 d& N0 h# \' d2 P+ }2 O
; Stuff to do when Windows Explorer is open( C0 |1 j n& L5 {4 V
;
7 O- e, r6 {- R/ @3 s. [ #IfWinActive ahk_class ExploreWClass|CabinetWClass
+ `, g2 R; a$ v6 a- S ; open ‘cmd’ in the current directory! H; J* q- f2 n9 @
;, O% l& j% Q+ a# Z/ r1 @& p. Y
#c::4 r K# P& m; Q/ v3 v/ A7 ^' T
OpenCmdInCurrent(); t: r+ n% C% x6 |* B
return
S# V# I( I8 i7 P" x( a* ?; G #IfWinActive8 [3 l1 X4 s% e- K( p- U' {
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, ^9 f8 r" z; N/ \+ n2 i ; Note: expecting to be run when the active window is Explorer.
: Z# V$ L7 z1 o8 l ;
; f2 Q& @7 v7 D: ?! v OpenCmdInCurrent()' t1 ?% D( {. y6 I: c0 F
{
4 l4 M. T; {$ { L1 J) } ; This is required to get the full path of the file from the address bar
/ ^" c7 a: N5 j3 ~+ B. b) U WinGetText, full_path, A1 F2 P6 f, g. N4 \0 E1 {2 i4 ]
; Split on newline (`n)
' W, X4 o3 J# y* U. C" l* I1 Q/ z StringSplit, word_array, full_path, `n
& K5 G/ s7 J! u9 I/ I$ D ; Take the first element from the array
$ g; U1 k6 w! T) t: k full_path = %word_array1%( k3 c3 R; @: `( ~( W; f6 c
; strip to bare address! _ L, N- y) Z& w' y0 l+ j7 U
full_path := RegExReplace(full_path, “地址: “, “”)6 Q; n1 G, G; e9 P( |
; Just in case – remove all carriage returns (`r)$ N% ^6 A& F7 X2 P5 X
StringReplace, full_path, full_path, `r, , all
4 O( X5 h3 {( q0 r; @2 u+ j' `4 G# I IfInString full_path, \
* A. l" f/ {! I2 Q% E {
6 l2 y2 w/ A8 B2 X4 @ Run, cmd /K cd /D “%full_path%”
/ D2 Q# ~) ~# c* E* P. [$ S7 F+ T8 m+ @ }
8 H* l% G' [$ P2 R/ o else
6 I, e% `+ v/ T% @* X7 m1 n {
8 q% w) h3 z' P) f* p Run, cmd /K cd /D “C:\ ”
\, p8 g2 d/ e- h) P }
: k1 V/ n* a7 y# n } j: d* @. b3 [! C* `6 Z
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。; L! Z, C: ~5 Z) X5 i
这段小代码肯能有两个你需要修改的地方
g5 j1 p' Z/ K, e9 [* Q3 p% e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. S/ V5 K+ T8 \0 s 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “5 A. ?6 k; Q0 ]# x: p2 k
|