此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。& b; f3 c. M. f
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 G" X G, q/ I, X) | 方式一:
, u! r6 Y4 r! |1 S% A 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,3 m# o( N8 M5 e+ ^2 r* ?6 u
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和! i M0 a! _) E3 {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。8 w; Q6 E% t0 |. N; c( f/ v4 m q
方式二:
8 _1 u6 c' {0 r+ y2 K 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:" f+ `; Y8 D* g, D
SetTitleMatchMode RegEx" ]4 \/ d% Y* L* L
return
1 b# ^/ i# D7 x% E4 `8 j ; Stuff to do when Windows Explorer is open
7 W& z Q% b3 E; w9 e: q3 ~, b* p: c ; }, G5 D% E- J8 V, }; w
#IfWinActive ahk_class ExploreWClass|CabinetWClass) X! |' `" x3 o$ v" h, a, d+ S
; open ‘cmd’ in the current directory
: R/ \% @& ~5 l7 G0 }) M' T ;9 `1 ~% x! {( e5 r
#c::% c! U. _7 |/ x9 Y3 j7 u
OpenCmdInCurrent()
) x/ p6 ^- v8 w9 `4 O: g return
6 j$ e; }6 X6 @" i #IfWinActive# y. r+ w7 J4 h' F: F4 T* u5 F
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.3 O5 k* b/ }& H; ], I
; Note: expecting to be run when the active window is Explorer.
9 {+ t H7 b$ n. Z, ?' M ;
) `" V" s# h7 O+ p9 y! q8 s" \7 ` OpenCmdInCurrent()* u ?# Q6 q6 E1 M! z, T
{
( Z& F) ?) x; P0 K7 P! h" r ; This is required to get the full path of the file from the address bar
$ Q Q) Z$ ]' J& g: v5 ^ WinGetText, full_path, A% b4 x2 S* r* a5 N7 y' X7 M
; Split on newline (`n); d. q: d% M8 U3 w' w* M
StringSplit, word_array, full_path, `n
% ?8 M9 _' q" H8 l/ G ; Take the first element from the array
6 o4 c& s; a4 C% V0 g/ G- I full_path = %word_array1%
$ s, J; `: ^0 r1 G" I ; strip to bare address& l$ @! H1 e4 l" x2 Z; A: ^: A
full_path := RegExReplace(full_path, “地址: “, “”)
9 P/ ]* }3 A. c1 V ; Just in case – remove all carriage returns (`r)8 Z. K* E- }; O- v& v% |) h
StringReplace, full_path, full_path, `r, , all5 }9 j9 _. a+ g( e; T0 q
IfInString full_path, \$ z9 D: Q# D9 k) m" i5 t J
{' n' Z% `- ^- L' r
Run, cmd /K cd /D “%full_path%”
9 L( O) ]+ S$ W% j- Y, ?( t }4 c" i$ n" s/ n
else
. N; e. `7 Q( r$ c9 n {
7 v8 s: a7 B, N9 D Run, cmd /K cd /D “C:\ ”
. t" u/ o! ]% E }2 E( a& P u1 r' ~
}
) r) m. H* c4 l% V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。! @7 G- ^2 |3 E5 K" J
这段小代码肯能有两个你需要修改的地方) f4 L) [; y+ {+ N9 I3 n' Q& x
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
$ v" L" x8 [9 X% B& l J 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “0 G- c) R2 O V% \
|