此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 `) R" W0 c7 F1 p 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。 p- K" U4 M. Q0 _: W5 _- Y
方式一:
+ d w* s8 y' ~8 s z( r7 I 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
' x0 M5 L' y4 W: S; G 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和3 V! e9 d( U& y2 {
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
$ X- ^! v s( ]+ u+ X$ G; P! t 方式二:
. v( B0 o0 L$ y' N; a 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
0 f% Z2 c3 `' B+ i6 v8 U SetTitleMatchMode RegEx- B' E7 C: m* n" @3 w
return' D' Q# C B7 J: L4 w
; Stuff to do when Windows Explorer is open) p( }$ G& g5 `0 C$ A* I: z8 D
;
$ i/ z# p+ q6 C4 f) Y #IfWinActive ahk_class ExploreWClass|CabinetWClass; B ?+ n" O% j1 x
; open ‘cmd’ in the current directory
) D6 m4 t6 `' K' e' ^ ;9 \' h/ F+ n1 n" j' G% _
#c::: A! O9 w! ]; M5 Q- M/ a4 z% r
OpenCmdInCurrent()
7 F/ Z: E4 O% R5 { return
Z7 P# J0 H$ F5 A# T #IfWinActive8 V1 r) I) X) j. a+ v; E$ c
; Opens the command shell ‘cmd’ in the directory browsed in Explorer., ~- [9 j" B& y" _) H
; Note: expecting to be run when the active window is Explorer.
( @- t N6 @; s! o1 l# ?) i, l ;
' Q" x( y0 _% O8 T OpenCmdInCurrent()( O+ u2 ?3 @8 F3 k
{% v9 ?* Y5 {6 k O& H! W1 K" e# F
; This is required to get the full path of the file from the address bar" V5 z6 s5 s# _# b0 `: y
WinGetText, full_path, A4 n" A/ x2 c# O7 [9 C0 s6 u
; Split on newline (`n)
. U( U$ i2 {& c; K8 b/ v StringSplit, word_array, full_path, `n
# h2 @+ D0 @; c2 M1 O ; Take the first element from the array
3 a& }' d3 C5 k" H, [$ M+ r8 T full_path = %word_array1%
, O: E( P% m# k0 C l ; strip to bare address- F# N4 _' e/ j* y' `* }5 K9 w/ I, h
full_path := RegExReplace(full_path, “地址: “, “”)% B0 }2 b8 M4 O# R
; Just in case – remove all carriage returns (`r)
\, ~3 s: `3 o8 X" @ StringReplace, full_path, full_path, `r, , all
E/ `1 R0 k' Z! Y IfInString full_path, \
% H- { u/ a- f$ q/ @2 `8 _ {
# D; E& m- G0 d/ r Run, cmd /K cd /D “%full_path%”. |# {: ]1 U5 V( I/ n& R
}/ d @; L" \/ N' R9 `
else& f) l8 Q" X7 U2 w
{2 O/ q& G: C& e1 G% h, N4 r, k' D
Run, cmd /K cd /D “C:\ ”
" l5 m1 y& G$ p6 ^8 R1 @ }; ^1 ]" Z. w- l, L9 s
}9 K( _9 x! S" s6 n$ I8 z* A
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。( L) ^& c( }( O9 {5 F( K8 W8 i
这段小代码肯能有两个你需要修改的地方
( y( Q) A& n/ P8 | 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 S7 g# @5 ?* c* o' i. S
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 m- J2 a8 @- j8 _ y% u% X/ Z
|