此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; s+ z) X" v' I' U- q( ?
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 I( z+ N; `$ K2 @8 u [ 方式一:
l5 w) n4 I+ d7 \" b: w 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,2 G" e* L5 v$ q; k1 p
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和& @( g: ^9 D8 h' }8 @
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" q8 v9 M+ V: N& l9 j/ I4 X: r
方式二:! ?- b6 z/ ~& Y" [( J
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:2 r1 n% f7 ?- n; L
SetTitleMatchMode RegEx
2 l8 v5 ^& t% g0 M7 u. e4 [ return4 m( n" a! J4 t5 c' W" c% o
; Stuff to do when Windows Explorer is open
2 B8 `! j6 ~6 r! ~( R ;1 I7 t0 h( x: B0 j; b+ E
#IfWinActive ahk_class ExploreWClass|CabinetWClass
6 |' d7 [2 s# l1 o1 Q- a ; open ‘cmd’ in the current directory
. ^6 `4 g3 `- j9 r ;
7 J) p# W# |! q4 n8 m' s #c::* B/ Y' m, s5 r. |5 K
OpenCmdInCurrent(): I$ L! q" G( q6 R# Y
return( g0 P$ \: m9 v6 f
#IfWinActive! H9 L' h9 h4 V7 z. |4 Z& t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., A2 s& i) Q# g! j% o; ^
; Note: expecting to be run when the active window is Explorer.
# [! Z/ }- `* V/ i ;
7 _* _4 q6 P" e, O! H; s OpenCmdInCurrent()
2 ]' W. z3 y1 B6 i {
( q+ T$ f/ w- v9 S/ s ; This is required to get the full path of the file from the address bar" h' R- M1 |4 l3 c) y
WinGetText, full_path, A
# ^1 H- z. S- n1 D3 Q5 M! j ; Split on newline (`n)
; E7 I6 q4 J- ?3 C% l4 P StringSplit, word_array, full_path, `n' p0 t" G Q& d% P M* y. h. M
; Take the first element from the array* X7 [; J/ e8 s1 F6 |
full_path = %word_array1%7 x+ `1 K: d0 W/ w5 N
; strip to bare address
! ]" l _& M) x6 W# @! U full_path := RegExReplace(full_path, “地址: “, “”)0 I6 W2 q# _4 C
; Just in case – remove all carriage returns (`r)
+ f/ N9 J7 ~; F4 t: \* n% E+ ^( C- B6 x StringReplace, full_path, full_path, `r, , all# p; D8 e* L) [& a) C& ?1 o
IfInString full_path, \
* s& }+ @9 d9 |" f: F {
- T3 e: f i& C' c$ ?4 P3 B Run, cmd /K cd /D “%full_path%”# w' G) j3 ~- M8 k0 S
}! N5 O3 z/ q* I
else' }+ C, q j+ d% W4 v( l
{
- k2 y+ Q2 P& c Run, cmd /K cd /D “C:\ ”8 t" T3 Q' Y+ [0 t! B
}& M) d0 w2 }! G/ z3 l% p- U: o
}( T$ V h* Z$ L) i
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# A! z# z8 n' [6 ?9 k9 Y 这段小代码肯能有两个你需要修改的地方' r: L" G! |9 d
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
' [5 u* z, }" R6 \ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: l O( b3 l, `% E: @ |