此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) a! V) l$ a Y' |% E9 I8 `
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
' @, G* k) D9 M3 v 方式一:+ W# T: P' b6 h" [4 f# y
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
% b4 l: {1 @# L0 Q5 q5 P+ v 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; j/ q* H% S: c! Z$ B HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) `3 Z. u' B8 }! `% } 方式二:
: Q# }9 k( u# w) N3 c 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 @3 {% d; w$ k, s* O5 v
SetTitleMatchMode RegEx$ f2 U B( I2 X% ^9 o7 K
return
* j8 u# F0 D4 a' e! e: F ; Stuff to do when Windows Explorer is open
% L- O$ x; {- H' z1 R8 ^4 S6 G ;
3 l; [" q+ H, `/ L! ~* }. W; w #IfWinActive ahk_class ExploreWClass|CabinetWClass; E+ ^3 z; a% z% ?6 ?* ~8 l- y
; open ‘cmd’ in the current directory( J' A' z9 u0 H, X+ `. z: z
;
# i/ D' s% u+ D, h #c::
7 Q: g% z$ {; W6 P OpenCmdInCurrent()
& H4 {& D/ l0 o% q# S return* t7 r& V$ Z# I8 }, H
#IfWinActive
3 h( C( x1 g4 l g% G+ j ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.& E0 P/ y* i( f; x A6 R* w
; Note: expecting to be run when the active window is Explorer.0 A% n: e) u6 z7 G
;( s/ C h$ j# e( l) T# s
OpenCmdInCurrent()
' r$ a$ l) Z) p( z3 g8 W {3 O. |3 Q' p6 }( @4 _% Q7 ~2 ^7 I
; This is required to get the full path of the file from the address bar9 A# U9 k% |: v! B1 | H
WinGetText, full_path, A
9 K* @3 `2 e. ^ ; Split on newline (`n)# r: {3 f" h# W, t8 ]* X7 x
StringSplit, word_array, full_path, `n* e4 t* J" I% ]; i) R
; Take the first element from the array
3 g7 H0 B5 J5 l, z- n full_path = %word_array1%
5 Q1 i( k/ d D/ T$ b ; strip to bare address
0 k7 f+ f3 ]( O! a; f4 o$ V full_path := RegExReplace(full_path, “地址: “, “”)
. w2 i- i4 z: X! b ; Just in case – remove all carriage returns (`r)
% G4 P8 \5 x% D6 p1 X V6 @0 C StringReplace, full_path, full_path, `r, , all# U4 c9 ^" I. i; \* n, |0 O, |& h/ @
IfInString full_path, \
) Q/ H) T5 f' b$ Z% d9 l {
3 b4 @, ~3 U+ h) |" J! W4 u Run, cmd /K cd /D “%full_path%”
9 e3 b, i4 A* t2 f8 Y: H* |; i }
2 g& R( ~, y; S: C else
4 ?4 w6 Q/ G8 f8 f/ \# L {
) C. U" Z& M j L' w Run, cmd /K cd /D “C:\ ”
1 M% Z9 @1 V" m4 R' K }
* H+ `2 i: P/ n; I7 O0 O }2 k' q8 b c( m
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
! }7 I0 Z4 S; F* I 这段小代码肯能有两个你需要修改的地方
/ w5 Y a6 A# k, J 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键& u4 M+ ], h, r1 ]# K
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
2 I& D! B: Y: p' l& ]! l) _# P# M! V |