此文仅限于对经常需要打开命令行并且感到正常打开命令行方式很浪费时间的人。. `* c* R7 H# X$ q; I
正常情况下我门需要打开CMD, 然后再CD到自己需要的目录, 这对偶尔用用的人倒没什么。 但是经常需要这么些操作就感到浪费了大把时间。 现在提供两种方式让你像在linux中那样更高效的在当前目录打开命令行。
2 @- q6 ^6 e7 P8 D: q 方式一:
( k. W( C$ G+ @* m; _ 在当前目录按Shift+鼠标右键, 你就可以看到类似的在此处打开命令行的选项了, 如果你想去掉shift,直接按鼠标右键就有此选项, 那么你需要用简单的修win7系统改下你的注册表,
3 `: ?) |, s/ n3 a3 n 去注册表位置HKEY_CLASSES_ROOT\Directory\shell\cmd 下面将Extended键值删掉, 如果你还希望驱动器和桌面也能这样, 将HKEY_CLASSES_ROOT\Driver\shell\cmd和
: K8 l4 H. D+ B1 u. x9 u2 a HKEY_CLASSES_ROOT\Directory\Background\shell\cmd 下的Extended键值去掉即可。5 W! ]3 F2 V& J
方式二:
8 E- K& X' I# u- E% |' W 用快捷键,当然会用到人见人爱的Autohotkey. 其Auothotkey代码如下:5 x- I9 p5 E6 M3 {; Z- j
SetTitleMatchMode RegEx1 u4 R: x. b) L# {
return% K1 S, }6 ^ c) |, b8 k! A1 w
; Stuff to do when Windows Explorer is open# X# N7 E9 I/ \' R& V: ]. I
;
6 G4 d( a7 i; S# H #IfWinActive ahk_class ExploreWClass|CabinetWClass
" c" L! W% N+ V# Q6 U ; open ‘cmd’ in the current directory5 h V% i( l7 O
;
4 K6 w# T! f6 R! j& v* O& J/ }& W #c::
$ v& c7 U& b* f1 z5 h5 J OpenCmdInCurrent()) O* D2 J' n4 y, c* F# t
return
. m# M5 j4 t' `% R3 X #IfWinActive
" E, C9 c7 R C8 z6 G% y ; Opens the command shell ‘cmd’ in the directory browsed in Explorer.
% R, H" \5 B+ y) f" }. B ; Note: expecting to be run when the active window is Explorer.
6 @* [% M" y2 H0 r ;) R6 E4 l+ T4 \* o6 [
OpenCmdInCurrent()( @- m1 X. [6 ^ p
{
! C# t9 z( `. I. I& { ; This is required to get the full path of the file from the address bar
4 `3 e( L1 Z* D2 G. L WinGetText, full_path, A
! V' J) d% y2 v2 a \ ; Split on newline (`n)
: U+ @7 t u0 o; X) P; b' d StringSplit, word_array, full_path, `n- ]) e8 b' K K. M) ?1 p2 C
; Take the first element from the array
; B+ D: r/ M! j8 Z V full_path = %word_array1%
* g) i3 |; S* L2 X4 ~- Y" C0 N ; strip to bare address/ s5 u( r& q9 L: V* ?! ]% V4 {
full_path := RegExReplace(full_path, “地址: “, “”)
( X, U# b# U5 }7 O% c# V8 s ; Just in case – remove all carriage returns (`r)
2 ~% }* ?$ u5 K1 P" S0 n StringReplace, full_path, full_path, `r, , all
6 C0 c5 u' T' i; f5 _ IfInString full_path, \- b4 s1 Q, F; \2 C
{
. c9 Z! G) u1 J, @+ h+ C8 l Run, cmd /K cd /D “%full_path%”
y; X" o# C/ e2 x" l- v6 H }, u3 E2 N9 `2 f8 |2 r3 b) l4 r* F2 X
else
' w, r z' i6 k C4 z {) [1 p/ X2 H/ \7 u5 R
Run, cmd /K cd /D “C:\ ”
1 k0 S" ^. v) l; b: H. O }
9 X+ V+ \( c5 N: f }
- x+ j) t% I L$ M& @3 F 把上面代码存为UTF-8编码格式(因为有中文)的ahk格式xp系统之家,用Autohotkey打开,然后按win键+C就可以在当前目录下打开cmd命令行了。" w5 P0 E$ _( s
这段小代码肯能有两个你需要修改的地方
- ^* y3 a. t9 x! ]5 u) {! C 1. #c:: 中的#代表win键, 这个代码中使用的是win键+C, C可以改成你需要的其它键
( E2 l; S- r( { 2. 如果你的系统是英文的,你需要把”地址: ” 改为 “^Address: “
6 p% Y* H+ R) g- g3 _/ x: c |