此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. m& @ z& ]4 p9 S/ W0 B. H
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。3 u# }$ W: r7 e8 D) O
方式一:# r, {4 h1 P8 e4 A6 M. u: M& [
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& ]8 |7 C+ q9 o# g( ?
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和5 ?. P( X( m( B0 Z" J/ w+ O5 i
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
" |) o, {* L/ ` Y$ c$ v; @ 方式二:
& \& @4 X% F3 \3 H7 U7 b 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
! q: K ^% h' [* q SetTitleMatchMode RegEx! n4 E) N7 K: W, ]6 ]5 K+ n
return: G9 L) s: O; W& B5 _! q2 q( c
; Stuff to do when Windows Explorer is open; F* L5 i% X8 J3 V1 Z5 J
;' B; s, _8 K: ]% E! m8 m/ ^
#IfWinActive ahk_class ExploreWClass|CabinetWClass) |/ @# Q8 K/ H/ G6 y
; open ‘cmd’ in the current directory
# R" j* l' k% E( u# U' c# k# C% H ;
/ Z( C- Q- U- [! f5 M #c::: k: q- B1 U0 \5 ?" v: i6 H
OpenCmdInCurrent()
( Y4 ?' }1 @: D" ^# b: r return$ J/ X: B% K$ e& |) z
#IfWinActive8 x5 B0 {9 o- \% R3 t
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.; l3 ~% U0 A/ B9 G. N
; Note: expecting to be run when the active window is Explorer.; {# D% K% f( a& f! S+ X
;
+ i: ~5 ^ J, z6 M# H+ Z7 ` OpenCmdInCurrent()
8 z/ ?$ Y: N7 a* }3 v0 K {( ~2 d/ H. W+ B% ^; Q$ K' ]5 o" r
; This is required to get the full path of the file from the address bar
8 Q y% ~2 x5 m" l1 u& x- X/ b: F WinGetText, full_path, A. A/ W0 Q: P0 r" Y7 D* u
; Split on newline (`n)* j( ?+ B' p- }( \% F+ n
StringSplit, word_array, full_path, `n
3 a$ W( i4 b% ` ; Take the first element from the array
5 a% a. h' Z9 U3 r9 y full_path = %word_array1%
! u' d; @. D" U/ j5 f5 ?0 O ; strip to bare address; E4 T: t5 U* D1 x* `* ~
full_path := RegExReplace(full_path, “地址: “, “”)
7 ^& `$ V. H, I; Z6 V- C; F3 k5 c ; Just in case – remove all carriage returns (`r)
1 o: {) G; a4 c9 ` StringReplace, full_path, full_path, `r, , all+ c& @1 B; _0 ^* |! u# i* t! g
IfInString full_path, \ n: x& v! k" G) D* u
{
1 p9 G' r4 W. d/ y# r& Q( P, | Run, cmd /K cd /D “%full_path%”! D/ Z9 P |2 s- S: k
}
. f3 W& w$ H- q* S1 _9 }- R else" v. v; J% I9 T7 t: c+ Y
{
2 R# A# D4 K6 a4 e4 W0 }6 c) ` Run, cmd /K cd /D “C:\ ”
& F- H/ Z) t3 h& L }3 q5 E! |# p$ c
}5 Z/ ?6 b! U% T; i' W4 U) K2 U; p
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
$ O5 m8 f& M* Y4 o8 j 这段小代码肯能有两个你需要修改的地方" x" y' J' i3 g6 N C) f: t4 N2 P
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
% Y% B& B' s1 W- e6 S 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “% Z, R N0 t. [0 K. o
|