此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。) `- h& V' q) f0 [' T
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
- b# B ?* ~, ~$ ~ 方式一:2 Z/ v: ` ~* z% w7 R2 s5 d& _" L8 b
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 O# f/ e$ {7 O5 S( S; Z# S) T" Q 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和+ X. D8 U, J' n, Z
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。0 @6 E+ ^) C5 N; o. ~8 i% M
方式二:
4 v$ `0 M% H+ ?9 Z) X 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:9 u; O2 ?. D d6 [2 I, V! _% L) o
SetTitleMatchMode RegEx% z3 E* ?2 a% p4 d
return5 [3 [9 P- K6 o, v7 m
; Stuff to do when Windows Explorer is open" g* U2 x5 ?- O2 Y' l
;
7 \' C3 ?* b, N k' i #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 r% V( v# k, A/ S9 ^ ; open ‘cmd’ in the current directory" Y- t- X' f" a: V6 f' v
;
" W; K4 A5 {/ f$ g- e #c::5 }5 ^, X7 Q9 i( o" }
OpenCmdInCurrent()& r( j& L( |! s6 j( N2 d4 T( W
return
3 H& }" S' V8 [7 r- \/ s# J& j( m #IfWinActive
$ ^0 U" g6 X- U4 s2 X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 q* I6 r( O* G$ k7 `* w- W- V0 i
; Note: expecting to be run when the active window is Explorer.* t1 l$ U, a! f& p# c1 B1 K2 N! F1 N
;+ t* \) V& v# j, |: H
OpenCmdInCurrent()' Z8 C% n: v0 \
{
' V9 K, O d1 N Y1 S" \. V( t ; This is required to get the full path of the file from the address bar i G, {3 M& z) b9 G3 I3 r+ D
WinGetText, full_path, A
' Z, d5 v; u5 o4 U" u ; Split on newline (`n)0 j$ P) r. {3 k! z' x2 _% b1 H
StringSplit, word_array, full_path, `n0 f; q. D' `0 P2 i
; Take the first element from the array
2 a/ D9 |, L: M, h full_path = %word_array1%
, D; U$ e2 p2 z; R ; strip to bare address$ k. j0 {$ H2 }" s% {. l+ s$ `
full_path := RegExReplace(full_path, “地址: “, “”) |: S# v' d% L2 f$ G
; Just in case – remove all carriage returns (`r). V7 j8 [" x+ | b( Z0 y
StringReplace, full_path, full_path, `r, , all
. J# S. k- F9 L8 t0 b4 M, A IfInString full_path, \
0 f; V. ?' D4 H1 h0 r+ i6 K { ]) f0 _) O0 _) e2 |
Run, cmd /K cd /D “%full_path%”) D# H' A3 u X* B( W
}
1 n \5 ]( u, e. @- j else8 W5 W2 z* s) s* s, i- Y
{
" | k, ~) V2 h+ L: [; v; W Run, cmd /K cd /D “C:\ ”
9 R. J7 v7 L9 N+ \6 L; V/ ] }
' Z1 X) x9 S" f- f4 R! O% M5 R. o }
# ^5 o7 `, {8 b5 D% I- d1 n 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。# n; R9 o; g& Z" M
这段小代码肯能有两个你需要修改的地方) B, v- C9 g; e9 R* m- g2 U! Q
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 W; M* R& Y( S7 `( \
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “& R+ @2 N3 _0 X* z
|