此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
, @2 |8 ^1 s9 \6 i# s" ]3 z 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 F# |! R, a; K3 @+ @" O- U; A 方式一:
& o; |# `/ G9 `# n& @+ D8 W- { 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,( s/ @( b3 X9 Z2 g& k, A! }* d3 B
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和7 N( L2 U8 n: q0 ?0 a# A1 V0 p& B
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。) x5 |. b: N3 i0 r l4 f
方式二:
_! @" B' [- q$ j6 [+ K r' X: V 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:% x7 |: c* o$ S, P! ]
SetTitleMatchMode RegEx; W' i8 z) d/ M! _; W. p% v0 N D
return
3 |% d( s. c8 M; f+ { u3 g, B, V ; Stuff to do when Windows Explorer is open
4 n5 C' ~. d( e! m ;( i& X) c3 I5 n
#IfWinActive ahk_class ExploreWClass|CabinetWClass B' A9 \1 v6 e# H" c/ j4 c1 \
; open ‘cmd’ in the current directory
9 }0 S4 G& m- G, J F0 D ;
. K( V4 D0 Y q/ r* n8 ~8 v! I: M4 A #c::( S' ^+ o& z% A: u) F# [
OpenCmdInCurrent()2 a+ o7 I0 S! S- V
return8 {0 E3 s: E p# i2 j# I8 Z0 ]
#IfWinActive
# {7 a# ]$ n0 n. d+ b: } ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
' ~* d2 e; Z2 v ; Note: expecting to be run when the active window is Explorer.$ i, Q8 j0 S' P: K/ n/ {
;
/ _# j x$ Y9 U: F2 Y1 ^! j OpenCmdInCurrent()' n( P @0 B# v2 a( ~
{
/ m; ^( ^5 S/ J1 h( f" i' |) i( S ; This is required to get the full path of the file from the address bar4 T: Z% }3 j4 `2 `9 \6 l
WinGetText, full_path, A# j( y# c' i. w, U, m! R
; Split on newline (`n)
8 C0 P% X0 M, A6 U. f- Q% q StringSplit, word_array, full_path, `n/ y! |1 Z- `! F8 ^ c. r3 _
; Take the first element from the array+ I/ }. a, o$ _1 q/ }7 S. v
full_path = %word_array1%" U8 M$ p9 I/ I3 @9 d
; strip to bare address
) }7 C0 X9 V2 w6 { full_path := RegExReplace(full_path, “地址: “, “”)
& B5 d1 }+ H( ]- n6 L ; Just in case – remove all carriage returns (`r)
4 z; R D, O( u) E( H9 j: l StringReplace, full_path, full_path, `r, , all
0 \% U! s, \/ u( P U( C' X/ j" u IfInString full_path, \
* o0 g" h0 Q/ g4 D9 ? {: Y- z! A8 ^$ S; _. M1 g
Run, cmd /K cd /D “%full_path%”" C# ]; R. { A8 ?: b L
}) O: V2 b' r5 o
else4 \# D; u9 U5 B4 n
{
$ b7 n; s& K, d1 T: @. _, n5 i* V Run, cmd /K cd /D “C:\ ”8 y0 X" R/ C6 g; Z/ d5 ~# l1 q, L. \
}
B5 A8 J! u: g/ N }) N- Y: d/ _" B0 G- x
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。: v( Y* }# K$ x7 D) B, e- ?
这段小代码肯能有两个你需要修改的地方
, ^( t7 `% ~2 M- X* _) R: v! Y' e 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
1 P$ y" e6 ?2 }2 n- l y* O 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “. k& r/ x# q5 f# _/ N: ], N/ ~
|