I was wanting to press a focused button in Maxscript using standard buttons if possible. I think this would be easily done using a .NET button but I was just curious if it was possible to press the focused button using the standard MaxScript button control.
Here's the code I have which focuses the button but the the button event handler does work even though the button is focused. I assume it's because its a mouse click only event.
try destroyDialog testRol catch()
rollout testRol "testRol" (
button btn_yes "Y̲es" width:120 across:2
button btn_no "N̲o" width:120
on btn_yes pressed do destroyDialog testRol
on btn_no pressed do print "Oh no.."
on testRol open do setFocus btn_yes
)
createDialog testRol 525 45
OK
If you want to press mxs button, use its handle:
on testRol open do UIAccessor.PressButton btn_yes.hWnd[1]
If you want to press the focused button, get its handle and use it the same way:
on testRol open do
(
local user32 = (python.import "ctypes").windll.user32
setFocus btn_yes
UIAccessor.PressButton (user32.GetFocus())
)