i sometimes work with slate editor maximized and sometimes the render setup dialog becomes behind it
is there a way using maxscript to bring it to front without closing and opening it again ?
i sometimes work with slate editor maximized and sometimes the render setup dialog becomes behind it
is there a way using maxscript to bring it to front without closing and opening it again ?
trickiest part is to get its hwnd
if not tabbedDialogs.isOpen #render then renderSceneDialog.open() else
(
local g = (dotNetClass "Autodesk.Max.GlobalInterface").Instance
local class_id = tabbedDialogs.getDialogID #render
local TAB_DIALOG_RENDER_ID = g.class_id.Create class_id[1] class_id[2]
local render_tabbed_dialog = g.TabDialogManager.GetTabbedDialog TAB_DIALOG_RENDER_ID
windows.sendMessage render_tabbed_dialog.Hwnd 0x112 0xF120 0 -- restore
windows.sendMessage render_tabbed_dialog.Hwnd 0x7 0 0 -- set focus
)
thank you for this code, much faster than mine
for m in windows.getChildrenHWND 0 where matchpattern m[5] pattern:"Render Setup*" and m[6] == windows.getMAXHWND() do ((dotNetObject "MaxCustomControls.Win32API").BringWindowToTop (dotnetObject (dotnetClass "System.intPtr") m[1]))
maybe because of the matchpattern that needs to parse a lot of data, thank you
no, its because of lots of child windows of the desktop and the fact that you donât cache max hwnd and call windows.getMAXHWND() on every iteration . Try to stop the loop after you bring window to the top, it should work faster
btw. your code perhaps wonât work for localized max version like spanish, or chinese sinŃe there wonât be âRender Setupâ phrase in the title
thatâs an old question i havenât solved yet, how can i cache the result of a native function in a variable? if you can point me to the reference iâd ve very happy. i have had this problem quite a few times.
for the matchpattern, i donât like it too but didnât tought about using the global interface, so thank you!
By caching in mxs it usually means to store the value/function in a local variable to minimize mem consumption and also to speed things up.
Did you notice that BringWindowToTop doesnât restore minimized render settings dialog?
local max _hwnd = windows.getMAXHWND()
for m in windows.getChildrenHWND 0 where matchpattern m[5] pattern:"Render Setup*" and m[6] == max_hwnd do ...
and this should work even faster since hwnd equality check is way cheaper than matchpattern
local max _hwnd = windows.getMAXHWND()
for m in windows.getChildrenHWND 0 where m[6] == max_hwnd and matchpattern m[5] pattern:"Render Setup*" do ...
You can find more in maxscript faq âMAXScript FAQ > How To Make It Faster?â in the reference
ok, thatâs what i used to do.
the thing i meant is, let say the function is not windows.getMAXHWND() but something that changes over time.
i cant recall right now the exact situation in which i had this problem but everytime i called the variable it would re-evaluate and update. even if i did a copy of the result it was kind of linked. i know itâs a bit OT, maybe iâll open a new thread as soon as i can remember when i had this problem
this is the real code i used to use
local max_hwnd = windows.getMAXHWND()
local handle = undefined
for m in windows.getChildrenHWND 0 while handle == undefined where m[4] == "Qt5QWindow" and matchpattern m[5] pattern:"Render Setup*" and m[6] == max_hwnd do handle = m[1]
RSetupHwnd = handle
but i didnt remember where i was storing it
so i patched it up quickly for this post