Skip to main content

Find Window Position by Process Name

Lua Automation IDE

The following program will look for the Lua Automation IDE window and report back the x and y coordinates which are stored in the win variable and then echoed to the console.

Lua

-- The process name which is the executable minus .EXE
local win = ui.GetWindowPosition("LuaAutomation.IDE")

-- 0, 0 could mean 0, 0 or it could mean the window wasn't found.
-- -32000, -32000 means the window as found but is minimized

ui.Log("Lua Automation IDE: x:" .. win.X .. " y:" .. win.Y)

ui.Sleep(1000)
ui.Minimize()
ui.Sleep(100)

win = process.GetWindowPosition("LuaAutomation.IDE")

if win.X == -32000 or win.Y == -32000 then
    ui.Log("Window was minimized at the time of this call.")
end

ui.Sleep(1000)
ui.Activate()

win = process.GetWindowPosition("LuaAutomation.IDE")

if win.X >= 0 or win.Y >= 0 then
    ui.Log("Window was restored at: x:" .. win.X .. " y:" .. win.Y)
end
Last Modified: 07/25/2023