此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
1 {( L5 ^! O; r, t7 S5 U 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
1 Q% r7 T, C$ K6 U 方式一:
1 b& ^, A$ I, K) E+ l- ? o 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,6 V7 T/ C o" x8 l+ W9 w& \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
3 |. i( @- R2 C HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" B' l! m6 N1 [. c/ ~
方式二:# w( Q; |6 |9 \5 I
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
# h/ K0 u- x* m SetTitleMatchMode RegEx
' m" p5 U' t" {9 E; i" H6 r8 d return$ t- P: f. s/ {& q2 ~
; Stuff to do when Windows Explorer is open
+ [+ m b" ~* ^ ;
3 _+ S3 K& {# U Z6 e+ N #IfWinActive ahk_class ExploreWClass|CabinetWClass
0 p( M# r8 _& J( A ; open ‘cmd’ in the current directory: f8 Z4 O" |4 n- C; N0 V
;
. A5 V( q' d3 g6 v #c::
' L" g5 ?! j. k1 R OpenCmdInCurrent()
5 l |0 F0 ~* t) n/ l' ?: \. @4 N2 v- w0 ] return4 o. x \0 F4 d
#IfWinActive
- d1 c7 u" t7 t { ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.) D) Y1 j9 j1 D" j6 Q( n& j( k" I
; Note: expecting to be run when the active window is Explorer.
4 M3 k: v9 B3 _5 m5 a1 O ;4 b d4 W' V; z; s
OpenCmdInCurrent()2 N8 C" W( Z/ @ t) ?. v# B* H
{. x7 e8 s8 y4 [6 k, L3 _: a( Y& K
; This is required to get the full path of the file from the address bar( g4 M* H8 e/ z# o3 s: A5 ?
WinGetText, full_path, A8 A. J' | w# h( d8 l" m6 x' t
; Split on newline (`n)8 r" ]# ]# n) m5 {& X' h
StringSplit, word_array, full_path, `n/ `1 P2 @0 B; j0 J0 U9 D
; Take the first element from the array
3 E* F7 e6 a* A) G: u full_path = %word_array1%9 _, e7 l: {# U9 ^1 r- D, I& \
; strip to bare address
2 w+ V+ u; k& @, e+ T full_path := RegExReplace(full_path, “地址: “, “”)/ ]' Y, f* H: s* b2 _" A
; Just in case – remove all carriage returns (`r)
; {' [7 @/ W6 Q$ Y StringReplace, full_path, full_path, `r, , all) ]; S, Z2 o6 K6 l& k! y. m
IfInString full_path, \
2 M7 n' G' M: T' a1 T/ n {
3 L2 d! n% n% E( Y* b: n Run, cmd /K cd /D “%full_path%”
3 J& Q9 L& d8 E4 n- X }/ f, n( i5 p+ _
else& d; V9 i% U# Q H2 G; `; f: e# {5 b1 i
{
" p4 Q1 E! c7 s g% a Run, cmd /K cd /D “C:\ ”
. D6 S v: @. a4 b }
) v' U4 a. z# L$ o7 a }
: L0 `) B7 V. I3 i 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 U4 B) p, g7 p9 Z! [! M 这段小代码肯能有两个你需要修改的地方
: H' F3 G/ T' @. B* j U 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键5 I- q0 j3 V4 j" Y* O$ R/ E) A
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
u; d4 S1 o4 O5 o: N; }# W5 H8 | |