此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. p3 | k$ u7 M3 `$ d3 u" _0 x4 W
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, g; L5 ?$ u M( x& @8 F& u
方式一:
* W1 Q7 H5 m* B8 v# p2 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," D7 r) b" L* F% J. R8 y) v
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和. V9 m2 H3 G$ U
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ I h$ ?8 K5 l/ E 方式二:3 t! x( Y: W, _3 m8 Y
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
: p. K4 Z+ T9 ~ SetTitleMatchMode RegEx
0 |8 D$ C0 Q6 q( {0 h return
5 l; c, g j l, f ; Stuff to do when Windows Explorer is open( H9 R2 ~ }8 W+ T9 v9 ]
;: m8 y; g& G& e6 z; M) s* {
#IfWinActive ahk_class ExploreWClass|CabinetWClass
$ j& C& J9 w4 C' s5 j ; open ‘cmd’ in the current directory
& w: _: a& E1 G8 }( B ;6 C) B5 f: R8 O% V4 e5 I. {( Z0 p
#c::
) }: X5 f2 ^ r" @" [ OpenCmdInCurrent()
6 o# c. _+ q8 X. K: A return4 A7 x2 e- m' F1 `7 x) A+ d
#IfWinActive2 d" v# _7 }7 T$ V4 l' j7 ~
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.% J G$ q' l2 f5 W0 o
; Note: expecting to be run when the active window is Explorer.
D" J6 _2 Y- J# x9 Y# ] ;
$ s( u4 D v- A3 Y% X2 a OpenCmdInCurrent()9 r) L+ g" Q( }; Y
{
" m+ D. v: i% c/ l9 ?( h ; This is required to get the full path of the file from the address bar0 s; |9 X6 x0 M0 D4 ~! O
WinGetText, full_path, A
4 e/ m; {! G& V1 a0 E. |0 k ; Split on newline (`n)& k7 |! s/ E& X% S
StringSplit, word_array, full_path, `n
% l& F$ S% T/ p. W* h ; Take the first element from the array
! p$ d( Q- R2 G7 M+ F$ @ full_path = %word_array1%3 t4 X0 W0 ]% m: o- ^% c$ j
; strip to bare address
* t( j( r" b, i' v3 D/ ^) b full_path := RegExReplace(full_path, “地址: “, “”)% G# y9 }% z7 O+ G/ s- V6 Y
; Just in case – remove all carriage returns (`r)
! b7 X3 f( J' N+ f5 w StringReplace, full_path, full_path, `r, , all, m' N/ E. _. i5 p
IfInString full_path, \
* k4 n( s) r! ~ {9 b8 R0 \ E" F8 c+ M- x5 x
Run, cmd /K cd /D “%full_path%”
/ ^6 V% @( n- X% @ }
+ O* y U# k# o; r; U) \ else9 g/ x2 p3 V! v9 s; E) o; D) _3 S% ?
{: j! m1 |4 y8 w! }1 M" H0 ?
Run, cmd /K cd /D “C:\ ”
7 k, ?) H4 K. F' [ }
; U; r# T ~4 U) H- w, }6 _ }# d2 G& \* ^4 p( Q8 k4 M
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
/ j' F+ L" F( T0 E# A 这段小代码肯能有两个你需要修改的地方0 B; b0 q- M4 L5 |* K6 ^. r0 E
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 v& Y$ r" R1 n- W 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “; S! F9 a1 ~7 v6 c8 s! P
|