此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
" T4 x' C" m- y5 C4 d4 b) k' ] 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
3 Y+ y' k2 o- v7 S t& ] 方式一:" t: i- _" P% Z- U2 G: |2 x
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
" V' k7 Y7 i1 @" p+ v9 q$ W' T8 B 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
9 |* m; ]4 j; {0 c0 f HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。- X" m- ^3 f+ O1 O
方式二:1 v. B5 F+ ^9 N7 c: p
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:$ v \/ |" J [* N! U/ D2 _- P( g
SetTitleMatchMode RegEx
& A3 [3 ]/ Y1 g6 r" H return8 y4 j$ i# t5 k# j4 n
; Stuff to do when Windows Explorer is open
3 K! r7 ^! Y5 X ;7 V& h7 x- i0 [/ [& s% a
#IfWinActive ahk_class ExploreWClass|CabinetWClass2 h2 ]% C7 ?" A8 P6 L- C
; open ‘cmd’ in the current directory
- q7 W% `( T( i) d1 `+ U ;
: U2 L6 w* u" ] #c::
3 }7 P- p+ V4 W' [/ P OpenCmdInCurrent(): R6 r+ ]3 }! F; C
return T9 S4 e! t: T y
#IfWinActive8 L' P/ b) p) o( ?/ p5 l
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
7 u' z9 X. ?6 {' [! o. f3 z ; Note: expecting to be run when the active window is Explorer.' x1 a, T% w$ H f# [( \3 Z" A
;% c: t7 R1 _8 m7 b* r9 a9 `
OpenCmdInCurrent()# ]/ l% {' F0 F. u( O) L) i4 h( o( ~" I# T
{
. M2 n- ~$ T- Z ; This is required to get the full path of the file from the address bar& x# c8 c {* F, K, V& s4 f4 K* d
WinGetText, full_path, A
: @5 L9 s$ d' x7 V ; Split on newline (`n)
# k. O6 b3 W; t2 Z StringSplit, word_array, full_path, `n
/ Z& b0 ]3 H4 Y% O ; Take the first element from the array
- n1 X1 a0 Q8 k; @ full_path = %word_array1%
5 X8 i, P; w9 {7 ?. i6 y% l ; strip to bare address
0 f8 ?/ Y- S" D2 [ full_path := RegExReplace(full_path, “地址: “, “”)
9 P' H& w7 D; R ; Just in case – remove all carriage returns (`r)0 H. ?& T+ P" n# v
StringReplace, full_path, full_path, `r, , all8 t0 i; `" j& U' b
IfInString full_path, \
& y" X4 K( d. Z! p( `$ r {
9 e. I: J+ t m Run, cmd /K cd /D “%full_path%”* R. `+ \0 ~7 \3 Q
} X1 b3 C* _& d
else3 n, s: x, _5 B
{ d- c5 r' j2 a. J z4 G
Run, cmd /K cd /D “C:\ ”! j4 b' Y. ?+ {/ A7 D& E
}: e! w W8 @0 w! \1 a
}2 s( ^/ ^+ @, p7 _+ f; H# }
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
" a* \9 ~" V. |7 J8 J9 e 这段小代码肯能有两个你需要修改的地方
% y6 }' ?& y1 H* U5 _; w 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键# o: t; `% L! D: J
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “/ J, W+ n0 v* y4 r
|