此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
2 q t1 k+ Y5 D. E 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。) C( `" ?" R9 l- X' O- A% a/ e' E
方式一:+ o2 G) F2 N2 s2 ? k0 A+ S3 U6 ~
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表, i d# g1 D9 [
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
' F4 N0 E, y" B! r& v3 | HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。4 F. W! t$ W+ u2 b6 J+ a& k
方式二:
# }+ _/ A# T, z" Z8 {4 g$ V8 T# t 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
4 Z% l U. Q" ^, U' G0 l: Q SetTitleMatchMode RegEx" X$ `' V: h/ F) E& T9 s$ ?: }
return
! O) u! j7 ^( O3 @ ; Stuff to do when Windows Explorer is open# l( J n9 R. N* |- q# h
;
0 Y9 @) K2 V' r #IfWinActive ahk_class ExploreWClass|CabinetWClass
( v5 u/ A4 S3 I' e+ m+ g ; open ‘cmd’ in the current directory' K/ G. o( e p% s& [7 ?
;
# f8 H0 j, \- D #c::( P) v1 N8 U* W0 j
OpenCmdInCurrent()
9 ~/ n3 o$ F4 ]( B5 ` return
; k% d' w3 u. R- i" l% M; O #IfWinActive
- B W" B7 _- P! _) i. X ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
+ \: ?2 r: l% f$ v( Y! m ; Note: expecting to be run when the active window is Explorer.
( Y7 c# K5 [' b, g; Z- l- B ;
& p- m& [- l8 _1 \. O OpenCmdInCurrent()
! D# A* `6 d' d2 U {- n/ q! d# S4 ?! e4 ^1 b" v- r0 R
; This is required to get the full path of the file from the address bar) o# I4 }" g l+ ?
WinGetText, full_path, A
T$ P* A/ M, S- Y; j$ l( {. R ; Split on newline (`n)
. Y d% ?( R# B) k6 R/ c, v1 D StringSplit, word_array, full_path, `n/ M9 D: a; d8 h0 }9 k
; Take the first element from the array
, ^+ Y2 C) M6 A0 z& {7 B$ j full_path = %word_array1%
! q. _4 [& s0 @ ; strip to bare address8 p7 D: T& U2 F( I4 W _4 h5 Y
full_path := RegExReplace(full_path, “地址: “, “”)& N$ C2 d a$ a) o4 j
; Just in case – remove all carriage returns (`r)
3 y5 Z8 q# T* t. \2 ` StringReplace, full_path, full_path, `r, , all
! p# F0 ^7 k# b% ]# p IfInString full_path, \
" M2 \6 c& z; m0 b, U {
8 `3 R5 |1 c2 [% y8 _, A+ B. ? Run, cmd /K cd /D “%full_path%”. M$ O `8 o9 Z4 i# F( l/ g
}
8 \& R! U1 s$ H7 {+ h& k else
3 z' [: R! h/ `' Y {
' `% } g6 a4 K1 b' _5 O Run, cmd /K cd /D “C:\ ”) }/ K+ D1 ]3 C c9 k( q
}
( Y/ O: H% t7 R }* k# f- l/ z7 E: o& |( U
把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。
% E1 V) [0 J; ^, H4 p 这段小代码肯能有两个你需要修改的地方5 y9 Y" O" e% t2 Z& @* B4 S. u- i( A
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
9 o+ F* w# |- @4 x/ D 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
* B' l @) y4 J0 h, ~" K: ^, z |