此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 q% a6 g$ }6 H i# r7 a* e3 [. L
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
9 U! V! c* `' n& ~ t 方式一:
. a; r2 g9 u% U: h8 h [ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# @; e& d/ `7 G0 J' B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和9 q2 N7 F9 Z4 d; p5 e' z& Q( E
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" W7 T3 k. g0 g9 F! W1 t$ _ 方式二:
* a/ P% `0 v6 [ o! J0 A 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
' b1 V8 h& Z0 Y% Z0 j SetTitleMatchMode RegEx
7 F# I, F2 g* z* {. Z return
, J& z" x# i5 X8 d U; m: V7 T ; Stuff to do when Windows Explorer is open
% H+ `. ?8 X: c2 h* G3 `, v$ N( ^ ;
6 A5 U% V% s; [' M$ C; [ #IfWinActive ahk_class ExploreWClass|CabinetWClass! A5 Z- u( `" V1 Y0 y& I% {. L
; open ‘cmd’ in the current directory
# b% O# Z. b3 _7 d ?2 r ;0 v: P3 n8 }7 g0 R& n
#c::% l" w: C( y4 W5 U; C
OpenCmdInCurrent()
4 R: B6 ~+ G+ j8 Z+ h return D( K# @" v( @7 l
#IfWinActive6 b0 U9 C3 a7 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 [" t( z U- @9 V! u
; Note: expecting to be run when the active window is Explorer.
" ~! k1 y' ]% G5 |, ^# K. U ;
2 o" H, N) Y& b OpenCmdInCurrent()
1 a }' n/ r+ H( C+ J' x9 n {
@. _. U R. z1 Z0 T. J$ J ; This is required to get the full path of the file from the address bar' U" D3 z" h! g! E/ Q0 s& y j8 K
WinGetText, full_path, A
9 h. w( b7 m% y ; Split on newline (`n)0 {$ r! z2 O' ?3 ^) @
StringSplit, word_array, full_path, `n
% P/ ]3 Q( d( j ; Take the first element from the array' q5 ] U _) s8 }
full_path = %word_array1%/ y; C: ]5 J+ q% V
; strip to bare address
% |. ^3 ]" {- h* ?& q full_path := RegExReplace(full_path, “地址: “, “”) T( a- [- I# ?- @/ h3 i3 e( D K
; Just in case – remove all carriage returns (`r)! q+ }& P ?: p
StringReplace, full_path, full_path, `r, , all
# ~9 j. q2 e4 U5 ]7 y$ t IfInString full_path, \
, [. `4 D8 N) _6 l {
( V1 O! D( D8 M1 {' v. Y9 Q. H Run, cmd /K cd /D “%full_path%” f0 R& p. ^& r- b3 E& \- ?2 j5 q
}$ }7 ?! Q3 P1 Q
else
8 j1 h( y; z3 O$ L8 w9 L* d2 U {
3 T7 g9 x( |. J2 J Run, cmd /K cd /D “C:\ ”
, B8 B' z# c/ Z3 ^5 u' x n- @% v }
& t; C: ?+ Q2 N+ @1 O- y+ m/ A }# ?1 {: o( @3 _; q, t8 n4 R
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 W9 P/ [" X" N# t 这段小代码肯能有两个你需要修改的地方1 Q' k; N+ f0 P9 m
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
0 ?9 T8 R( \/ y% `2 ~" x" T 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “+ u% E( [& P0 w4 o
|