此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; u D& ~. v! c$ x* G 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) n6 b& d& F, L" L
方式一:* F0 C4 l! l2 a9 W! c
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
) U- C. y/ w4 c4 Z& \2 O% J; l 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% w8 Q* ~5 W/ b2 q HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
( ~+ o! n- T& B% ~) }; e5 H8 y 方式二:
* ?6 O. f6 x8 l- R4 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:/ H$ o& `" U* l9 ~7 B( u
SetTitleMatchMode RegEx
' u$ O+ m% j* [6 Y return
+ g: c3 `* Q u9 k& F; U2 m ; Stuff to do when Windows Explorer is open% d4 E$ D7 j- W5 E, L
;
9 P( ]! |7 ]4 j #IfWinActive ahk_class ExploreWClass|CabinetWClass8 c; G, o8 p. l) a
; open ‘cmd’ in the current directory
9 k7 b. Y3 I3 E" i" v ; g+ ? R" Q9 G5 s
#c::9 m4 f# [, l/ `1 u, C
OpenCmdInCurrent()
$ u+ B, _5 F3 ~4 i8 W) k/ h return' R! k1 T1 X: O
#IfWinActive& }4 O/ Z5 c$ m8 F) T f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
: w4 U6 i) [6 B9 r ; Note: expecting to be run when the active window is Explorer.# I D8 c4 k z8 p! K
;/ D' v; l( O6 V1 p4 R2 J" A( z
OpenCmdInCurrent()
+ x" u. n" C+ |. l1 D {
" s5 Z4 `% R: Y+ Z( E- |' w ; This is required to get the full path of the file from the address bar
" U2 \1 ]$ J' a' D3 a8 V' ^6 H7 n WinGetText, full_path, A( S. U; F! `( F
; Split on newline (`n)
4 C( e7 `& z, Z( S3 O7 y StringSplit, word_array, full_path, `n
( S# g+ b' A# u! Q6 N# t5 m ; Take the first element from the array- M t" \/ U' | R1 c! ~
full_path = %word_array1%
& E& C* l2 G% @+ M+ u' r8 Z& t3 N# ` ; strip to bare address5 a1 X+ e; A6 s/ Z h( E5 r
full_path := RegExReplace(full_path, “地址: “, “”)3 }3 Q4 {3 K' C* o4 |' K" u
; Just in case – remove all carriage returns (`r)
6 ^ k' Q4 s3 x. Y8 P D StringReplace, full_path, full_path, `r, , all
) Z- K# J' j1 u' t6 X IfInString full_path, \
7 R5 I& W, [ }3 S% H5 d# y9 j {$ z, \9 l7 [) K) ?1 H4 h+ I
Run, cmd /K cd /D “%full_path%”
; u" L) e% U) t: G; U }* [6 ^* _# I. R; ~# Q) r' I
else9 P' v# Z( [: y w: O/ b/ {
{
$ |; n1 P0 B8 s. P Run, cmd /K cd /D “C:\ ”! u1 ]& z g* p4 [$ [+ i+ @: v0 |
}
+ \# ^* Y0 P3 I3 W. y: E6 ~9 ? }2 L8 b; M* @) O0 c% Y: {
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
( R9 q; V/ j) x; _% s 这段小代码肯能有两个你需要修改的地方
: l% m+ f+ a! t% L 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键8 z6 t$ G7 Y, [
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
" p( H& g# z3 Q2 m, Y |