此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。7 _/ T( j& D( m8 \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- ^; f& i- M6 u8 Z# G
方式一:# ]/ G6 c0 G R7 F9 C& b9 B; o
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" G6 h2 C' Q( b1 Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
- o! @& w& g! t+ @8 s" M9 ~ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 T' X5 A) y7 I* r) i J8 n4 |% c
方式二:
$ F8 F/ e; q1 B) a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
6 B/ w9 W9 q0 ?! d3 P; u$ l SetTitleMatchMode RegEx, D, u# s) g: {& o4 U( G
return
0 H4 N9 c8 r8 R h8 L ; Stuff to do when Windows Explorer is open8 L: i2 f3 N4 o+ k) K; T
;
3 r. K# K+ C, V: M #IfWinActive ahk_class ExploreWClass|CabinetWClass
$ q# M) e' U# m2 [) T w( p+ G ; open ‘cmd’ in the current directory7 E ]# {# }, @6 h
;
8 ?9 B2 q; F4 V9 [ ^$ [' y #c::
3 g0 J* ~2 h2 ]1 e1 h. c OpenCmdInCurrent()
# z: _6 [4 Z$ g/ _ return* W& h$ x0 \" a2 J
#IfWinActive
( f/ }1 O+ a. C ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
; N& ~5 c! w+ n1 M4 A& o! h ; Note: expecting to be run when the active window is Explorer.3 f7 {! }9 ^+ ~
;& O, |7 b1 p5 J1 P
OpenCmdInCurrent()7 U( n5 l4 h8 O" F7 \
{4 a$ D" t3 K' R, J3 [& V% e
; This is required to get the full path of the file from the address bar
0 z4 H% V. u# f: o. Y1 D WinGetText, full_path, A
' W1 y+ h1 x$ x/ ?' ~* U2 ^ ; Split on newline (`n)
0 Q0 ?" s% S( X4 } StringSplit, word_array, full_path, `n$ N+ C" d* z+ S( @
; Take the first element from the array
4 W y1 x. R+ h2 g full_path = %word_array1%2 s \# a# w5 E8 C- V4 a" K4 H
; strip to bare address
. e5 h5 t! I' F* N full_path := RegExReplace(full_path, “地址: “, “”)! i# ~# A/ t0 v5 K
; Just in case – remove all carriage returns (`r)
" j$ Y5 n/ w5 `; F8 [4 ^ StringReplace, full_path, full_path, `r, , all! e5 Q$ f1 c% R3 @
IfInString full_path, \
9 T/ Q/ v5 ], h, [ {' H i7 g b' u/ k+ ]: j- F
Run, cmd /K cd /D “%full_path%”
1 B2 X, h* ]; k' f }$ J# F% O0 C! j6 n7 K0 S
else% s6 T; P* `) J6 }: n b
{
; ]6 Z1 {2 Y% c/ b Run, cmd /K cd /D “C:\ ”9 Z4 {' H" a/ v* x( x& F: u! M
}4 U% K# b& q+ |9 U& q1 {& g
}/ i' N. ?7 c2 i% M" A* i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 r+ o' E0 r4 _/ H8 d# `* o; z
这段小代码肯能有两个你需要修改的地方8 o0 ^* l% Q0 o& d }/ M
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键7 _' `8 b# ~$ ?1 h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
+ a+ B N+ T8 M9 O |