local MAX_HEIGHT = 800
local mq = require('mq')
local idw_history = {}
function resize_wnd(wnd)
local x = wnd.X()
local y = wnd.Y()
local width = wnd.Width()
local height = wnd.Height()
local item_desc = wnd.Child('IDW_ItemDescription')
local vscroll = item_desc.VScrollMax()
local new_height = math.min(height + vscroll, MAX_HEIGHT)
wnd.Move(x, y, width, new_height)
end
function poll()
for i=1,6 do
local wnd = mq.TLO.DisplayItem(i).Window
if wnd() == nil or not wnd.Open() then
idw_history[i] = nil
goto continue
end
local wnd_name = wnd.Text()
if idw_history[i] == wnd_name then
goto continue
end
idw_history[i] = wnd_name
resize_wnd(wnd)
::continue::
end
end
while true do
mq.delay(100)
poll()
end