此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。5 g A9 ?. [$ Z! [+ o# h0 w$ W1 E
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
) X. f& O7 Z0 G& K8 W2 k 方式一:
+ E- s1 s/ O2 y* C/ K 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
5 d/ _; k0 g3 g: o$ z8 B; m 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
7 K- |5 C0 F. O2 Y' |$ _# \2 ? HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
) l# ~ s4 |: R9 j) | 方式二:
( {. G2 n% \) W: l/ Q' r. Y 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
. W( Y Q5 K9 y$ N0 V1 s SetTitleMatchMode RegEx" w0 H5 y6 X }: C0 }# G
return
7 T8 O* d: m8 q$ Y+ j& S: d ; Stuff to do when Windows Explorer is open7 S6 x% b# H8 k! T4 N- z
;) W5 _3 z4 r5 E. ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass. |8 V- c3 m9 r( e4 u2 c7 L
; open ‘cmd’ in the current directory
U; d9 m+ f, s8 e6 s ;; P' V- T' C I" j
#c::7 W7 T$ `5 [; b6 L. G% I5 x
OpenCmdInCurrent()
+ Q1 F! n ^/ y k# n3 z return N! ~+ i3 j: A( j
#IfWinActive0 R8 I" Z1 Z& w: A! E$ l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer. v7 A* u8 U0 U
; Note: expecting to be run when the active window is Explorer.- j$ l( l8 b' O+ R" z. X* ~
;
1 {' W, u- L" N W) o OpenCmdInCurrent()
& D" U: N9 C* o {* m( I# x2 z0 ]+ {* g! O7 ?6 `' H
; This is required to get the full path of the file from the address bar
7 }- @# } q' N5 h y7 h WinGetText, full_path, A
% B& n& {2 @5 F% I- v* g ; Split on newline (`n)0 ?: e9 Z) n+ H
StringSplit, word_array, full_path, `n7 m8 [, C5 y, L* a. L D2 [& K
; Take the first element from the array
9 Z- X$ [2 D+ l full_path = %word_array1%+ W3 q4 P& c% s5 j7 Z
; strip to bare address0 t% \+ l, b" c
full_path := RegExReplace(full_path, “地址: “, “”)0 C8 i# {% A6 p9 b8 {
; Just in case – remove all carriage returns (`r)
1 @: P9 K. l* _" y! Z9 p) x StringReplace, full_path, full_path, `r, , all
& R8 q. L: c4 j5 [ IfInString full_path, \
8 j0 z8 g: O! G; ^7 f, K {
0 `& O# l% d; l' Q6 E$ ~ Run, cmd /K cd /D “%full_path%”
( N3 g8 k+ @4 g9 s2 A+ E5 x }
9 q; n. d1 C6 @- L& Q else& X" B6 z& j- O5 q
{+ _( e" j! X! T) ^; b! N
Run, cmd /K cd /D “C:\ ”
' L- w2 l, U! K }6 t0 P+ W( D% t
}; j( |! C# X. ?
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
5 U9 g0 d9 B. b9 [' @ 这段小代码肯能有两个你需要修改的地方
0 E/ w* m5 M0 a 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ f0 k& \4 R. c- ` 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
P2 {% ~: k' A% v( V |