此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 d- P, G5 Q5 p" g8 h6 w6 M+ W 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。9 m9 _8 O ^) S% D5 r
方式一:8 q; O* L E/ h& I$ |; G
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
# C! L4 I8 U4 K 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
( X/ n& C- h* [) _ HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ H$ ` e- P' Z1 ~1 a& _# m 方式二:& C) x) u2 i# a' M! e( p; x
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 S. {9 D* C# M
SetTitleMatchMode RegEx5 X3 I4 Y. @$ N6 V. p, h- C
return$ U/ u3 b8 V: x4 j
; Stuff to do when Windows Explorer is open4 _8 }8 n8 \4 Q
;2 N' `9 a; o8 t. Z2 e5 }% L
#IfWinActive ahk_class ExploreWClass|CabinetWClass$ ?2 ?; _+ C. T# x6 o
; open ‘cmd’ in the current directory
& B5 j+ W! l" U8 _ ;$ Y, e5 p$ ^/ I7 O9 n. K8 f
#c::* x0 X; O& [6 P. g3 {& C
OpenCmdInCurrent()2 h) H9 U, l- V$ o
return
% P* ^" `0 @7 Q9 w! ?# y #IfWinActive
! e9 {/ d- E( e4 q3 {; J ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
, R, u- }6 N! t& W ; Note: expecting to be run when the active window is Explorer.
3 `9 g7 {! P# L/ V' w ;
7 |: C4 n. y$ p( q OpenCmdInCurrent()# x% O$ ?9 g/ y9 T4 j) w$ p( s
{& i7 H+ j5 e7 E; L
; This is required to get the full path of the file from the address bar
O3 Y, l- A" G. x5 R WinGetText, full_path, A
' s2 J- e( ~1 | ; Split on newline (`n)+ n7 e. _* x/ X. C" e# U
StringSplit, word_array, full_path, `n
& D2 T4 n* C- D# M ; Take the first element from the array" `/ i* a: T- ~
full_path = %word_array1%
' }! S B5 x# t! R$ F ; strip to bare address! D0 p1 a! z- y* e2 w ~
full_path := RegExReplace(full_path, “地址: “, “”)6 Z0 d$ }$ P7 j# e4 T9 S" X
; Just in case – remove all carriage returns (`r)% N. `1 k; u2 Y8 ^9 K
StringReplace, full_path, full_path, `r, , all
% I, _* f: O) v& j$ ] IfInString full_path, \4 `+ y8 `8 T+ C W, y, F. d
{+ @- i, \5 k' A, O( ?8 {1 z
Run, cmd /K cd /D “%full_path%”8 _/ ^& l( t5 H3 V
}% H l$ D8 F1 \2 Z8 F1 h! K
else
% v' I% L7 d" C8 T {
A/ t J2 c+ s Run, cmd /K cd /D “C:\ ”
" d, d% d* M/ D$ t/ ` }1 a7 V1 {! l8 K
}; Q; A9 r/ v- ~. p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。8 M2 @9 c' y4 q$ J3 `% u
这段小代码肯能有两个你需要修改的地方, A! g. Z/ ^9 W0 S6 u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键3 E6 u- u$ {: p, h' F- D/ i
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ w: k# i# t( W. D
|