此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; a, w0 w+ O& l1 H) o* y! t 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
8 q3 U+ V8 z3 L3 N0 `- q! y- a 方式一:' w! D% I+ Y: P6 t9 U
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,+ @0 @: h, \7 d b! d
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和) V3 i. n2 F) [# E q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
, x4 Y) K# o1 l8 h( G$ [ 方式二:% f. M* |6 L3 J/ ^3 e" Y$ ?
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
" j, l0 f- S& [: T" I/ T SetTitleMatchMode RegEx
3 P. _ q# w4 {# D6 w7 o+ u return
4 a9 U# n0 p2 J% J ; Stuff to do when Windows Explorer is open
7 S1 Z5 `( j7 d3 W9 h ;% b9 ~9 e- H8 r, Y* n3 v9 r/ l
#IfWinActive ahk_class ExploreWClass|CabinetWClass8 p, W' A5 U. ?+ \: Y
; open ‘cmd’ in the current directory
; G( I8 W' l1 H: |: I3 o0 v; J ;9 ~5 P9 b% Z; q, O T7 S+ E8 @* O! a" x
#c::
, ]9 F+ @9 R- J! _8 ?9 Y OpenCmdInCurrent()
# z! b8 K% x* }/ Z n return
2 Y; w: w8 J& k$ B, p #IfWinActive
0 ~2 n D I1 ] ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, c% d ^( L$ d8 K9 G6 g ; Note: expecting to be run when the active window is Explorer.3 n! X! v) r# z+ V% @$ }
;
/ a! e+ p* e1 b' U OpenCmdInCurrent()
' i# f" `# s) }2 J4 a' ~. I {) d) X7 h3 F- ? i' r3 W
; This is required to get the full path of the file from the address bar4 j/ i' n3 y: S" U w8 c
WinGetText, full_path, A# I k8 V" |0 B! w' c. J
; Split on newline (`n)
" S# P& `6 B5 _% K2 }% t; ]2 H StringSplit, word_array, full_path, `n
- W2 \" O6 P9 K5 y ; Take the first element from the array
9 m. }5 ^# W% U/ K* P full_path = %word_array1%$ L/ r( k. i3 N) k8 A9 Q
; strip to bare address* f' P: ~' n+ }& H5 K* t
full_path := RegExReplace(full_path, “地址: “, “”)$ g: H w( b& G# d( \
; Just in case – remove all carriage returns (`r)
9 [0 T/ t! S: d. ]$ Z" G8 d StringReplace, full_path, full_path, `r, , all' ^* Q# u) w' M9 `9 j8 U5 g
IfInString full_path, \
: S2 E1 y1 d+ x! A {) U# w# y& s$ V0 h) a4 l. \
Run, cmd /K cd /D “%full_path%”$ f% }; o: d7 m- d7 H
}
' h# t! x1 G% w7 n else' Q: Y9 Z# S: f5 ]& o O/ j+ Q
{
/ |$ T. u* e. m8 S& K8 b& _ M Run, cmd /K cd /D “C:\ ”
6 O% j9 J K- ?# j* j2 j K }
! S# P) N: B* V C }% ~5 X4 u$ S( F, [; U# _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。- w7 j4 x( Q3 U6 O& o. R
这段小代码肯能有两个你需要修改的地方
. M# y8 x2 O7 a: k: Z 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 v5 m r2 D. R1 J3 j! z
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% Q- H0 t7 x8 J. x) L% `
|