Hi!
Just to show you (and possibly other interested people) what I am doing, and to indicate that I'm still interested in ext.hasfocus() :):
To get rid of the hourglass, I'm now using ext.postmessage to do the focus check (which I want to do in lua) and mouse movement (which is already possible in lua).
I'd like to post this to the user contributions subforum when I can completely implement it in lua, because then the following problems will be solved:
- having to enter the window title of the FSX window (which changes when I'm using FSUIPC to monitor offsets)
- requiring an external program to run (and to be compiled beforehand)
- having to adjust the path for ext.run
FSX/Modules/lua/mousemove.lua (called via ipc.runlua('lua\\movemouse') in ipcReady.lua):
-- 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.
mousemove = ext.run('D:\\FSX\\FSX\\Modules\\mousemove\\mousemove.exe',
EXT_HIDE, EXT_FOCUS, EXT_CLOSE)
function mousemove_reset()
mousemove_timeout = 3
end
function mousemove_timer()
x, y = mouse.getpos()
if x ~= mousemove_old_x or y ~= mousemove_old_y then
mousemove_reset()
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
ext.postmessage(mousemove, 0x1001, 0, 0)
end
end
mousemove_old_x = nil
mousemove_old_y = nil
event.mouseleft("mousemove_reset")
event.mousemiddle("mousemove_reset")
event.mouseright("mousemove_reset")
event.mousewheel("mousemove_reset")
event.mousehoriz("mousemove_reset")
event.timer(1000, "mousemove_timer")
FSX/Modules/mousemove/mousemove.ahk (compiled to mousemove.exe):
#NoEnv
#SingleInstance force
Suspend := "Suspend/Resume mousemove"
Menu, tray, NoStandard
Menu, tray, Add, %Suspend%, menuSuspend
Menu, tray, Add, Exit, menuExit
Menu, tray, Default, %Suspend%
Menu, Tray, Click, 1
; autohotkey script to move mouse to upper window edge of FSX window
; receives postmessage 0x1001 to avoid having to execute more than once
; workaround for FSUIPC not yet providing FSX focus information to Lua scripts:
;
mousemove(wParam, lParam, msg, hwnd) {
FS := "Microsoft Flight"
FS := "Monitor IPC"
IfWinActive, %FS%
{
WinGetPos, , , Width, Height, %FS%
MouseMove, Width // 4, 0, 0
}
}
OnMessage(0x1001, "mousemove", 1)
return
menuSuspend:
Pause
return
menuExit:
ExitApp
return