Can anyone help with checking a checkbutton via UIAccessor?

Hello Folks,

I really appreciate the time and assistance everyone provides on this forum, and so wanted ask for some help.

I am trying to check a checkButton through maxscript but dont seem to be able to. I can press a normal button, but not a checkButton.

For example:

rollout accessTest "access test"
	button one "press"
	checkbutton two "Check"
	on one pressed do print "One pressed!"
	on two changed state do 
		if state ==true then
		(print "check on")
		else print "check off"
createDialog accessTest


RollOutHandle = (windows.getChildHWND 0 "access test" )[1]   
pressHandle= (windows.getChildHWND RollOutHandle "press") [1]
checkHandle =(windows.getChildHWND RollOutHandle  "Check") [2]
UIAccessor.PressButton pressHandle  -- DOES press 'Press'
UIAccessor.PressButton checkHandle   -- does NOT press 'Check'
UIAccessor.PressButtonbyName checkHandle "Check"  -- only registers an UNcheck....

I have been trying to figure out the windows.sendMessage stuff but without any progress at all. I cant figure out why this doesn't work..

windows.sendMessage presshandle 0x00F5 0 0

Any help would be much appreciated, Thanks all.


Comment viewing options

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

just usetwo.changed true

just use
accessTest.two.changed true

miauu's picture

If you have access to the

If you have access to the code of those scripts, that creates the rollouts, then, I think, is easy to create a script taht check/uncheck the buttons in these rollouts. You need to know the name of the rollouts(not the title) and the name of the checkbuttons(not the text that describes them). Then it is very easy to press buttons, enter text in text fields, checking and unchecking checkbuttons, checkboxes, radiobuttons.

gobbledegook's picture

Thanks, I'll give it a go.

Thanks, I'll give it a go.

gobbledegook's picture

Thats the problem, Im not the

Thats the problem, Im not the creator of the rollouts. They are embedded in the max file I am using, and I didn't want to start messing with code I dont understand, instead I just wanted to replicate how I would use the interface manually and UIaccessor seemed straightforward at first.(Ive got 10 of these rollouts that need unchecking everytime I check one button - so a script seemed like a good idea!).
I guess I may have to figure out a way of accessing the button states via the rollout code rather than the UIAccessor...? Or just lump it and get clicking manually!


miauu's picture

If you are a creator of the

If you are a creator of the rollouts then why you want to use UIAccessor? You can get/set state of each checkbottuon. checkbox, radiobutton in the rollout or subrollouts.

miauu's picture
gobbledegook's picture

Although, I may have spoken

Although, I may have spoken too soon....

It seems it would be far more helpful to be able to set the state of the button to either checked or unchecked, rather than just toggle between. I have a set of rollouts that I want to select which buttons get checked and which dont. I still cant figure out why a windows.sendmessage with 'button checked' doesn't work where as a 'virtual key' press does...?

miauu's picture

( local RollOutHandle =

	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 	

I am sure that there is another way to achieve this. :)

gobbledegook's picture

Brilliant, Thanks Miauu !

Brilliant, Thanks Miauu ! Virtual keys, eh! Thanks for the solution ( or 'a' solution if you think there could be other ways - but this one works for me so Im happy!) Cheers!

Comment viewing options

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