此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。4 ` R6 O6 @9 a6 X
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。, p8 L( I3 J) i) U' R& ?
方式一:1 m2 {, o2 T) t! P+ X9 j
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
`8 b8 E2 P" _* ~8 U 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 v \1 E( L; q# ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
4 ]# b; N* j+ n 方式二:
5 t( N- Q6 F* S4 |+ T7 ]4 e5 L9 k 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
% J# O9 @( ?3 \" @# u SetTitleMatchMode RegEx6 _# W: o" }& _
return, ?- K4 J1 Z/ V7 X
; Stuff to do when Windows Explorer is open
7 }" U0 K- R$ U/ k- U/ o ;8 I5 L: B/ ^- X2 R% S
#IfWinActive ahk_class ExploreWClass|CabinetWClass+ X& W' O4 H2 q: w) d* h! a3 B
; open ‘cmd’ in the current directory
' l+ J: P7 P+ ~, D7 T ;
- J3 {2 n. ~: |5 }5 ?1 W #c::
! B/ w0 ^4 g5 N8 y# Y% b! c- x OpenCmdInCurrent()
4 _# x: F# t# w return7 L4 L. Q5 W3 A
#IfWinActive
: h& b5 |2 `1 w; B3 U ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.# O: |& b2 _9 {) Y' m/ r
; Note: expecting to be run when the active window is Explorer.0 x2 @8 G5 w- t3 t3 x7 @ J
;
7 o! |2 y( x# v5 q2 i G: [ OpenCmdInCurrent(). s5 @; I D- x4 m# E2 M7 ^. T
{$ a$ X G1 R3 p& ~
; This is required to get the full path of the file from the address bar6 A5 g g' M: t! c, X1 d
WinGetText, full_path, A
2 h. o) q4 @1 c ; Split on newline (`n)
2 J$ b& J- L0 C& X$ ~% H; ~5 \ StringSplit, word_array, full_path, `n
1 R a, c) m' `. J ; Take the first element from the array& p9 S( m' d+ g+ T, h9 Z: `% p% L
full_path = %word_array1%
: G# h! Q6 C* |1 p _; d* C ; strip to bare address6 t& i" K2 u/ x8 M& h% z9 ?1 n
full_path := RegExReplace(full_path, “地址: “, “”)
6 @* e# N6 g& T& l O4 w ; Just in case – remove all carriage returns (`r)3 t3 \1 _' o1 Q4 D9 j
StringReplace, full_path, full_path, `r, , all6 z3 p% q( h- Z* L8 a6 n( f j
IfInString full_path, \
4 R* f/ A l1 E! s {2 Z V! w y$ [
Run, cmd /K cd /D “%full_path%”) H9 _. i& B4 {& D; [, C
}
{6 `$ Z+ `2 y5 M$ ^ else
: Y& b2 C& A" P& f {# ?$ O1 J; t& |, z9 O4 q% F$ v
Run, cmd /K cd /D “C:\ ”
8 a) F* A/ F% y$ l$ l3 ~ }
1 u$ V- H8 s {0 F" Q$ I }
" r* X5 y" y! I, ?" X+ C5 [ 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( O R$ S% d; ]
这段小代码肯能有两个你需要修改的地方
$ M" _9 K, H) Y7 t, \& R" H" I. j1 _& i 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# ^ _5 L9 G8 W& s* }
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
: d4 u" q" G) } |