[Closed] cant find command panel HWND in max 2018 SP3
Hi everyone,
greetings, i’m a new member here and this is my first post.
i’m writing a maxscript which need command panel HWND.
windows.getChildHWND #max "Command Panel"
string “Command Panel” is correct in max 2016 and 2017 but return undefined in max 2018 (i dont have max 17 & 18). then got a help from a friend, and found that it is “CommandPanelWindow”. but there is a report from user who uses max 2018 SP3 which makes it undefined.
so, anybody here can help me to find the command panel HWND name in max 2018 SP3 ?
hi Denis who tried to reply few days ago
The case is done finally. People in the Corona Forum helped me and the cause was floating command panel, i never thought of making it floats will makes it doesnt belong to max HWND but desktop HWND.
thanks.
you can find my post about Command Panel in 2017+ handle on this forum … it’s off
if you know how to find it just share
Isn’t there also the issue that the floating command panel is identified by its text, which is different in various max localizations?
hi, sorry for late reply.
here is the codes
commandPanelHWND=
( if cui.commandPanelOpen then
( local popUpDialogs= UIAccessor.GetPopupDialogs()
local currentMax= (maxVersion())[1]/1000-2
local WindowText= "Command Panel"
local cmdPanelName= if currentMax>=18 then "CommandPanelWindow" else WindowText
local CmdPanelIsFloat=
( local isFloat= for i in PopUpDialogs where UIAccessor.GetWindowText i == WindowText do exit with true
isFloat==true
)
local intHWND= if CmdPanelIsFloat then 0 else #max
local CommandPanelHWND= windows.getChildHWND intHWND cmdPanelName
if CommandPanelHWND== undefined then CommandPanelHWND= windows.getChildHWND intHWND WindowText --this weird line is needed because in max 18 "CommandPanelWindow" will change to "Command Panel" after we float and dock back the command panel.
CommandPanelHWND[1]
)
)
any suggestion to make it better?
edit: denis i cant find related the thread you mean about Command Panel in 2017+ …
windows.getChildHWND 0 cmdPanelName
This is wrong, don’t do this, if there is more than one max instance open, it will always give you the handle to the first one. You have pop-up dialogs for the current max instance – instead of just checking their captions, return the hwnd if match is found. Also, IIRC for different language versions, you will have to check for different captions.
yes you’re right, i should get it direct from PopupDialogs. thanks!
i’ll revise the code once i have 3dsmax in my hand
hi all, here it is the revised code
( if cui.commandPanelOpen then
( local popUpDialogs= UIAccessor.GetPopupDialogs()
local currentMax= (maxVersion())[1]/1000-2
local WindowText= "Command Panel"
local cmdPanelName= if currentMax>=18 then "CommandPanelWindow" else WindowText
local floatingCmdPanel
( for i in PopUpDialogs where
( UIAccessor.GetWindowText i == WindowText
) while FloatingCmdPanel==undefined do
( floatingCmdPanel= i
)
)
local CommandPanelHWND=
( if floatingCmdPanel != undefined then
( floatingCmdPanel
) else
( local theHWND= windows.getChildHWND #max cmdPanelName
theHWND[1]
)
)
if CommandPanelHWND== undefined then CommandPanelHWND= windows.getChildHWND intHWND WindowText --this weird line is needed because in max 18 "CommandPanelWindow" will change to "Command Panel" when we float and dock back the command panel.
CommandPanelHWND
)
)