此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。8 t; Y0 _- G8 B5 f, h, y
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。- _9 }; \2 Z& l. a6 F, V( X
方式一:
* v- \# @8 o4 K& D% y 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
0 @; l; Z$ o/ D3 ` 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和, p# w3 [. B( V
HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。/ |0 D, {4 K% O- q5 [
方式二:3 e! b0 p, Y+ H
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
) M" E2 l. w6 e SetTitleMatchMode RegEx7 c4 A' P6 B' _
return( Y* y& W4 D' C7 @( B
; Stuff to do when Windows Explorer is open
' R* `" [' J; W% M n6 \8 d3 @" Q ;
, O( w$ t* s1 z #IfWinActive ahk_class ExploreWClass|CabinetWClass& ~, {9 S" |; h
; open ‘cmd’ in the current directory+ q: G* Y8 U( o3 D2 D/ s# _- b
;
" R8 V7 J/ M+ o2 W8 w% G- J #c::6 F8 D S ~1 _, P+ E1 z( j, Z w
OpenCmdInCurrent()* b* m- G( b7 }1 d0 x
return
% h; c) i! b" k6 v' V4 a m #IfWinActive# f) {$ x$ d& a% x$ O) W
; Opens the command shell ‘cmd’ in the directory browsed in Explorer.0 Y0 j+ O; W8 l; A7 Q- v4 R
; Note: expecting to be run when the active window is Explorer.
; U. [0 m h G% C6 I ;( l) X* S" h5 C6 M5 v
OpenCmdInCurrent()
# E6 c5 O% {+ y A {
+ B9 Q4 M1 s: r3 F. U8 R, x; v( y& }4 o ; This is required to get the full path of the file from the address bar
$ m/ u+ r( S* P WinGetText, full_path, A4 h2 M% @& S4 B; o" _' e
; Split on newline (`n)9 X" P/ ? D' i, J4 Z* b. {4 @* _7 N& Z
StringSplit, word_array, full_path, `n9 J' B( F: h8 Z2 W, z. m, F
; Take the first element from the array2 z; p5 u6 A) t% `1 E( P
full_path = %word_array1%
0 @1 H0 y5 i) Z' S- o7 H ; strip to bare address
2 e, O2 w/ w4 M6 ^% v2 ?$ G d full_path := RegExReplace(full_path, “地址: “, “”)
3 ^* }! B% ^% V! C5 ]$ T0 G) z ; Just in case – remove all carriage returns (`r)% L0 E. {/ q4 Q$ V% B& ~ e* I0 W
StringReplace, full_path, full_path, `r, , all8 N( {# T$ l; s9 x) ~7 z
IfInString full_path, \" s# @" D( Z# G
{4 R( A3 I ~. ~1 }" {: L( w: S* d! j
Run, cmd /K cd /D “%full_path%”9 p7 v7 i7 f+ }8 ^6 ?
}
7 m0 R* P* z, V8 T; \: q7 \ else2 P% ~1 q- a: q' x0 D
{7 |) y7 p5 o. r; v) D
Run, cmd /K cd /D “C:\ ”
: M' e+ g1 i$ G6 f* b/ e/ c }
- c" v9 {/ j; d+ K8 @/ `! l O }3 M, M6 R4 {6 }3 E$ b
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
4 V5 f( S, E' w! H3 R" w. G8 V 这段小代码肯能有两个你需要修改的地方
3 X/ M2 G& B8 L- ?' t) B7 Q! w. \- P 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键0 l# J$ ?) \& }. A+ W- c
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “- N5 H& S4 r% H
|