此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; h$ M; U s u4 B! J 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
" F" r' n. |9 h$ _/ M2 I' _' A5 t 方式一:2 q6 C$ T: S. k4 } K
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, B& ]. b4 a8 H8 y2 G5 v. a
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 c* o! D. H8 ^' i0 @0 q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
6 X( v3 M E; w3 l& e 方式二:* X/ F; f! a/ U" N1 s% V' }
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ d) g6 r5 g0 J
SetTitleMatchMode RegEx
) k+ q8 ^4 n6 R, e0 Y return
" J) ], I: o6 Z6 h: `0 v1 M# T ; Stuff to do when Windows Explorer is open
4 J$ l5 X/ D; h' G: z8 n; y3 E ;
. C( l. _) N; |( W' c( R% V8 h4 v #IfWinActive ahk_class ExploreWClass|CabinetWClass+ G' [- U9 o# } X. e
; open ‘cmd’ in the current directory
" A- [( \/ T, p( d ;
7 H% i/ ]: a1 R$ u/ C #c::/ g$ G. C# Q) l$ z3 d2 |
OpenCmdInCurrent()2 n" j( _2 Q8 G
return9 B& F ]" `7 ^. k: u
#IfWinActive) ^: y k4 R2 x3 e
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 j$ t6 ]- R5 q* }. m r
; Note: expecting to be run when the active window is Explorer., F, n( E2 m# p' x6 r* f1 e
;. {3 c' L# V% y6 n/ q
OpenCmdInCurrent()
% u2 `( X. n) k0 z {
! D! B( C! L, y' U/ S4 k- K+ ^ ; This is required to get the full path of the file from the address bar
% H0 `& k0 n3 a2 r3 w1 N/ e$ } WinGetText, full_path, A% k1 T6 t" {( `
; Split on newline (`n)/ [/ ?; `" {# b8 x
StringSplit, word_array, full_path, `n
/ V/ z0 e Y9 u; j$ Y. j- T ; Take the first element from the array
E$ C* X( p3 G' B' s# L" }" Q full_path = %word_array1%2 R' W2 o+ I* f
; strip to bare address
- x6 i k+ L$ J full_path := RegExReplace(full_path, “地址: “, “”) _9 X3 W; f0 v& q" M
; Just in case – remove all carriage returns (`r)" m( i t5 l4 H- x
StringReplace, full_path, full_path, `r, , all
0 q' D* D. k! E1 g0 S! I IfInString full_path, \
1 w, F. T" P& E2 z0 Z* l {3 t# n2 G# C; ~; v) a5 T. `
Run, cmd /K cd /D “%full_path%”1 B3 f+ S. m/ W- O" t7 w. G; B
}
" c8 v9 I& }/ Y* p4 \3 Z else) _' P! }2 z. q1 }- P3 v# s
{
! @& f' V* b3 M, ^; u9 u Run, cmd /K cd /D “C:\ ”2 H! m1 }. o# Y. E2 D3 h$ b6 d
}
0 T' h" F$ }+ n }3 H9 M: y/ i W, T9 M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 k7 I% B2 R( ^ e! J4 o
这段小代码肯能有两个你需要修改的地方
8 k, o' N! i( q$ a* y m, Z+ J; n, F 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键( A6 }) k" @' m5 R! }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 w/ I P9 y) l! e
|