此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
- U& ~. t4 G* V& l 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。* m& [1 [9 n0 c2 d/ ]7 Q
方式一:9 O! {; _) [* F' r2 @8 S( l
在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表," A- t' B& r$ R4 ~
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
5 C5 @5 v8 j* O4 Q3 N HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。 c, G- Q/ O% i' f4 {
方式二:& Z1 S9 l3 p4 R8 ^7 j. U# u
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:
+ v- U1 g! Y& \ SetTitleMatchMode RegEx
1 s% H% W0 Q5 X6 Z: `* q return
: f4 F+ B+ l5 A ; Stuff to do when Windows Explorer is open- Z4 \9 @7 y+ \" `/ }- e
;! b5 H' J8 N# @) x3 Z- i: N
#IfWinActive ahk_class ExploreWClass|CabinetWClass
4 u: G4 l+ h. u- E8 d1 J3 L- T ; open ‘cmd’ in the current directory3 R) \& l2 G& |
;
+ ]7 N, ~2 l( ^$ K+ W #c::
$ B' J0 Z7 I' o* F% o OpenCmdInCurrent()
5 v x( ?6 V) `- l* S6 N' }+ U return
% z& n A1 x! [! @1 e #IfWinActive
% S! ] h- ?% j' J* a- `! ~$ G ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.6 u) J7 E4 o3 H1 n& `: v/ {
; Note: expecting to be run when the active window is Explorer.7 `% m5 X4 s6 I+ r, i# v
;/ ]* C% N+ _2 Z9 x1 G) b. W
OpenCmdInCurrent()
! s: S5 U/ w/ n {8 a( E2 d/ a( Y# I7 B
; This is required to get the full path of the file from the address bar
2 v4 ^- t9 r6 R3 K3 _" B, K* j* } WinGetText, full_path, A
: ~ [; p- M0 L1 h ; Split on newline (`n)1 k% u. T8 U P: P
StringSplit, word_array, full_path, `n
+ [* ?" s+ N8 Z1 g' ?/ O$ |3 y ; Take the first element from the array. j' E$ A' m8 ~% P v6 x
full_path = %word_array1%
- p& y M- S, r u5 |: S ; strip to bare address; ~1 f, M5 S V
full_path := RegExReplace(full_path, “地址: “, “”)
% S, h4 \4 n# F! N! z ; Just in case – remove all carriage returns (`r)
; H3 U+ z: a# I2 a" T StringReplace, full_path, full_path, `r, , all
) ?3 s3 }8 j/ z, W6 g* ^! o IfInString full_path, \
" |7 B/ ^, q3 R4 i {$ ]" P# |! i! m/ t
Run, cmd /K cd /D “%full_path%”
+ K$ q4 h" z2 {& | }
+ h. O. y1 I- o" v( V else# P0 a3 |8 g9 r5 _
{
6 \6 ^/ T4 {/ f6 E0 ]- g* J Run, cmd /K cd /D “C:\ ”7 E- g9 m5 l0 d6 }4 Q2 h
}
' }) e) V+ Y4 ^ Y& H% O7 v }
- q9 }% v4 g; U7 O! b2 c8 q- i" Z4 ` 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。) {, {8 K8 g8 o+ S" T+ l {! B
这段小代码肯能有两个你需要修改的地方; \ q3 Y1 V/ H1 W
1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键; Q4 O9 P. U, a' K& R' w$ {$ K2 k
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
1 r& J) w2 t A2 ]1 [* H! D3 ? |