ui界面使用 DialogMonitorOPS 问题

-- 是类主要是实现对界面上元素的处理。实现效果的处理 
struct  gt_cl_hp_uiName (
    fn help  = (
    
        gt_10000_help = "
            类主要是实现对界面上元素的处理。实现效果的处理 
            
            property::
            
                sorUIname 要抓取的ui 界面的名称 (只要填写一部分就可以了 )
                desUIname 要更改ui 界面的新名称 
            method::    start() 
                    该方法对所有 ui界面名称进行监控处理 
            method::    end ()
                    该方法关闭监控 
                    
                        
            
            
            下面是使用实例
            op = gt_cl_hp_uiname()
            op.sorUIname = 实用工具
            op.desUIname = 0000
            op.start()
            op.end()

            
        "
        return  gt_10000_help 
    ),
    sorUIname = "" ,
    desUIname = "" ,
    fn dmnotification = (
        WindowHandle = DialogMonitorOPS.GetWindowHandle()
        names = (UIAccessor.GetWindowText(WindowHandle) ) as String 
        if   (findString  names  sorUIname  !=  undefined)   then (
            UIAccessor.SetWindowText WindowHandle desUIname     
        )
        WindowName =names
         if (WindowName != undefined) then
            (
                if (findString WindowName "Fgtun") != undefined then
                     (

                            chWindows = UIAccessor.GetChildWindows WindowHandle
                            for h = 1 to chWindows.count do
                            (
                                    if (chWindows[h] != 0) then
                                    (
                                            
                            if ( UIAccessor.GetWindowText chWindows[h] )=="是(&Y)" then  UIAccessor.PressButton  chWindows[h]
                                    )
                            )
                    )
            )
        true --- 最后返回是一个bool 类型数据
    ),
    fn start  = (
        try (
    --    DialogMonitorOPS.Enabled = false    
        DialogMonitorOPS.unRegisterNotification id:#gtneteaseUIname 
                
        DialogMonitorOPS.RegisterNotification dmnotification id:#gtneteaseUIname
        DialogMonitorOPS.Enabled = true
        )catch ()
    ),
    fn end =(
        try (
        DialogMonitorOPS.unRegisterNotification id:#gtneteaseUIname 
        DialogMonitorOPS.Enabled = false
        ) catch ()    
    )
    
)

关于 max 加入的这个自动点击的脚本  我使用很奇怪  有几点

1.如果我使用结构 在别的脚本中引用  脚本中在写一个 DialogMonitorOPS , 引用失效。 估计是自己没设计好

2.有时候 在处理max程序 循环中 不会等待,有问题,如 批量加入包裹,或做别的事情,就错。

要分步骤进行。

这次我的程序是更改 Unwrell2 ( 展uv 一个插件 )  的 窗口标头信息。

需求是 使用脚本批量展开。 但是展开后 ,弹出的窗口  所有的窗口都是同样的标签。

要求在窗口标签 改成 使用了 几层uv 张开的uv对应的object 的名称。

我使用了 DialogMonitorOPS  UIAccessor  但是 循环中发现 只对最后一个窗口处理。 解决办法是叫程序等待 。使用了messagebox 

到这里等待, 在使用 DialogMonitorOPS  UIAccessor 去点击  确定按钮, 就可以了。

解决了脚本处理不等待问题(术语不知道  就这样描述把)