Press Radio button with Maxscript in Command Panel

I want to press a radio button in the command panel. Someone asked how to press a checkbox in a 3dsmax menu (I have included the link). I am trying to press a radio button in the Command Panel: Proboolean --> (sub-object Operations) --> (Remove or Copy or Inst). These settings are not exposed in maxscript unfortunately. I tried your solution for the checkbox but it does not seem to work for radio button. Can someone help me?

Link to ScriptSpot Thread: Pressing a Checkbox with maxscript

miauu solution for Checkbox:

local RollOutHandle = (windows.getChildHWND 0 "access test" )[1]
local checkHandle =(windows.getChildHWND RollOutHandle "Check")[1]
local VK_RETURN = 0x000D
local WM_SETFOCUS = 0x007
local WM_CHAR = 0x0102
UIAccessor.sendMessage checkHandle WM_SETFOCUS 0 0
windows.sendMessage checkHandle WM_CHAR VK_RETURN 0
 

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
TsveTan's picture

.Net allowed?

Is allowable to use .Net assembies?

OccultArt's picture

Does anyone have an idea how

Does anyone have an idea how to get this 100% working? I really would like to be able to change the radio buttons somehow: Especially to change from Inst to Remove! Maybe it just isn't possible since Miauu did not get it to work.

Inst to Remove - DOES NOT WORK

(Copy to Inst - DOES NOT WORK)
(Copy to Remove - DOES NOT WORK)

OccultArt's picture

I have mailed Miauu and he

I have mailed Miauu and he mailed me a script. But it does not work all the time. It will change from some radio buttons to others: Could someone think of a solution?

Remove to Inst - WORKS
Inst to Copy - WORKS
Remove to Copy - WORKS
Inst to Remove - DOES NOT WORK
Copy to Inst - DOES NOT WORK
Copy to Remove - DOES NOT WORK

Code from Miauu:

function SetRadiobuttonsState rbName state =
(
	local properRb = false
	local BN_CLICKED = 0 -- clicky message ID
	local BM_SETCHECK = 241 -- checkbutton toggle message ID
	local WM_COMMAND = 273 -- windows command message
	max modify mode
	df = #max
	for child in (windows.getChildrenHWND dF) where child[4] == "#32770" do
	(
		for classN in (windows.getChildrenHWND child[1]) where (classN[4] == "ModifyTask") do
		(
			for btn in (windows.getChildrenHWND classN[1]) do
			(
				if btn[5] == "Extract Selected" do properRb = true
				if properRb == true and (btn[5] == rbName) do
				(
					local parent = UIAccessor.getParentWindow btn[1]
					local id = UIAccessor.getWindowResourceID btn[1]
					windows.sendMessage btn[1] BM_SETCHECK (if state then 1 else 0) 0
					windows.sendMessage parent WM_COMMAND ((bit.shift BN_CLICKED 16) + id) btn[1]
				)
			)
		)
	)
)
 
-- the name of the radiobuttons: -- "Remove", "Copy", "Inst"
rbNamesArr = #("Remove", "Copy", "Inst")
-- first all radiobuttons have to be turned off
for rb in rbNamesArr do SetRadiobuttonsState rb false
-- turn on desired radiobutton
SetRadiobuttonsState "Remove" true
pixamoon's picture

Hmm,

Hmm, good question, It's easy to change other radio boxes like Union, Intersection etc in Parameters by simple UIAccessor.PressButton:

for c in windows.getChildrenHWND #max where c[4] == "Button" and c[5] == "Union" do UIAccessor.PressButton c[1]

or with UIAccessor.SendMessage:

for c in windows.getChildrenHWND #max where c[4] == "Button" and c[5] == "Union" do UIAccessor.SendMessage c[1] 0x007 0 0

But it doesn't want to work with Remove/Copy/Inst... :(
Will try something more tomorrow. But maybe somebody else know the solution ?
cheers,
Pixamoon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.