Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- log = OutputLogMessage
- Sleep_Delay = 1
- function OnEvent(event, arg)
- if event == "PROFILE_ACTIVATED" then
- EnablePrimaryMouseButtonEvents(true)
- elseif event == "MOUSE_BUTTON_PRESSED" and arg == 4 then
- x, y = GetMousePosition()
- save_x, save_y = fn_GridToPixel(x, y)
- log("x = %d, y = %d\n", save_x, save_y)
- elseif event == "MOUSE_BUTTON_PRESSED" and arg == 5 then
- fn_MoveMouseRelative(-1920, -1080) -- forces mouse to corner
- fn_MoveMouseRelative(save_x, save_y) -- moves relative to saved location
- end
- end
- function fn_GridToPixel(x, y)
- local resolution = { x = 1920, y = 1080 }
- local max_grid_val = 65535
- local conv_x, conv_y
- conv_x = x * ((resolution.x-1) / max_grid_val) + 1
- conv_y = y * ((resolution.y-1) / max_grid_val) + 1
- return conv_x, conv_y
- end
- function fn_MoveMouseRelative(x, y)
- local max_inc = 32
- local n
- local sign
- if x >= 0 then
- sign = 1
- else
- sign = -1
- end
- n = math.floor(math.abs(x / max_inc))
- for i = 1, n do
- MoveMouseRelative(max_inc * sign, 0)
- if Sleep_Delay then
- Sleep(Sleep_Delay)
- end
- end
- MoveMouseRelative( (x % max_inc) * sign, 0)
- if y >= 0 then
- sign = 1
- else
- sign = -1
- end
- n = math.floor(math.abs(y / max_inc))
- for i = 1, n do
- MoveMouseRelative(0, max_inc * sign)
- if Sleep_Delay then
- Sleep(Sleep_Delay)
- end
- end
- MoveMouseRelative(0, (y % max_inc) * sign)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement