此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。0 W% j; N* K+ k& X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- ]! g4 h- d; |, y B( U, j 方式一:/ H2 H; {0 G( o, b1 v5 N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
* h) h9 [) c0 I3 ?0 j6 ?+ c4 ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
6 v3 K9 c& z0 s4 x& n# S HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。& e4 ~3 b' C7 W- G9 ]- g: q$ S
方式二:) o7 B! m6 U* m/ d2 G, w% O0 Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! I" H0 x6 p: n* t" Q# V SetTitleMatchMode RegEx
2 Q- E& u) f) [, \ return. m8 u$ C2 J9 E9 m) M1 X
; Stuff to do when Windows Explorer is open# a! P* E8 ~$ T5 V1 B
;% A" g) }0 g. j3 e) i" ^* L
#IfWinActive ahk_class ExploreWClass|CabinetWClass
3 ^: q$ w* c2 m+ Y9 W- u* s ; open ‘cmd’ in the current directory
3 I& @9 \0 Q1 g- d. G" H+ d0 a ;
3 k; U/ p" ^( V: U #c::$ E# E+ E- _( R1 g& c. @0 F
OpenCmdInCurrent()
4 o* I- `0 A: c9 d/ U/ n0 } return/ H6 M1 a3 y4 q8 C5 ^+ r8 W
#IfWinActive6 G {! y& u; K9 I }( B& F1 D
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
8 N% M* {# w! Y+ o! U' L- ? ; Note: expecting to be run when the active window is Explorer.4 U/ d! {" ?1 k$ X: ?
;- Q: y4 E; ^$ `9 v
OpenCmdInCurrent()4 R4 a% {9 s; o: T+ E7 }8 G2 _
{
9 }6 F( S) v N8 P ; This is required to get the full path of the file from the address bar2 Z5 S( v! Y% R
WinGetText, full_path, A* P7 g4 R6 s. ]/ p# s8 ?
; Split on newline (`n)
+ R- p6 B" S& J# r& l4 }) e! y StringSplit, word_array, full_path, `n/ o w( a9 u6 y
; Take the first element from the array
% A" \: h! O2 n% T+ {: O0 c full_path = %word_array1%1 f- O0 m. [: \* ^
; strip to bare address4 T8 y. }& w) }4 {
full_path := RegExReplace(full_path, “地址: “, “”)* p- ]4 e' Q. C
; Just in case – remove all carriage returns (`r), J) r4 ?8 f* Z" P2 J
StringReplace, full_path, full_path, `r, , all
6 a- F/ c1 u/ y) A* c IfInString full_path, \: W1 B( k+ e8 ~2 g) |
{4 Y+ n6 y h# ~& J" ?9 l$ S
Run, cmd /K cd /D “%full_path%”
' F/ c2 i4 w5 m! { }( X: b" M0 c: q" `' i W0 f
else
6 B) j% u& o @+ O. y& Q! i, K {
7 w/ ]; U- `" Q8 v w Run, cmd /K cd /D “C:\ ”2 L2 F! v! l+ ?
}7 \9 u3 p! @" H" c
}
4 y! q1 b7 D/ t( \ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。3 i) s) Q; H% }( R, g
这段小代码肯能有两个你需要修改的地方
: a) @$ y# p2 v4 u, @ [. a" j+ _ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; [! e; t9 m/ ]
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
4 ~9 K* i; g. ^6 v% i% z: s |