此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- }4 |# A+ s/ {" u2 d 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。8 y/ v T9 O( ^7 x& c+ r) X4 N
方式一:3 L7 b! S* w/ g4 s" S0 X$ s" |, b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
4 K9 t2 L* s1 ^: V 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
/ W ^' K5 C( j- d$ X HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。6 a. y( X% |3 c
方式二:
7 W* n& [% [ V3 N4 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* U J" k$ K& c( d2 [; N SetTitleMatchMode RegEx
( X# u6 T5 r) {+ f7 r: V( \/ f return
) M* ?/ K6 }- s! t0 ` ; Stuff to do when Windows Explorer is open4 m, m- j- q }7 y1 V, @: S1 W! @
;
* v# Q8 s6 l u' ^4 q #IfWinActive ahk_class ExploreWClass|CabinetWClass
. f9 d0 y Q- B( g: R% L ; open ‘cmd’ in the current directory( J$ G+ T9 K0 f* Y$ A
;. H5 Z6 h: p; e" s* ~3 u
#c::5 v8 b& n- ~( z8 P5 q
OpenCmdInCurrent(): R8 a$ {% U8 x( u. c+ A. P
return
_8 ^& i1 n2 f) L #IfWinActive
# f- q( H9 b- M+ B( F ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 M8 R6 R: l8 j) ~7 g$ {- u
; Note: expecting to be run when the active window is Explorer.
4 E9 g4 y) K. l$ Y$ g3 P ;
0 ~( K: W7 ]1 g$ P7 { OpenCmdInCurrent()
* s. V* j- Q7 V9 d; S7 W% _ {
2 U" a% Q# |- D5 M0 H# x, D3 f ; This is required to get the full path of the file from the address bar: i5 m/ ]& |% P8 T4 C
WinGetText, full_path, A
" e r. g0 ?, n" X# q8 } ; Split on newline (`n)
+ }8 B* M( @8 n, E StringSplit, word_array, full_path, `n3 U5 D3 g7 X1 H3 {. J
; Take the first element from the array
5 t0 G- r: \- L+ V3 w( s3 ` full_path = %word_array1%
* M+ P( O5 D' R- Z ; strip to bare address
! E" W4 g# [! D4 f& V full_path := RegExReplace(full_path, “地址: “, “”)
4 c" v8 W. U* f# E ; Just in case – remove all carriage returns (`r)
2 ? s6 u) n1 R# c$ k( B0 x StringReplace, full_path, full_path, `r, , all/ u* Y( Y& v. J' {# P
IfInString full_path, \5 R0 @; P* b% x! G2 x- s
{) ^! f& ^4 r2 v/ e2 l# K/ q( E2 h
Run, cmd /K cd /D “%full_path%”$ W( T1 r* ~3 f; D' P6 h: N
}- f- s# K- O/ N% l$ B |6 I3 B: K
else
0 |6 |9 G7 t. e! {. O {2 c0 ?+ c8 s o- t% t) m, o+ B
Run, cmd /K cd /D “C:\ ”
0 G0 Q1 Q) ^8 q& _8 ^+ { }# o5 S7 b+ }8 |9 E8 b# p
}
, w) j! T* \3 A7 ?& Y" X 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! D6 }% O$ N3 K5 M* \
这段小代码肯能有两个你需要修改的地方4 n% D, \3 P% r* F
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 @( d( a. O8 I* r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 d9 @$ \2 _+ w/ v6 X. X! T0 e |