此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
9 k- a( b5 r0 T# | 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
+ B+ [( X# A0 r" P5 p% b5 _ 方式一:0 v i# ~. D. ~; _5 J/ n
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 l+ H2 x( _% b3 m4 J 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 p0 k' a; P5 R: Y) |$ g' Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
0 L( m) u; I; v- H) s 方式二:$ c/ D+ {9 S4 |, E
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:; d4 l `) m/ x" R& x6 y4 L2 F
SetTitleMatchMode RegEx
! Q X: |3 { P" u return
% d; c7 B3 I3 _& ]5 t( c& h ; Stuff to do when Windows Explorer is open4 V- l; B+ R1 U6 i$ z* n
;# c# t8 R( S" m+ H0 R
#IfWinActive ahk_class ExploreWClass|CabinetWClass( w; h$ H/ L V' }# d, h
; open ‘cmd’ in the current directory
- ]' c ^$ C0 ]( } ;+ h& s1 Y2 t: t7 d! J5 ?: [, _
#c::
. u8 u7 e8 E! W( ?+ d" o/ Y8 P OpenCmdInCurrent()' G7 v9 l0 I/ v" T
return0 f3 w- h% s! t# f0 `
#IfWinActive
& n# m5 t- f# b% _" Y7 T ; Opens the command shell ‘cmd’ in the directory browsed in Explorer./ h6 y" h/ z3 k6 ^" g- k
; Note: expecting to be run when the active window is Explorer.- ]3 j- Z+ K- q% x6 c& h. A; Z
;( B! Q1 N8 R1 z4 X! {
OpenCmdInCurrent()
9 W( C7 l& M, k9 |8 Y; j4 o! ]# ] {+ X; A8 J# Q; ~
; This is required to get the full path of the file from the address bar
: F' r* Q# C; Z& X! [- p0 C7 ~. Q6 | WinGetText, full_path, A
' y/ D( y1 U, k* q" }0 U ; Split on newline (`n)0 v: s9 u7 S9 D
StringSplit, word_array, full_path, `n
, i* c" L3 q4 w ; Take the first element from the array
$ h( \0 F+ f7 o1 Z full_path = %word_array1%
, T0 _' J/ b, x6 g$ H. Z ; strip to bare address
8 X% G. G; K! g" f1 E6 c full_path := RegExReplace(full_path, “地址: “, “”)& J6 f) j1 P+ t' Y
; Just in case – remove all carriage returns (`r)
8 ]- U8 G7 T! R( ~6 y0 b StringReplace, full_path, full_path, `r, , all' |3 p/ i* |6 q' R% z
IfInString full_path, \ p- }1 K& d5 j' B' L
{; x2 V# }7 L4 J3 ~7 i% o1 D
Run, cmd /K cd /D “%full_path%”1 e7 D% Z' A3 m9 o g- `* Z
}
7 t6 ~* h- U+ q5 _6 h3 c else
# L* u1 S1 H) s# p5 m {
$ f! i8 G! W0 t! a$ ` Run, cmd /K cd /D “C:\ ”9 V) U# x, w$ R f! X
}$ Y: }/ L7 T* |. v+ O: Q0 q2 O$ {; m
}
- }6 i# z! e r2 A [1 ] 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 N9 ]9 O1 n' h/ f6 i# ^5 J6 d6 M
这段小代码肯能有两个你需要修改的地方
$ f8 L- s4 r' x 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
+ G1 h4 a. b' h2 V4 L0 \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “3 O& c6 v' C8 r
|