此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
6 ^8 `% T8 J E 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) a' H5 v. l2 y/ ?& c1 P7 P
方式一:
5 D$ H+ B* h6 c0 a+ F 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
; ]9 D; P( J# i; v0 N, ? 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和0 f9 j' h! h. B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。7 P% S7 `0 G$ ?( }4 E1 J1 J" s
方式二:
% ?' x- Y9 K4 a: R 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:3 ^! M& i) h2 p z! Y0 c, O
SetTitleMatchMode RegEx2 k* J# T9 {, U8 i$ j
return" V. U) N" C8 {7 d! x, S0 `. S
; Stuff to do when Windows Explorer is open7 E- H! @, O" M4 D: Q/ C
;" B& L+ D% D# u. z3 c
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& K7 B( W, i2 ^ ; open ‘cmd’ in the current directory: P4 p8 [: S( V$ b) _/ T
;
; M! b d4 q8 M6 j) z& T #c:: ]3 x+ u" A: _2 p9 o7 R1 w' p; k
OpenCmdInCurrent()# a& g5 D: g6 F( m! [1 U: P
return
8 V- r9 d- _+ e2 k #IfWinActive
- D) j- L% K) M ^0 t8 k( l! b ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 e* Y6 E7 v/ C6 A; s ; Note: expecting to be run when the active window is Explorer.
7 F' {: W6 x, v( D7 {3 z2 q& | ;
1 ] L& T' f" i& Z; S# y$ m OpenCmdInCurrent()
1 g, s' t' b( ^3 d- l S& b {
% Q+ v0 r. W' J4 y* M7 I ; This is required to get the full path of the file from the address bar) k: a! s, I# e! S e1 q t
WinGetText, full_path, A
) o" @! w* m1 T) w* E" Q( R; p* m ; Split on newline (`n)) k P9 X, Y' P; X$ u, x
StringSplit, word_array, full_path, `n! p+ h. L/ E v
; Take the first element from the array$ M7 u9 Q1 P7 Y1 H( a1 n
full_path = %word_array1%' Q+ ^1 |" p1 `! W9 K1 S
; strip to bare address3 k9 C1 a& G6 E8 O
full_path := RegExReplace(full_path, “地址: “, “”)
3 Z4 {: P+ `# T. V+ S. e ; Just in case – remove all carriage returns (`r)
; @4 }$ S: y5 v- W; h StringReplace, full_path, full_path, `r, , all. W: l6 X3 \ O3 E! I
IfInString full_path, \, B# l- |5 G4 Y$ q' Y: m$ x. z1 h
{
4 t( Q1 J4 ?3 A6 L Run, cmd /K cd /D “%full_path%”
2 \7 Z- X7 D& [" ]& T }% P# d7 ~4 n, }! O
else
2 U3 ~' H: }/ E {( T6 G3 e0 B! u7 ]# `# u
Run, cmd /K cd /D “C:\ ”
4 I- f0 \* h0 }3 p0 b, U$ a% f }& l# O/ j& L) P- [/ S" y
}
1 @) \* P* X! Q# |! S& S% X% b. c) G 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# h; ~. [+ ?' V2 W4 J' Q 这段小代码肯能有两个你需要修改的地方0 m2 W8 a+ `2 H( x4 ~
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键, g! L( w* n, l$ {/ D" Y
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
3 k9 N2 f! V/ n' _6 ]* @) _% J |