此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。; e1 C! b& F! \
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
. [3 g3 c/ ^6 z8 r5 y* L# o6 w 方式一:
% H% u) R! C9 {5 H J2 z 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
. n( x, c) Z" u, n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
" a1 r2 y6 ^9 N- z! s HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
2 e* W7 Z( s4 ? 方式二:
# ]" a8 ^& }% h% X" E 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 L) S/ |: Q2 c2 `2 Z4 C9 B6 D
SetTitleMatchMode RegEx
( L# B9 r- ^$ l& w8 T return
. M- {$ E# G' V0 e' `2 h# \& I ; Stuff to do when Windows Explorer is open
; B, {3 L6 {3 ?/ x; U ;
( y$ |2 B, t2 I# H, x" {, d- K' B #IfWinActive ahk_class ExploreWClass|CabinetWClass
* A4 S7 t5 P; W: m& p+ Z# X ; open ‘cmd’ in the current directory
0 ]; u/ t& j+ O" f ;
' ^* i4 I( b5 c* P$ t/ S0 I #c::: @1 B! H2 E% M1 ~$ p2 t
OpenCmdInCurrent()6 u# a% A; H& ^+ p5 g& b
return
6 c, l3 P0 [- l6 H0 x #IfWinActive- A4 H% G6 y% N- A
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
4 l8 T% d/ Y. W& L- H( z ; Note: expecting to be run when the active window is Explorer.
. x; v7 _! v4 [ ;
3 `* @' w2 `7 |4 `- [8 b) X: g3 e OpenCmdInCurrent()3 U1 B' h. t. y
{+ u% ~- J% D. [6 _1 D6 ]$ @- O
; This is required to get the full path of the file from the address bar
5 n& L, s) M, Y6 `' G WinGetText, full_path, A8 }" ]7 z" z8 k; O8 y
; Split on newline (`n)* w9 d- ~4 E: r
StringSplit, word_array, full_path, `n
1 U2 j$ P- n: D* P ; Take the first element from the array
( o; ?, G' @- L" |6 z$ E1 o, P4 | full_path = %word_array1%
9 q7 H9 |. }1 E0 e ; strip to bare address9 C# `* F! b6 e( T8 w$ v
full_path := RegExReplace(full_path, “地址: “, “”)
- a) a/ C9 W3 T: [ ; Just in case – remove all carriage returns (`r)
) H( a. N. j# T$ S% R% P StringReplace, full_path, full_path, `r, , all
# O. ?4 E/ t8 _9 B* f IfInString full_path, \1 G, [0 U, L) w5 J% K1 B! Z9 {
{ x6 a, r. ^) m0 @/ w: ~/ N, h
Run, cmd /K cd /D “%full_path%”6 M+ v' O" J2 w7 X! l2 R3 I! u
}
% J# V0 y* o- `) | else
. O4 S" w( I1 F& _+ ] {6 }$ O) p+ ~; A
Run, cmd /K cd /D “C:\ ”
' ?3 u& t8 Q; T. |) G }! e, u1 n/ i/ y$ A& B
}
: C2 R1 }/ k6 ^: X" L, | 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
# R5 i8 m( A9 N) p4 a6 [ 这段小代码肯能有两个你需要修改的地方7 X+ t3 M" D1 p: U% `8 Y
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- R& L# t- e* d# m6 x, _
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
/ a7 h! u# w9 I- b, g5 a |