此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; e1 P( l6 h. B8 T/ k 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
4 B" ^" k# n* x 方式一:
( L4 H5 v% D9 h7 v$ ?7 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
C( K% e4 y' Q% D! g0 o 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
* c+ q( |) M y2 M. g( o HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, R( b0 P6 E7 W7 H 方式二:9 d5 @- @' V, g `/ E$ R
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
1 f$ z7 H! t4 \ SetTitleMatchMode RegEx
: t0 P$ h+ D: y2 f* ^ return
. C/ s m* p% c9 B3 L2 M4 [ ; Stuff to do when Windows Explorer is open; _' d1 N1 r. O
;
! h& a$ s" F' n( c- v6 K5 O, m #IfWinActive ahk_class ExploreWClass|CabinetWClass5 c5 N4 M8 g& i" m* D
; open ‘cmd’ in the current directory
3 w7 M( ~3 G" F- ~. y8 D. I. D/ M ;" Q) k( K/ Q5 v1 q4 x
#c::
4 M s! _7 o5 f: H% X OpenCmdInCurrent()& r9 w$ N8 j4 M2 y( `8 n8 ]: h
return
- E W* N' K6 m2 L- | K #IfWinActive8 l" f, @- s/ Q% G) f, r5 M
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
6 w/ v$ a, x9 B# g ; Note: expecting to be run when the active window is Explorer.2 Q" p' w4 ?6 d1 N+ l
;
% i; h1 v, S8 |$ X( q% t OpenCmdInCurrent()! L. I' o+ r A
{! _% q+ O/ [5 ]
; This is required to get the full path of the file from the address bar
3 ]# |. x e+ D# ?3 q+ J WinGetText, full_path, A2 a2 U }6 g% I# ~
; Split on newline (`n)
g3 ?+ L. C/ }6 z9 j. b! h StringSplit, word_array, full_path, `n6 T* R. E' U1 h3 s7 n5 f7 [
; Take the first element from the array
* v8 s' e. _7 s S0 W# ^5 d full_path = %word_array1%8 r. h; w- S v5 l+ z
; strip to bare address/ a+ ^6 T* X5 r0 o& p
full_path := RegExReplace(full_path, “地址: “, “”) v* q3 @6 Q) f, h: R
; Just in case – remove all carriage returns (`r)
2 z% D0 z( e7 e) Z$ \# g StringReplace, full_path, full_path, `r, , all) A; H' S9 W3 k
IfInString full_path, \
8 K/ l' W- G' K# A, e' B {: q {4 P, ?( w/ n5 U( v6 E
Run, cmd /K cd /D “%full_path%”, d$ i$ ?0 ]! ]0 N$ ^: g
}
0 ]3 j- N% \2 J# C2 Y2 N, ^! q* ^ else
1 E ], X% e" } {
. M6 x% E1 `8 l) n/ H2 F Run, cmd /K cd /D “C:\ ”
( M$ j( X) k4 r; H, V2 Y+ r }. i; f% Z' v5 S/ a8 f. J
}! k( G, i% A' c- T7 ~' L |/ }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。7 w# s. g% J0 I- G( F# _
这段小代码肯能有两个你需要修改的地方# s, g2 O8 S% u n3 q, [$ u) n
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 a! M8 ?& I4 I+ i) r- w
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 H8 }% x8 m5 g! V" o- K' X" p; I
|