此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。" V L, _ F- @1 D
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 |+ q4 {& g, I% z! Z
方式一:
- g' F3 g% T0 ~7 v 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
2 r2 i. S6 }! r* @ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和 n5 \8 ]& q/ W0 I; w
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" S1 s) ]4 s8 I- z7 G 方式二:
7 D' ?1 W8 n$ q h% f7 n 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:. z# g: ^; r/ e
SetTitleMatchMode RegEx
$ `" Q, `5 L( y return0 e/ I9 w% l- D/ O( o2 ^4 i
; Stuff to do when Windows Explorer is open8 v1 t! R& M. l
; i7 `4 `* C# x% t D! Q5 I
#IfWinActive ahk_class ExploreWClass|CabinetWClass% R# l7 A: ?. C: E8 c& T& K
; open ‘cmd’ in the current directory
. Y ?" ?. `- T! O' \4 p7 R8 _ ;- L! z2 X: X% t
#c::: ]. H6 A# ], N& G" k
OpenCmdInCurrent()/ V4 ?1 T8 i' p! l. A
return6 S! Z4 a7 M' T b; n
#IfWinActive
/ p0 C1 u' Z' k! Z' l) M! w ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
0 n5 C) T, @2 N& _8 B- m* K+ N ; Note: expecting to be run when the active window is Explorer. S' j5 S! W7 D9 W, l
;
# q) `( h8 j( m& V7 d5 q; Z' H. t OpenCmdInCurrent()4 y. V! b7 M2 l$ v# G
{
+ b+ h2 m8 ?* U& M( b- J5 a& r ; This is required to get the full path of the file from the address bar3 U7 H' M. I& P0 m4 ]. Q4 P( Q
WinGetText, full_path, A9 [ d3 |$ ]4 j) \2 F
; Split on newline (`n)4 g5 P) X W8 e
StringSplit, word_array, full_path, `n
# g& M; I }+ s- D# w, O. n/ n ; Take the first element from the array
/ {) N* N) c' h* b' Z3 x0 K full_path = %word_array1%
( n. W4 C" `8 P& @) f ; strip to bare address% `/ n$ Y8 u$ i+ |% m7 B! S
full_path := RegExReplace(full_path, “地址: “, “”)
- j! y. m/ X( t7 t6 [, @8 D. N- H ; Just in case – remove all carriage returns (`r)% w3 U% S, n5 @/ l6 M3 `" M
StringReplace, full_path, full_path, `r, , all# l2 _: B9 `2 N3 y( B
IfInString full_path, \
- \$ v' ?! E& V: C! U/ z; W {% {; O2 B+ Q. T- H7 e" E* N4 @$ K
Run, cmd /K cd /D “%full_path%”5 y; u$ {. v% u- }( W, h
}# e2 P1 A u' R0 w& _- r
else+ H0 \8 B' ~* S9 u/ Q& [& b7 Z
{7 t" |# o: S" v4 s* X3 [
Run, cmd /K cd /D “C:\ ”: B- ]& [5 Z# d" ^
}
$ T$ T3 O2 `- N. u }7 D6 c& @2 \8 n
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。2 M7 u0 K' S5 j8 M
这段小代码肯能有两个你需要修改的地方
" b0 |, M- L3 Y 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
8 `) N0 m: r' L" b2 w. [ 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “ d1 s! O4 c& \4 ], L8 C& r; G
|