Can't access to "Yes" button with UIAccessor

Can't access to "Yes" button with UIAccessor

andres.hernandezB63FL
Advocate Advocate
1,687 Views
14 Replies
Message 1 of 15

Can't access to "Yes" button with UIAccessor

andres.hernandezB63FL
Advocate
Advocate

Hi!
I'm having a problem with a dialog that comes up in certain situations when using re scale tool from Time Configuration. Since re scale functionality is not accessible directly through MaxScript I had to access to it using UIAccessor. 
I need to click always on "Yes" in this window. I used UIAccessor.PressDefaultButton() and it works, however if the user is working in a different window than 3ds Max (for example, is doing something in windows Explorer) it will do "Enter" in those cases and it can be risky and not expected, that's why I'm digging into a solution to hit only "Yes" button for this window. 

if theDialogName != undefined and matchpattern theDialogName pattern:"*Biped*" then 
(
  UIAccessor.PressButtonByName WindowHandle "Yes"
)

If I print inside this condition theDialogName it returns "Biped" so I know I'm in the correct window. 
And here is the pop up window 

andreshernandezB63FL_0-1689093988466.png

 

 Hope someone can help me with this. Any advice or tip is very appreciated. 
Thanks

0 Likes
Accepted solutions (1)
1,688 Views
14 Replies
Replies (14)
Message 2 of 15

Swordslayer
Advisor
Advisor

Since there's an underline in the Yes button representing a mnemonic key denoted by ampersand, I'd first try pressing "&Yes" button instead of "Yes" button.

0 Likes
Message 3 of 15

andres.hernandezB63FL
Advocate
Advocate

Hi Vojtěch, thank you for taking the time answer. I had my hopes on that but I tried and no, is not pressing the button 😕 
Do you have any other idea that I can try? 

0 Likes
Message 4 of 15

Swordslayer
Advisor
Advisor

And pressing the button by its handle (hwnd)? It's the first child of the dialog (you can make sure by checking the resource ID, it's 6 for this button).

0 Likes
Message 5 of 15

andres.hernandezB63FL
Advocate
Advocate

Thank you Vojtěch.
I have no idea how to do that, are you talking about something like this?:

 

hwnd = windows.getChildHWND 0 WindowHandle
windows.sendMessage hwnd[6] WM_LBUTTONDOWN 0 0

 

This will return:
-- Unable to convert: 530346P to type: String
 I tried iterating over the children of the windowHandle but it returns nothing with this loop:

 

for i in (windows.getChildrenHWND WindowHandle) do print i

 

Thank you for your help, and sorry that I'm completely lost with this

0 Likes
Message 6 of 15

denisT.MaxDoctor
Advisor
Advisor

@andres.hernandezB63FL wrote:

Thank you Vojtěch.
I have no idea how to do that, are you talking about something like this?:

do you use the DialogMonitorOPS?

0 Likes
Message 7 of 15

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

did you try to press the "Yes" button by its standard default ID:

UIAccessor.SendMessageID <HWND> #IDYES

where <HWND> is the dialog's hwnd of course.

 

0 Likes
Message 8 of 15

denisT.MaxDoctor
Advisor
Advisor

@andres.hernandezB63FL wrote:

I'm having a problem with a dialog that comes up in certain situations when using re scale tool from Time Configuration. Since re scale functionality is not accessible directly through MaxScript ...


Actually, that's not true... You can scale the scene time through MXS. What exactly do you want to do? How do you want to scale?

0 Likes
Message 9 of 15

trykle
Contributor
Contributor

This is a QT window `Qt5151QWindowIcon` and you cannot obtain the handle of the button. You may want to send an `Enter` key (Be sure to focus on the `Yes` button).

Message 10 of 15

trykle
Contributor
Contributor

Or use: `SetQuietMode true`

Message 11 of 15

denisT.MaxDoctor
Advisor
Advisor

@trykle wrote:

This is a QT window `Qt5151QWindowIcon` and you cannot obtain the handle of the button. You may want to send an `Enter` key (Be sure to focus on the `Yes` button).


Yes, that's a good point. This "Biped" dialog is a QMessageBox.
Therefore, its buttons must be clicked according to Qt methods. Win32 methods are not suitable for it.

However, it is still possible to capture it using DialogMonitorOPS, and "click" its "Yes" button.

0 Likes
Message 12 of 15

andres.hernandezB63FL
Advocate
Advocate

Hi Denis and trykleqq thank you for your help. 
I tried your solution Denis and it seems to work perfectly. I'm using DialogMonitorOPS
I'm trying to rescale the scene time and I research about accessing to that functionality through MXS but it wasn't possible, are you aware of any other solution for this? I'm interested. 
About what trykleqq suggested, how can you set "focus on" when you are working with UIAccessor? also the `SetQuietMode true` sounds even better, I never tried that before, thank you for the suggestion.
Thanks a lot for your help, I really appreciate it

0 Likes
Message 13 of 15

denisT.MaxDoctor
Advisor
Advisor

@andres.hernandezB63FL wrote:

I'm trying to rescale the scene time and I research about accessing to that functionality through MXS but it wasn't possible, are you aware of any other solution for this? I'm interested. 


the `SetQuietMode true` sounds even better, I never tried that before, thank you for the suggestion.


1.

you can always scale all scene keys by something like:

scaletime objects animationrange 0.75

as well as move all keys anywhere

 

2.
using Quiet Mode was the first thing that came to my mind, but it always uses the #default option for the requested cases. In the case of "negative biped keys", I'm not sure if the "YES" option is always the default, and there is no place or way to change the default to "NO". So I can't consider it safe, as I can't be sure of the current #default option.

  

 

Message 14 of 15

denisT.MaxDoctor
Advisor
Advisor

@denisT.MaxDoctor wrote:

you can always scale all scene keys by something like:

 

scaletime objects animationrange 0.75

 

as well as move all keys anywhere

 

In general, of course, "Re-scale Time" is a much more complex method than scaletime, but for something simple the (movekeys + scaletime) might work.

 

Message 15 of 15

andres.hernandezB63FL
Advocate
Advocate

Thank you Denis, I'll give a try to this because I'm also having some issues with re-scale tool because is not keeping whole frames even with the checkbox active so maybe this could help. 
Thanks a lot! 

0 Likes