此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。/ q) J% y$ Q' d* l2 g8 I I% B
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! M1 d; ]7 g) a5 f P$ l
方式一:. W) b! y9 S4 g5 Q+ I: N
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. ^8 ?* H3 m$ \
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和- S0 P; _3 E! _3 V5 G+ u Q
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
5 n1 E) b0 r7 E6 U# c+ f! s 方式二:
9 X( v4 ~6 z/ W0 Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
& x3 D4 E) ? c5 j! g! w SetTitleMatchMode RegEx. r: W0 Z2 O2 Z( B
return+ G* |. N& ~2 B7 Q- F* e0 I
; Stuff to do when Windows Explorer is open* R& e5 d5 r0 {1 D2 G) {6 V
;
4 J ?* U6 T4 D+ |, O #IfWinActive ahk_class ExploreWClass|CabinetWClass$ f% U9 {# d4 o3 C) y! Z5 H1 X) z; k5 i
; open ‘cmd’ in the current directory5 o& J2 i9 ~% y5 I
;% n- k" Y4 w- O% q. t
#c::
# ?) d+ K& B8 x2 Z) Y OpenCmdInCurrent()6 E$ E$ v/ ~+ u* S, A
return
- G5 `; @# a$ i' Z# f& \% y) ~. `6 E V #IfWinActive
( f& A% s1 |" l. s8 b# _ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer., k. K' d! N0 w4 ^2 ^
; Note: expecting to be run when the active window is Explorer.! b# A- s0 _) Y3 l2 e7 Y# c
;
0 ~1 C" ~0 h5 }, m6 s OpenCmdInCurrent()
7 R7 O. {: Z/ p {
6 q: h3 o u f; [6 N3 L& @0 ? ; This is required to get the full path of the file from the address bar
. I) `8 y+ J0 H" J& Z$ s WinGetText, full_path, A
9 P( R9 N! j) t$ ] ; Split on newline (`n)2 p+ c4 F, q. q
StringSplit, word_array, full_path, `n4 d1 l( i7 e U) A T
; Take the first element from the array4 x! M4 e- c' ^9 ~; x
full_path = %word_array1%" p6 F# c* ^( Y
; strip to bare address; m8 b |" G$ u4 {
full_path := RegExReplace(full_path, “地址: “, “”)
: `$ ^, F9 B: ?9 U ; Just in case – remove all carriage returns (`r) P! z. \5 W4 L( ?5 V9 H' n
StringReplace, full_path, full_path, `r, , all
6 L% m; u% e0 P+ c% ] IfInString full_path, \/ s: z4 e0 W- A: C, ]& I
{0 x) D9 U; D# Q+ Q% h7 h
Run, cmd /K cd /D “%full_path%”
5 @5 m2 x" S; c5 k! G, s1 K }
7 B( X# p0 N/ g. ` else! \) E5 N4 Y! x% f1 \2 e0 l4 _3 H
{
" W0 W5 h- }, }! `, M! ^ q Run, cmd /K cd /D “C:\ ”
& R/ ^! O# [2 C% I: \& N }
" W# N% `8 i3 }$ y4 X) {& c }
A0 ~3 l& V2 J g, U9 f( ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。0 E. { m7 ^: i1 j0 R8 Y3 G" U/ U
这段小代码肯能有两个你需要修改的地方
G/ c1 p1 i3 Q8 @& O 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; F8 A. X- Z# O
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
& ^% E6 I" [5 Q# E! x3 g6 m( e |