此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
3 T% }1 i) E2 m9 f# t) u j 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 Q0 V- S4 [* C! m$ v% U
方式一:
7 Z, M% |) S& W P# m" { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ ~2 h# [& T& X2 O1 @
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* s- [" c1 Z/ w8 G T# k HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" Q; n4 b9 a/ s* ?* r& o$ o4 D 方式二:5 l) Z4 C0 F% B
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:+ h. R0 q7 b; t; @% ]5 a
SetTitleMatchMode RegEx1 ` y& Q2 D7 a, p i0 l" x# L
return
, L! g3 |" f6 {# S ; Stuff to do when Windows Explorer is open; u. Q$ }6 Z g* _+ y6 p2 X3 T7 b
;
0 l+ {4 D; g( `$ Z7 `4 Q #IfWinActive ahk_class ExploreWClass|CabinetWClass
& v9 E- v/ K2 r ; open ‘cmd’ in the current directory: X# W1 y1 |4 d
;5 T; E Y9 I3 L: N" k4 w9 [. p: S
#c::
4 ?$ Q* G G V6 f3 l OpenCmdInCurrent(): A5 [1 X1 B/ i# Q: u: B
return
% l8 _0 Z: e: d #IfWinActive, c$ k0 I$ Y9 u4 n
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; i7 u B7 m- A$ B ; Note: expecting to be run when the active window is Explorer.- U' ?+ |" K" s5 r( R# Q4 @
;
3 \7 a9 i1 b3 t2 E) ~+ D OpenCmdInCurrent()/ a* b" t5 o: M6 i Y4 T+ A# [
{
+ v X+ m' v- }7 s ; This is required to get the full path of the file from the address bar
9 f0 b8 c7 P* h7 S9 ^+ c* L WinGetText, full_path, A
% T4 i, H2 S) d; w2 V. r8 H/ k ; Split on newline (`n)
9 y2 [0 M+ S. `- `4 O) y6 ~* n2 A! e/ R StringSplit, word_array, full_path, `n
. d+ E- c& g; p/ ^" K& U+ `$ B4 @ ; Take the first element from the array
/ ~# x' n9 b8 V! X4 n5 C* h full_path = %word_array1% p4 D% S2 l7 e$ a) t, B! G! a0 [. ~$ U2 i
; strip to bare address
& D% }: l' K: ]4 u' |, }% r" e0 q* n full_path := RegExReplace(full_path, “地址: “, “”)
' x" Z2 _ G3 E, \ ; Just in case – remove all carriage returns (`r)
0 X. p6 k* S& d' Y, V; g StringReplace, full_path, full_path, `r, , all4 `) t( G6 x3 x. n, p1 A: f
IfInString full_path, \" F" {5 f4 } ?6 G, N4 ] U( C0 h- ^
{
$ J( m; q( s- r% j' W9 N Run, cmd /K cd /D “%full_path%”$ f! C, s% F: Z/ H q
}
+ Q r1 g/ E: o2 W( q/ ]9 l4 G8 O" z1 M else
& B, o6 z0 d6 v* F9 G {
; s) L" F5 {) e/ W5 a+ { Run, cmd /K cd /D “C:\ ”
% |* ^7 h' M" C( Q }
* B2 ?( l5 y5 f5 B/ p }
$ }% V0 @+ h9 h. T 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
& v+ M2 r) M+ M$ ]5 Y5 J2 x 这段小代码肯能有两个你需要修改的地方
& _; [. E) A& c 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% e$ [$ m R3 ]7 A( ]$ g( w 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& @# q$ C7 n. |- l! S. q
|