此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
% H9 L( l+ p4 e/ O: [& V& Y8 o) B 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 |; T3 g+ z, R: Z2 a 方式一:) H- G, k+ T$ _$ }
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,/ K0 H: p( i! A7 C: Q
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
0 Q" `; Y1 W# i/ S5 i$ E HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 C0 Z, l' D" |/ Q, y 方式二:9 J' w! |' M d
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) e2 d. a, z& a3 W o# ^, ?& k SetTitleMatchMode RegEx
/ f- H+ J8 F7 } return# P. ]. w' J: b) t, _
; Stuff to do when Windows Explorer is open
6 B3 Q# E7 h4 H' a+ F" A* h9 \ ;
1 m2 u3 u- H* W Q9 u5 X% [+ P #IfWinActive ahk_class ExploreWClass|CabinetWClass
9 l- R; C- [, U- _5 ? ; open ‘cmd’ in the current directory
3 c; d8 s9 O+ S* X' G" m2 l" g1 A ;
' e" f' _4 y/ h, r& B: l( Q #c::2 r K. p: l z$ O/ P! O4 l
OpenCmdInCurrent()
7 i8 ?4 E- Q( q5 B# e- N& q return& s ?: J# G( S9 j' |( U0 t5 f
#IfWinActive
5 A! s" V. T" o ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' \/ I+ N8 M$ N& I5 @3 p: j/ t ; Note: expecting to be run when the active window is Explorer.
" `2 s& K# R R8 {, _ ; l7 N; K* {! f6 }
OpenCmdInCurrent() K7 B. O1 s* r5 ~6 g
{
k6 r' ~0 \& b* U& }( z ; This is required to get the full path of the file from the address bar
/ k, n9 y4 ]3 C WinGetText, full_path, A( D# W& X9 M# d0 l0 L3 i
; Split on newline (`n)- o" ?5 f# u7 [, [
StringSplit, word_array, full_path, `n
/ o/ x" {' i; B2 H9 I ; Take the first element from the array- [$ S- J- p/ }$ W1 p* x
full_path = %word_array1%
; i! c. v) w& S9 O) s ; strip to bare address
. { A" D9 G3 @. G- r# y1 G full_path := RegExReplace(full_path, “地址: “, “”)/ L7 [1 L+ W3 x. \+ r- O
; Just in case – remove all carriage returns (`r)
1 }5 V/ H3 H- m6 c StringReplace, full_path, full_path, `r, , all
) b8 ~% w) @, ] IfInString full_path, \
" H9 J6 f' a" R5 p4 ] {, o1 l n7 g6 G1 ?1 \: ^. L! n5 Y+ H0 z
Run, cmd /K cd /D “%full_path%”2 h1 T, Z" g* g: A/ m9 P% X' ~
}3 i" b; c! C5 D! ?2 C# j
else
% d1 T! V# ]# g7 z3 l {1 q* f' p- _( B7 R
Run, cmd /K cd /D “C:\ ”
) _" H& m% |9 m) w2 U- W }2 v* r) s3 O, l
}
H/ L9 Z& a+ v: O( L3 g 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 V" N" V d* U8 \
这段小代码肯能有两个你需要修改的地方1 n, x Q. |( ^' o
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键: x- ~' F" X( c1 I
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
( D+ v. R* T1 P$ X \ |