Jump to content
The simFlight Network Forums
Sign in to follow this  

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

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • 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.