i want push button from script

i want push button from script

geme9876
Explorer Explorer
1,108 Views
5 Replies
Message 1 of 6

i want push button from script

geme9876
Explorer
Explorer

i want push that button from script 

but i can't get button's hwnd

 

help

 

button.png

0 Likes
Accepted solutions (1)
1,109 Views
5 Replies
Replies (5)
Message 2 of 6

tagopinath
Enthusiast
Enthusiast

Hello,

 

Try this script

 

maxOps.trajectoryMode = false (true - will set check Motion Paths button)

 

Regards

Gopi.

Message 3 of 6

Swordslayer
Advisor
Advisor
Accepted solution

It's Qt UI so you have to get the container hWnd and use that:

 

QtWidgets = python.import "PySide2.QtWidgets"

setCommandPanelTaskMode #motion
cpHWnd = ((dotNetClass "Autodesk.Max.GlobalInterface").Instance.UtilGetCoreInterface16()).CommandPanelRollup.Hwnd
cpRoot = (windows.getHWndData cpHWnd)[7]
motionHWnd = (windows.getChildrenHWnd cpRoot)[3][1]
motionWidget = QtWidgets.QWidget.find motionHWnd

for w in motionWidget.children() as array
	where w.__class__ == QtWidgets.QPushButton and w.text() == "Parameters" do
		w.click()
Message 4 of 6

geme9876
Explorer
Explorer

thank you for reply !! very helpful

0 Likes
Message 5 of 6

geme9876
Explorer
Explorer

that's what i find.

but I'm  using max 2019 version, there is a some issue when getting hwnd function ( return float value )

So I solved the problem by getting all the QT widgets and iterating them. 

 

thank you!!!

0 Likes
Message 6 of 6

Swordslayer
Advisor
Advisor

Whatever works 🙂 In pre-2018.2 or so CommandPanelRollup.Hwnd was broken anyway (always returned zero) so you had to do a lot of gymnastics to get the right handle (different ways when it's undocked, if you get it by the string you have to cover localized versions etc).  

0 Likes