此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
& t. h0 k: h1 `; T3 t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* `8 M. z# l" f
方式一:
/ [/ N$ Q: y$ l# T2 x 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 j' D6 _) J: \% C( B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和/ ^; ]5 H8 a; x$ x/ B0 d! m
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。# y! d8 y% u) n: a2 l H+ q( o( m
方式二:' A! D( O) E1 g8 K
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& J; T1 a/ l! j% H+ C+ e! T" P SetTitleMatchMode RegEx
- U" w9 Z9 ?1 q! Y8 _# @' I return
4 _$ A7 T0 ?3 c% x ; Stuff to do when Windows Explorer is open
& O8 l' S$ T- \: V. [ ;9 ~* u G* f! s) j" `9 [1 }
#IfWinActive ahk_class ExploreWClass|CabinetWClass
: @7 I/ p% A7 B# T1 A: V4 x$ J' O ; open ‘cmd’ in the current directory% R# C9 j" w( r, q# k' B
;3 p1 ^! {& W+ s# C( p
#c::! i l9 N/ w! r0 `9 ?& k- k
OpenCmdInCurrent()8 C: V* D4 j( P) w- s
return
% `# h, I- H, f. o/ U! a #IfWinActive
1 G# A- ~7 {+ s1 P) B- q+ f# A ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& ^* B( f, q! v, i
; Note: expecting to be run when the active window is Explorer.( ~# j5 n4 A! W9 _, p6 w
;* a2 ]6 l4 W! Z! a
OpenCmdInCurrent()+ d! w6 k4 |* j; {; ~) g
{7 F6 [; y* m6 d" R
; This is required to get the full path of the file from the address bar
. G) J& Z1 @- }; p9 T: | WinGetText, full_path, A
. V, X, [" { S9 j: V ; Split on newline (`n)
7 N# X9 M; z$ L* d, i StringSplit, word_array, full_path, `n
9 ]! F! P' W" p8 q ; Take the first element from the array
! Q; V3 p+ j e( f* o full_path = %word_array1%
" E( y7 x8 |8 x' D% l( ^5 j ; strip to bare address! R t% m, X) C. w
full_path := RegExReplace(full_path, “地址: “, “”)$ Q0 m) h* _, Y" }; E+ \
; Just in case – remove all carriage returns (`r)! T1 z/ \3 b g8 u
StringReplace, full_path, full_path, `r, , all( S6 Q- ~3 a% Q! P# |
IfInString full_path, \; l- R/ p+ I# r' t4 u
{) ?# ?3 s, U" I5 @! ~ r' g" _
Run, cmd /K cd /D “%full_path%”
W. T1 }# c ?% L }5 N' o& o# ]# ?7 ]) p4 D$ F8 ^5 ?
else+ p+ t( V% a; v8 w
{
* ? H) c2 B4 y! \: H Run, cmd /K cd /D “C:\ ”1 R1 C5 u# ` B( H* I8 D
}
0 L7 L" D0 H9 i$ l }
* s( E; x: y! ~9 s5 s 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
. Z% g) c4 \+ F6 A; p2 A 这段小代码肯能有两个你需要修改的地方
% D9 F( f7 r& I0 i9 O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, K2 }8 T$ o: k/ s
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 S! I! n0 e' t' I& F: k+ \0 C" u
|