此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。
/ S1 V+ N i( ]/ m) n4 a, j1 N 正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
& v/ J5 P) a; {) `, n1 D% F 方式一:
/ N9 r1 d1 ]( v. k2 l 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,& ?* N. X: B& x6 Y$ T: R+ H+ z/ Y
去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
; [, Y7 }/ P/ N/ n HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。
* ~7 T" y( Q4 O5 G! y 方式二:* w: ^ B+ X; W6 y0 U8 w6 x# q) P
用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:1 \8 Z" h& \2 d* T# }+ }8 {
SetTitleMatchMode RegEx
) o' T) T0 L" A0 G, Y/ {" \: Y return
. P9 K3 E5 P5 m& `0 e ; Stuff to do when Windows Explorer is open' v. i2 t+ D, m! j! Q! J& l
;. V! i4 m: P: O
#IfWinActive ahk_class ExploreWClass|CabinetWClass* d9 v& g0 [; R, H! P/ {, V: g9 f/ W7 P
; open ‘cmd’ in the current directory
- ^& K; z4 n. d( c ;" {# s) |' U( i& ^: m' \
#c::+ F& n6 O! O+ e% r4 a% Z7 A# B5 z+ H
OpenCmdInCurrent()" m( @* ^- I# }
return! C( P! e- }/ `$ a1 K" c2 O
#IfWinActive
# e- Q2 s: j y$ O0 p! D4 [( @ ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.4 S6 b5 E* m! ]6 ~4 ?
; Note: expecting to be run when the active window is Explorer.3 w/ e+ S5 ~- x' a& o) D3 w
;
! X2 t6 K# K4 R" i" \& R OpenCmdInCurrent()
* }8 J# y" @; [. z2 X: I {
0 W; x5 [0 B* X" r+ m" E ; This is required to get the full path of the file from the address bar
, ]/ E( v8 O' } WinGetText, full_path, A' [3 ]1 z9 a* S
; Split on newline (`n)5 X1 y q; _6 N* C5 q" _. T0 G
StringSplit, word_array, full_path, `n5 ?6 A4 O) x0 B+ G& Z) H4 n9 d
; Take the first element from the array6 n k- B, o3 v# ]
full_path = %word_array1%
0 a4 m2 O+ f A; h ; strip to bare address, @1 b8 x* f( W# N1 {$ k
full_path := RegExReplace(full_path, “地址: “, “”)
: p+ P4 y2 M( k8 ~& Y; b3 }6 `* u ; Just in case – remove all carriage returns (`r)
3 q# f* n% i: [; @ StringReplace, full_path, full_path, `r, , all
0 N3 t' R5 M; H* Z/ H& C/ C& } IfInString full_path, \
y% @6 t: z" a4 \, ^2 v( z: J {" |% E$ a+ x! k w- E6 p: {$ y
Run, cmd /K cd /D “%full_path%”
1 E; ^7 i+ k$ V! j$ }0 e }, s4 x8 F L o
else, v6 j# m3 R: j5 P
{
* [5 u4 N$ `0 e3 R% B Run, cmd /K cd /D “C:\ ”
% R: }& `) |" f }, a" F+ E; @' w- M- a' ~, {! u' ~) z
}
8 D$ }! Q: ^! P& K3 a) [8 @, V 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。9 p' e: n) r' E$ d& A) M
这段小代码肯能有两个你需要修改的地方
1 n5 J- _1 @, H9 c, u; {% d3 K: Y$ M 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键. Y! b& W9 G5 _# M
2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
- ]; d7 ]$ k) Q \3 j# s |