Let's say you want to zoom to the center of the viewport as opposed to the current method that zooms to the mouse cursor. This can be achieved by binding a couple keys to scripts in MoI and using AutoHotkey.
In MoI, create the following keyboard shortcuts:
code:
PageDown=script: var scale = 0.20; var vp = moi.ui.getActiveViewport(); if (vp != null) vp.Zoom(1 + scale);
PageUp=script: var scale = 0.20; var vp = moi.ui.getActiveViewport(); if (vp != null) vp.Zoom(1 - scale);
Create the following AutoHotkey script:
code:
#IfWinActive, ahk_class MoiMainWindow
; Zoom to Center
^MButton::
CoordMode, Mouse, Screen
threshold := 20
MouseGetPos, co_x, co_y
while GetKeyState("MButton", "P")
{
MouseGetPos, mouse_x, mouse_y
abs_offset := Abs(co_y - mouse_y)
offset_sign := (co_y - mouse_y < 0) ? -1 : 1
; Zoom events only occur when the magnitude of the offset is at least as
; large as the threshold distance.
if (abs_offset>= threshold)
{
; Determine how many threshold distances fit within the offset.
multiple := abs_offset // threshold
; Mouse moved down.
if (offset_sign = -1)
{
Send {PgUp %multiple%} ; Zoom in.
}
; Mouse moved up.
else
{
Send {PgDn %multiple%} ; Zoom out.
}
; Update the stored y-coordinate.
co_y := mouse_y
}
Sleep 10
}
return
After executing the AutoHotkey script, you may now zoom to the center of the viewport using Ctrl+MMB. You can change the MoI "scale" and AutoHotkey "threshold" variables to adjust the sensitivity and smoothness of zooming.
|