此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
# j4 n- e- V8 F$ z) q 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。. d# _+ e, Q( M, f
方式一:
" u5 Q% v8 x1 y; B: e+ a* h2 O+ d 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,$ f+ g% G- ~# n( V! g
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
% `. F' s$ q1 F8 H ~0 j$ } HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
8 @9 z& ]* t2 _ 方式二:
- {, L. r- _* L8 k4 s# z, B 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:7 Y3 g/ A, O, z, y
SetTitleMatchMode RegEx
0 ^: v+ Y5 |* r5 {' V return4 s1 u& S n7 R7 H3 o
; Stuff to do when Windows Explorer is open
p4 W+ o" n3 f* e2 y) |: L ;
# i! S9 a( u" K #IfWinActive ahk_class ExploreWClass|CabinetWClass$ U) O: E% {0 r9 J, }
; open ‘cmd’ in the current directory j9 V: H% [+ B6 B
; R# \* ~# {$ Q3 s4 u/ u
#c::. ?9 |; \6 I/ i- y% W
OpenCmdInCurrent()
( l, l& i. S, N" V4 Y return1 g8 h. _# H4 c$ Y! @
#IfWinActive
* }3 g0 o v. u; G2 u: } u ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
. i0 B g% H$ m! ]9 ^2 y i ; Note: expecting to be run when the active window is Explorer.
2 |( c5 ?8 }9 x8 s# E! u ;- G! D: O9 B, j A" }
OpenCmdInCurrent()
- Y& Z: A$ z- U& e. j* ]( F8 k {7 l t1 C3 B _' j
; This is required to get the full path of the file from the address bar0 x8 t3 j S3 W+ x8 Z- p0 r
WinGetText, full_path, A/ ^) L5 v2 j C1 v7 M1 H/ |
; Split on newline (`n)
0 a" v8 R% c1 z/ a( v- ^ StringSplit, word_array, full_path, `n4 i0 Q. z. B/ a: | K* `3 U7 g
; Take the first element from the array! q2 x: Q/ V$ N& g
full_path = %word_array1%4 x! {9 X9 k& s
; strip to bare address
* Q& O6 [9 d$ o+ {* r: d full_path := RegExReplace(full_path, “地址: “, “”)% p$ i N0 p7 V q5 x5 I# l/ W
; Just in case – remove all carriage returns (`r)
# |5 s6 s: P4 d7 Y5 w) x StringReplace, full_path, full_path, `r, , all
- e, U- }1 D2 b4 A& A IfInString full_path, \
" i7 u9 d3 |6 l. r: D X {
4 p l, z- I0 Y Run, cmd /K cd /D “%full_path%”
" e! J( I& ^0 g7 b6 ^ }
( ]4 M& W2 d' a! n$ R else. }) m& b2 _8 N+ C, {) R2 a
{+ I1 T" r' r3 x1 m6 H
Run, cmd /K cd /D “C:\ ”
" j/ A! x% ?! |( b }* v0 O2 ?* r6 o. Z7 M- Y* G
}
/ C; H5 K8 ]* o 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。/ e' b4 |$ s9 ^
这段小代码肯能有两个你需要修改的地方; {2 V& i2 ?9 y2 c$ X- _+ U) p
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键- q' n+ U0 V* s4 w$ v! e2 ?- F
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) X+ M/ R; ~1 E" A2 A |