此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。( I7 y: G2 y- E: C
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 L# ~, G# m" d6 \4 O5 Q$ q
方式一:
0 M) [1 w" r& I7 e G 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
6 ^! k9 I( C1 l% b& I1 A 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和* a, v# M" R* o) B# `
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
+ M$ n! j2 f2 E6 _- ^1 k 方式二:
& o% b! V9 o- C( p& r$ v 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
* K. c8 ]/ j) u& a K4 ?1 m5 o: E SetTitleMatchMode RegEx
# v1 A( ~3 _+ g# a return- J" J8 P- {7 f4 @
; Stuff to do when Windows Explorer is open$ v6 `' o( i3 a. W$ p! ~4 ^. N( U; Q
; o$ |, j% K* ^8 M6 c5 s$ Q: ?: f
#IfWinActive ahk_class ExploreWClass|CabinetWClass
0 g: G, o6 O' ^) f ; open ‘cmd’ in the current directory
) u5 P. M8 }, O0 w; y/ I ;
7 `+ U" ~2 _, a( w$ J; ^ #c::
8 q8 B9 \; o/ {, j+ x OpenCmdInCurrent()
- F. m% K2 n$ n9 S& s- D return
& n/ a; n$ C; ]5 ^) S #IfWinActive
! `+ W0 o. ~3 [& ` b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
! m! L2 t# p; b2 E5 N1 C0 d$ Y8 K ; Note: expecting to be run when the active window is Explorer., J6 X; a8 t0 Z2 @5 D' ~; L1 l
;+ e) d2 s- ^; S: Z/ h$ P
OpenCmdInCurrent()$ Z3 }- p4 { g: \4 E# D K p
{
1 a7 K3 o/ ?. n0 [! Q; P ; This is required to get the full path of the file from the address bar0 C2 Q8 S- s/ K. F6 Y' W
WinGetText, full_path, A
7 j' \, k; j/ N" d4 t9 A4 a( L( e7 t ; Split on newline (`n)
r+ g* f: w8 W( H StringSplit, word_array, full_path, `n
G. j5 A! l) [. Y8 _- ^1 \0 [ ; Take the first element from the array& E. e/ y9 U4 n0 u9 Z
full_path = %word_array1%
' `# M- |" v" c4 U ; strip to bare address7 o7 ~$ W& T+ F$ `9 }! |3 R+ Q. p# }
full_path := RegExReplace(full_path, “地址: “, “”)1 o3 C1 j+ O V* {8 ?
; Just in case – remove all carriage returns (`r)$ r- m9 Q- r/ ~* Q# R% J
StringReplace, full_path, full_path, `r, , all
6 e, _5 D. B7 l$ X8 a7 Q7 i0 J f( a IfInString full_path, \) A7 @2 x1 [' @+ B
{; J$ @) T" H! f8 T
Run, cmd /K cd /D “%full_path%”
: F) m1 H/ Y% R$ X. z }5 }2 l, P# S* q3 G
else( ]) h( K) W# m
{
7 T+ @0 K! B6 s/ C Run, cmd /K cd /D “C:\ ”
( g8 s2 G9 L9 f6 t$ J p }" S8 m: t5 O6 d" k3 e/ J% b
}
( s" e- v) l6 z) E 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。* G- s4 J4 V5 D
这段小代码肯能有两个你需要修改的地方
, ~1 s8 c* w; I5 C' U& \ 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 d# c* \, [' @0 C 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 ]: e, i7 R/ O9 p |