此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。' M9 B. l4 E5 F8 ~8 m
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。6 W% i/ q, s( Y* g1 k' ^0 t
方式一:
4 w4 w, o8 i1 ` 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
/ a: v' ?5 n- d( ] 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和; r) T6 P' r; {1 N9 `" ~
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。" [+ a- N: |4 N5 ]. L
方式二:4 n. f4 P) n- T2 I! [* _" C
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下: W5 W. _# R3 a" E `8 u; ~
SetTitleMatchMode RegEx
2 e! Y- {& d$ r9 O" B% I+ r return2 Q) y5 ]8 \6 W/ y" r% `8 m/ P
; Stuff to do when Windows Explorer is open5 b$ x# U6 p4 x; \% a! r
;+ }5 r0 [4 m" x
#IfWinActive ahk_class ExploreWClass|CabinetWClass
7 R; i& J3 O# _4 A7 m( D5 | ; open ‘cmd’ in the current directory
7 }5 o7 S' e) B* [6 ~5 b ;
* G$ z* X7 M- o- P5 }9 M% A #c::& k4 o6 u6 V7 V7 N$ J
OpenCmdInCurrent()
+ T+ C+ ]$ e. W' q5 f! p return! s F( W0 y- k M% T- u
#IfWinActive) ]0 l3 r W% s( }, K
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.9 {, a- D3 K5 Q( g4 v7 G* K
; Note: expecting to be run when the active window is Explorer.
5 z. s5 V% u) p6 n3 U ;1 v8 S6 `$ j9 p, y
OpenCmdInCurrent()
5 j9 [5 G( {" }# r {
& a1 d! T: X8 s S3 W ; This is required to get the full path of the file from the address bar
* A. w. J# w) V# P. J WinGetText, full_path, A7 I. e; ^" f3 C
; Split on newline (`n)+ }7 N! `' M! ^2 i/ p% V. j, Y
StringSplit, word_array, full_path, `n' f& }" H9 [, p! Q4 R4 L4 B$ b
; Take the first element from the array
! G# C1 f) P3 @; `# c full_path = %word_array1%8 \% q4 m& H# A# r9 g1 s: e6 _
; strip to bare address3 F1 F! F: {& ~5 [9 w5 C9 c
full_path := RegExReplace(full_path, “地址: “, “”)3 O- l9 _5 h7 H
; Just in case – remove all carriage returns (`r)3 Z; e- l2 K' w g( q6 R4 J0 @4 M
StringReplace, full_path, full_path, `r, , all
& y7 E! {4 E9 u+ h. y+ y IfInString full_path, \; E# `8 Q; B' F5 {
{* v# z% h B- h9 N0 n9 l
Run, cmd /K cd /D “%full_path%”6 ?' ^$ b+ J/ G- F0 _2 H
}
( {2 _ i2 ]& e/ B% }8 Z3 Y else! D6 N2 B x: p: W" P
{
7 R5 |8 K s, ~7 I O3 ` Run, cmd /K cd /D “C:\ ”% u4 o) U2 ]6 A8 v- n
}% u% z' N( i- o
}$ d1 T) J4 S2 l2 l2 _
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
) `4 \6 ]1 m0 P 这段小代码肯能有两个你需要修改的地方
6 K2 m+ H) [) u 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
# w% D& i& ]7 Z% N' q 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “6 Y# \7 e8 G. f/ M0 o% }& S
|