此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。 b1 c- ^$ w2 }- Y) A
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。5 j/ V! t( z* m h, W
方式一:0 m1 l7 r/ }9 L: |; @
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,* s( }# o5 C3 G9 r
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" i j9 u3 E- e. j HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
' U% u& y8 b1 I; a' B 方式二:
( j" K! j/ E, Z9 k4 {# z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% Y& H6 O! J9 u( S8 A$ l SetTitleMatchMode RegEx+ C& a( E$ D& c4 ]; F4 m2 `
return
! W0 Z% B0 s! K( j2 F+ J2 ] ; Stuff to do when Windows Explorer is open$ m, t( K2 V$ K6 C2 X& `* R/ b
;! C) ]0 j% y) ~( N% z2 i! X
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 ?! s! n: F$ t4 @2 K% G( f ; open ‘cmd’ in the current directory6 {. }1 l& ]- S+ L" B& J( C7 ]$ H
;
; ~+ z Z- T( l #c::
0 ^% X8 e6 n6 O OpenCmdInCurrent()
, h y1 F2 l( k- s return: h9 K! m( c# i J/ R
#IfWinActive
( ^7 [" d1 o, ?; b) L+ e ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 x* P( c! P0 h) B/ g6 |& L% T- B; ^& A
; Note: expecting to be run when the active window is Explorer.8 u0 t" w% f( t# R5 c2 q0 j
;
6 C: V/ j1 @& c3 Q8 x) o OpenCmdInCurrent()% y! ^# Y6 r$ J0 T3 j
{5 @/ e7 P/ V# \3 f, m7 L
; This is required to get the full path of the file from the address bar
& S) f: G; e( i5 J' G- e WinGetText, full_path, A% ^( x5 v% X% Y
; Split on newline (`n)
6 I$ C, r+ O% f: k" E StringSplit, word_array, full_path, `n
/ ?& O9 o0 m8 F% ~+ [ w9 e ; Take the first element from the array% Q' i7 D* W6 V, e9 L# v- [
full_path = %word_array1% i7 ^4 M) b$ i: u
; strip to bare address
1 ?2 v6 |# i2 y3 ^- @" o {( ^ full_path := RegExReplace(full_path, “地址: “, “”)
4 O1 d( Z' b) T6 p( T. s5 f0 l ; Just in case – remove all carriage returns (`r)
' A/ E/ @% K8 T2 a" `& i) h. S StringReplace, full_path, full_path, `r, , all
% ^& N |" m+ a) N# N9 S IfInString full_path, \7 [* N7 z7 Q7 u; a8 g
{9 m# l- x' g" P0 `/ z, v
Run, cmd /K cd /D “%full_path%”
( U" t9 C) r4 q; j }
3 _$ m2 l+ v: |( ^/ `9 Z, ]! h else( x+ @; U; o( R; K
{
/ T, w# u {1 c3 Q6 Z Run, cmd /K cd /D “C:\ ”
0 y+ |: ]% {- j5 K }
. d& u9 C. e% C+ Y- ]% S. W }0 O9 v8 C( x8 d. H9 s- @; c
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。' C3 i2 w& Q' D2 ?: I
这段小代码肯能有两个你需要修改的地方1 z# t' {) Z& N; p. p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 b+ O3 E; p- G. d6 I 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& g4 x( U# L. i4 a |