[Closed] Customizing Safe Frames with maxscript
Hi Guys,
I wrote a code to turn on the Title Safe and Action Safe frames in “Viewport Configuration”.
Here is the code,
struct setSFStr
(
fn setCheckBoxState hwnd state =
(
local BN_CLICKED =0
local BM_SETCHECK = 241
local WM_COMMAND = 273
local parent = UIAccessor.getParentWindow hwnd
local id = UIAccessor.getWindowResourceID hwnd
windows.sendMessage hwnd BM_SETCHECK (if state then 1 else 0) 0
windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) hwnd
ok
),
--you can use strings: "Title Safe" or "Action Safe"
fn getButtonHwnd hnd cbn:"Action Safe" =
(
for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:cbn do return i[1]
0
),
fn getButtonHwnd1 hnd1 cbn1:"Title Safe" =
(
for i in (windows.getChildrenHWND hnd1) where matchPattern i[5] pattern:cbn1 do return i[1]
0
),
fn getButtonHwnd2 hnd2 cbn2:"Show Safe Frames in Active View" =
(
for i in (windows.getChildrenHWND hnd2) where matchPattern i[5] pattern:cbn2 do return i[1]
0
),
fn sfTurnOn =
(
local hnd = dialogmonitorops.getwindowhandle()
local TCM_SETCURFOCUS = 0x1330
for kidHWND in (UIAccessor.GetChildWindows hnd) where ((UIAccessor.GetWindowClassName kidHWND) == "SysTabControl32") do
( UIAccessor.SendMessage kidHWND TCM_SETCURFOCUS 2 0 )
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) on
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd1 hnd) on
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd2 hnd) on
uiaccessor.pressButtonByName hnd "OK"
true
),
fn setSF state =
(
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
DialogMonitorOPS.enabled = on
DialogMonitorOPS.RegisterNotification (setSFStr.sfTurnOn) id:#useSF
max vptconfig
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
)
)
setSFStr.setSF on
Its working fine.
Now I need to change the “Horizontal” and “Vertical” Percent Reduction Values. They are spinners and I have no idea how to control them.
And also need to change the “Rendering Level” to “Shaded” in Visual Style and Appearance Tab.
Please Assist.
i’ve showed in this forum how to set spinner value by its hwnd. try to search.
Visual Style and Appearance … is it Nitrous?
Thanks denisT, I saw that post earlier today and was trying to get things done from that.
Still no luck, but I’ll keep trying!
Yes, its Nitrous.
I know maxscript but I have no knowledge about dotnet.
Hi denisT,
These spinners doesn’t have anything attached to them. How do we send a message to set custom values?
Just give me a light!
i’ve modified your code and it unlocks Action_Safe’s Horizontal, sets it to 30.0, and locks it back:
struct setSFStr
(
fn setCheckBoxState hwnd state =
(
local BN_CLICKED =0
local BM_SETCHECK = 241
local WM_COMMAND = 273
local parent = UIAccessor.getParentWindow hwnd
local id = UIAccessor.getWindowResourceID hwnd
windows.sendMessage hwnd BM_SETCHECK (if state then 1 else 0) 0
windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) hwnd
ok
),
--you can use strings: "Title Safe" or "Action Safe"
fn getButtonHwnd hnd cbn:"Action Safe" =
(
for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:cbn do return i[1]
0
),
fn getButtonHwnd1 hnd1 cbn1:"Title Safe" =
(
for i in (windows.getChildrenHWND hnd1) where matchPattern i[5] pattern:cbn1 do return i[1]
0
),
fn getButtonHwnd2 hnd2 cbn2:"Show Safe Frames in Active View" =
(
for i in (windows.getChildrenHWND hnd2) where matchPattern i[5] pattern:cbn2 do return i[1]
0
),
fn editValue hwnd val =
(
WM_CHAR = 0x0102
VK_RETURN = 0x000D
uiaccessor.setwindowtext hwnd val
windows.sendMessage hwnd WM_CHAR VK_RETURN 0 -- press ENTER key
),
fn sfTurnOn =
(
local hnd = dialogmonitorops.getwindowhandle()
hwnd0 = setSFStr.getButtonHwnd hnd
for k=1 to 2 do hwnd0 = UIAccessor.GetNextWindow hwnd0
setSFStr.setCheckBoxState hwnd0 off
---format "........ %
" (UIAccessor.GetWindowText hwnd0)
hwnd1 = UIAccessor.GetNextWindow hwnd0
hwnd2 = UIAccessor.GetFirstChildWindow hwnd1
hwnd3 = UIAccessor.GetFirstChildWindow hwnd2
setSFStr.editValue hwnd3 "30.0"
--format ">>>>>>> %
" (UIAccessor.GetWindowText hwnd3)
setSFStr.setCheckBoxState hwnd0 on
local TCM_SETCURFOCUS = 0x1330
for kidHWND in (UIAccessor.GetChildWindows hnd) where ((UIAccessor.GetWindowClassName kidHWND) == "SysTabControl32") do
(
UIAccessor.SendMessage kidHWND TCM_SETCURFOCUS 2 0
)
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) on
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd1 hnd) on
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd2 hnd) on
uiaccessor.pressButtonByName hnd "OK"
true
),
fn setSF state =
(
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
DialogMonitorOPS.enabled = on
DialogMonitorOPS.RegisterNotification (setSFStr.sfTurnOn) id:#useSF
max vptconfig
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
)
)
setSFStr.setSF on
You rock man! :bowdown:
I just commented the line which turns the lock back, since there is no point locking the values again, If we lock, then the values in horizontal and verticle percent reduction gets nullified.
-- setSFStr.setCheckBoxState hwnd0 on
Also we need to execute the code once the focus is on the “safe frames” tab.
So I shifted the code below.
struct setSFStr
(
fn setCheckBoxState hwnd state =
(
local BN_CLICKED =0
local BM_SETCHECK = 241
local WM_COMMAND = 273
local parent = UIAccessor.getParentWindow hwnd
local id = UIAccessor.getWindowResourceID hwnd
windows.sendMessage hwnd BM_SETCHECK (if state then 1 else 0) 0
windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) hwnd
ok
),
fn getButtonHwnd hnd cbn:"Action Safe" =
(
for i in (windows.getChildrenHWND hnd) where matchPattern i[5] pattern:cbn do return i[1]
0
),
fn getButtonHwnd2 hnd2 cbn2:"Show Safe Frames in Active View" =
(
for i in (windows.getChildrenHWND hnd2) where matchPattern i[5] pattern:cbn2 do return i[1]
0
),
fn editValue hwnd val =
(
WM_CHAR = 0x0102
VK_RETURN = 0x000D
uiaccessor.setwindowtext hwnd val
windows.sendMessage hwnd WM_CHAR VK_RETURN 0 -- press ENTER key
),
fn sfTurnOn =
(
local hnd = dialogmonitorops.getwindowhandle()
hwnd0 = setSFStr.getButtonHwnd hnd
local TCM_SETCURFOCUS = 0x1330
for kidHWND in (UIAccessor.GetChildWindows hnd) where ((UIAccessor.GetWindowClassName kidHWND) == "SysTabControl32") do
(
UIAccessor.SendMessage kidHWND TCM_SETCURFOCUS 2 0
)
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd hnd) on
setSFStr.setCheckBoxState (setSFStr.getButtonHwnd2 hnd) on
for k=1 to 2 do hwnd0 = UIAccessor.GetNextWindow hwnd0
setSFStr.setCheckBoxState hwnd0 off
hwnd1 = UIAccessor.GetNextWindow hwnd0
hwnd2 = UIAccessor.GetFirstChildWindow hwnd1
hwnd3 = UIAccessor.GetFirstChildWindow hwnd2
setSFStr.editValue hwnd3 "25.0"
uiaccessor.pressButtonByName hnd "OK"
true
),
fn setSF state =
(
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
DialogMonitorOPS.enabled = on
DialogMonitorOPS.RegisterNotification (setSFStr.sfTurnOn) id:#useSF
max vptconfig
DialogMonitorOPS.unRegisterNotification id:#useSF
DialogMonitorOPS.enabled = off
)
)
setSFStr.setSF on
Thanks again.!!
unfortunately there are many situations in max script development where you have to use a hack.
my point is… i cannot wait when the max fixes all its bugs. so i have to use every dirty solution to make my tool works.