此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 Z' b4 {( b v: _7 x$ z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- v. W- s7 K" D
方式一:
7 f1 V0 q4 R, g) i 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
8 {- A# R% o5 y- m Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和4 ?; w( _6 ]0 s6 f G
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
1 L0 M3 ^7 _) \ 方式二:
0 Z+ p6 b! Q* }- _+ a7 g/ h 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:, @( M* a1 @$ C+ z0 l' X) c
SetTitleMatchMode RegEx5 h3 q# C/ P( l. O
return
& J- O9 t! ^1 A- t$ E* f9 L: ~% W& o4 I ; Stuff to do when Windows Explorer is open
6 u* d. [) r- b ;$ R. R S% b# t& T/ U; H( l
#IfWinActive ahk_class ExploreWClass|CabinetWClass
8 ^( L5 w* e: Q+ P* {' c% F ; open ‘cmd’ in the current directory
; ]/ s( H! D; M% ^' {) Q ;% A9 H6 W7 l+ F; i5 z4 t
#c::
/ C' A6 O p+ t6 o OpenCmdInCurrent()
: ], w W& `& J9 }8 Z% i1 ?1 b return
& K$ d- }$ [/ d& A3 u3 a+ A #IfWinActive
7 w' B6 l9 q9 f- W$ u6 a* b- ?3 W ; Opens the command shell ‘cmd’ in the directory browsed in Explorer." {* l- X' y0 b1 x- y0 ]
; Note: expecting to be run when the active window is Explorer.
$ X' z5 ` C. \8 ^/ o: P! U ;
& f' d% L+ L* a* U- B/ _+ g/ L1 m Y4 F OpenCmdInCurrent()3 ~6 @+ Z8 I( D7 E/ |
{
9 R% v! a6 b6 d ; This is required to get the full path of the file from the address bar
8 d G5 j& D) W WinGetText, full_path, A
! C _+ K* A+ _3 D ; Split on newline (`n)# u, G# X1 y$ L* V' w3 {
StringSplit, word_array, full_path, `n# { d* O0 l0 f- ^$ E
; Take the first element from the array
" J! H$ i) v2 s# s7 k full_path = %word_array1%! `8 n- J3 j' {. L' V* t1 {: f% H
; strip to bare address
" m0 H6 a/ O! e6 F full_path := RegExReplace(full_path, “地址: “, “”)
" t0 Y# i: n& M- G ; Just in case – remove all carriage returns (`r)
. `" H4 w8 F: I f+ A3 w StringReplace, full_path, full_path, `r, , all
" A: h$ c$ R P7 U. e! q& ^ IfInString full_path, \
+ z2 P; X3 Z" W {$ V& u4 j$ Q! o& \
Run, cmd /K cd /D “%full_path%”4 V) c% e; j" c" k5 H- Y
}# h4 y$ o% R3 }4 `% l5 `
else: x/ P3 M6 [% P
{
6 ~ W9 ~/ [0 f7 ?1 g1 j! F* O Run, cmd /K cd /D “C:\ ”9 d" m+ {! R/ |( I1 b6 _
}
( V7 }5 Y' X! h- ]$ I1 A5 T4 P! g }9 ~/ W# c( e }, U3 t) N
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
3 k0 t) g; O& l, X: v7 L- O2 _1 S 这段小代码肯能有两个你需要修改的地方; A! Z' I; V! |) x( N( v4 ]
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
) b e) Y+ p6 [: o9 W6 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “4 T5 |/ \. |. w3 Q
|