此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。+ T- h V: \& h0 J. Y5 H% Q
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。( x+ N: U# b$ z" X- X$ F" m: u
方式一:7 T7 D- q8 ^8 E( F, i4 t" Z. T
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
o9 g0 _, R8 X0 i0 C+ F& w) _ 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
# n; Q0 ]4 V* N& r$ c: H HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 e% Y; a' H6 R0 ]6 {
方式二:
# [9 I1 P: ~- Z 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
( y3 P* w) o3 b1 [. x4 L SetTitleMatchMode RegEx
, q5 k. r- q) B return
+ H0 R; v, m, l ; Stuff to do when Windows Explorer is open! [; Y# n3 M+ `1 U+ \8 `
;( E# D1 {9 \9 b9 h
#IfWinActive ahk_class ExploreWClass|CabinetWClass
& g# k Y, Q# C6 R% T, | ; open ‘cmd’ in the current directory
# F: d9 e( B( e+ Z# J& x6 d$ c ;+ c2 [% D5 Y7 ^/ g/ x' z+ G- O
#c::
/ H- Z$ M/ S f! z8 l' Y OpenCmdInCurrent()
% Y( d" \- } I/ f! W return. l/ b o' C' u
#IfWinActive/ e7 B m% {0 C5 t0 c1 } S7 f
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
K4 H I# z' B" n+ E Z$ u- U ; Note: expecting to be run when the active window is Explorer.
/ ]( E$ r# Z% l& \3 S ;% r# b* h5 u' s, M! u/ ]- Z
OpenCmdInCurrent()
# h5 v) P' L, L6 l" m/ c' p8 c1 k {
3 i. j8 V/ g! Y9 T ; This is required to get the full path of the file from the address bar
9 g' k; F% J" ~ WinGetText, full_path, A
3 D7 d- y3 J3 J0 ? _ ; Split on newline (`n)+ [( G4 B; C q
StringSplit, word_array, full_path, `n& b r/ V2 V' r. i( r5 M
; Take the first element from the array3 w y7 C3 h) v- }" U8 x/ `. B
full_path = %word_array1%, C \4 X3 c$ N4 t/ t) D
; strip to bare address
& F; L0 s# e: u3 p1 r full_path := RegExReplace(full_path, “地址: “, “”)& ?5 g% Q/ p/ y4 a6 F
; Just in case – remove all carriage returns (`r)/ l% D. ] Z3 c& c6 I/ H
StringReplace, full_path, full_path, `r, , all
( H. {9 r7 l; Q+ ^! [( M IfInString full_path, \! ^$ {, K! P# Q3 g( }# Y# ]1 W
{$ ]) X" l: R5 c8 j5 N0 C
Run, cmd /K cd /D “%full_path%”& h1 g% l6 s7 w$ n8 O6 h! T
}
3 t3 m9 S4 B6 _4 n" ]6 f+ r else/ w0 v$ Q3 q$ e# V( E) _
{$ E# _4 _; H* \, y' v! i0 q2 @
Run, cmd /K cd /D “C:\ ”; ~2 [5 g# g$ k# ?( Q9 i3 d
}8 D% h& C4 p2 [! @
}
& k/ U6 d+ _* n0 e! _" ]: Z 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
2 @# I8 V' ~) n) j; P8 F1 o ^ 这段小代码肯能有两个你需要修改的地方
- u% O9 j; V& i# T 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
. Y7 \" k/ m# ?3 H0 N3 z3 k2 r 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
) a, ?8 P1 ?& ?) y |