Jump to content
The simFlight Network Forums

mousemove.lua - move mouse to upper window edge of FSX if the mouse is not used


Recommended Posts

-- Copyright 2016 Thomas Arendsen Hein <thomas@jtah.de>
-- Copying and distribution of this file, with or without modification,
-- are permitted in any medium without royalty provided the copyright
-- notice and this notice are preserved.  This file is offered as-is,
-- without any warranty.

-- Move mouse to upper window edge of FSX window mouse is not used.
-- Workaround for a performance issue when the mouse pointer is
-- inside the FSX window.
-- This script requires a registered copy of FSUIPC 4.949f or newer.
-- Install inside the FSUIPC modules directory:
-- 1. save this file as FSX/Modules/lua/mousemove.lua
-- 2. add ipc.runlua('lua\\movemouse') to FSX/Modules/ipcReady.lua

function mousemove_reset()
  mousemove_timeout = 3

function mousemove_timer()
  x, y = mouse.getpos()
  if x ~= mousemove_old_x or y ~= mousemove_old_y then
    mousemove_old_x = x
    mousemove_old_y = y
  elseif mousemove_timeout > 0 then
    mousemove_timeout = mousemove_timeout - 1
  elseif mousemove_timeout == 0 then
    mousemove_timeout = -1
    if ext.hasfocus() then
      mouse.move(25, 0, 2) -- left half of FS top edge

mousemove_old_x = nil
mousemove_old_y = nil
event.timer(1000, "mousemove_timer")

Same file as attachment for your convenience: movemouse.lua.txt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.