此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
; _' ]$ u; `! v& ]+ N. j, g 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。! `8 j' k# G( s, k
方式一:
/ M* w! C/ L% U 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,. V1 i2 Q' u9 _, i/ U' E
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和# \. i2 Z. ]9 `: ]7 n
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
% k- ~8 S C; ~, T8 [+ G$ g 方式二:6 q( `# b: O: @' u- o3 M
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 P1 T1 `3 G9 S: \. d SetTitleMatchMode RegEx
; M! [, A% I0 c% s return7 |- B( [* j: I% v. [
; Stuff to do when Windows Explorer is open9 J! s X& S% K' J# ^
;
: {- S) ` \3 \1 F( W, [ #IfWinActive ahk_class ExploreWClass|CabinetWClass
/ g# g1 A; t6 \. j$ F# V+ @+ _0 S ; open ‘cmd’ in the current directory
- O5 T/ G1 Y/ q8 u; F6 Q ;1 [. v0 F$ h6 ?- |8 P. D
#c::
( a. P' e9 z. ^4 H OpenCmdInCurrent()% R- q8 z. O5 U+ Y9 Z1 l
return
% A5 l) k7 n: Y# ], C5 ~7 w7 K #IfWinActive
) A# A4 {+ f+ A5 `8 Q/ x1 N ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.1 s1 ` f9 g3 l9 V: ?! ^7 z) J8 F
; Note: expecting to be run when the active window is Explorer.
5 V. s' ]7 n2 a" `# }# R1 @ ;$ n$ ^ Y3 C. z0 Z
OpenCmdInCurrent()' a! L# i. E' a9 F% n. ]0 p
{! q# H3 v6 s O& S% P# b9 }$ `9 o
; This is required to get the full path of the file from the address bar u; L9 @1 a. r/ i4 h3 M
WinGetText, full_path, A
* t1 W' D0 k9 v! D ; Split on newline (`n)
' ~2 o$ ~7 ?4 o! B/ |0 n StringSplit, word_array, full_path, `n
$ L/ R) ?; M# Z0 L) Y3 F ; Take the first element from the array
! z1 s4 T+ u/ o X0 j full_path = %word_array1%
. E9 ~( F7 n! u4 n, B9 [0 a s8 ? ; strip to bare address
$ |) Z) K3 B6 \1 W full_path := RegExReplace(full_path, “地址: “, “”)4 G# E5 L$ `2 c4 Y8 J0 W
; Just in case – remove all carriage returns (`r)
5 ]+ t' j' f5 f* g. H1 z) q% K) |# f StringReplace, full_path, full_path, `r, , all
$ b2 ?+ e7 d+ a$ n IfInString full_path, \
7 f) r2 L) h9 { H {& _ Q. o5 j- G) @6 w! B: H3 V4 V
Run, cmd /K cd /D “%full_path%”1 W; e6 t! U {/ b0 S' C, S
}
2 _7 \" i5 b, C* d! M4 q1 `( m0 [. M else
. d+ h' A+ I& u {
6 `/ `6 m& A( M3 {6 L% a* a! Q2 o Run, cmd /K cd /D “C:\ ”
" w( B. u0 _& t( i% Z }; ?2 S# h9 A' ^, F* i
}
- ], o0 X# S: ]3 M- i' X$ O' \$ w( K 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。. i! [9 U/ M, f; F2 w
这段小代码肯能有两个你需要修改的地方( S) r2 h" o. Q: B# ]6 A. u
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键! S" W' m+ V6 R3 |; K h
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- A' ?3 l' @+ ?
|