hexagon logo

Creating and Controlling Input Dialog with C#

I using C# to interact with PCDLRN.dll. Currently, our programs have a manual alignment at the beginning and then a comment that pauses execution prior to switching to direct computer control mode. What I am trying to do is, after manual alignment when the program is switching to direct computer control, I want to be able to press a button on my web app that clicks OK on the comment prompt that continues the DCC alignment and continues on with the program. I found references to a Comment method that has a "PressOkButton" function but I can't figure out how to use that in tandem with the Application or PartProgram that I have in memory.

Any thoughts on how to approach this via C#?
Parents
  • Update: I figured out how to do this with the built in C# AutomationUI. I don't know if there is a VB equivalent. I am not sure which version I prefer so I listed them both just in case you're a crazy person like me and you like options. Also pay attention to the whitespace in the string "Execution " because it's important.

    Loop Version
                    var windowNames = new string[] { "PC-DMIS CAD++ 2021.1 (release) - Offline", "Execution ", "PC-DMIS Message", "OK" };
    
                    AutomationElement currentLayer = AutomationElement.RootElement;
                    foreach(var windowName in windowNames)
                    {
                        if(currentLayer == null)
                        {
                            throw new NullReferenceException($"Automation Element not found windowName: {windowName}");
                        }
                        var condition = new PropertyCondition(AutomationElement.NameProperty, windowName);
                        currentLayer = currentLayer.FindFirst(TreeScope.Children, condition);
                    }
    
                    var invokePattern = currentLayer.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
    


    Imperative Version
    
                    Condition condition = new PropertyCondition(AutomationElement.NameProperty, "PC-DMIS CAD++ 2021.1 (release) - Offline");
                    AutomationElement pcdWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "Execution ");
                    AutomationElement executionWindow = pcdWindow.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "PC-DMIS Message");
                    AutomationElement pcdMessageWindow = executionWindow.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "OK");
                    AutomationElement okButton = pcdMessageWindow.FindFirst(TreeScope.Children, condition);
    
                    var invokePattern = currentLayer.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
    
Reply
  • Update: I figured out how to do this with the built in C# AutomationUI. I don't know if there is a VB equivalent. I am not sure which version I prefer so I listed them both just in case you're a crazy person like me and you like options. Also pay attention to the whitespace in the string "Execution " because it's important.

    Loop Version
                    var windowNames = new string[] { "PC-DMIS CAD++ 2021.1 (release) - Offline", "Execution ", "PC-DMIS Message", "OK" };
    
                    AutomationElement currentLayer = AutomationElement.RootElement;
                    foreach(var windowName in windowNames)
                    {
                        if(currentLayer == null)
                        {
                            throw new NullReferenceException($"Automation Element not found windowName: {windowName}");
                        }
                        var condition = new PropertyCondition(AutomationElement.NameProperty, windowName);
                        currentLayer = currentLayer.FindFirst(TreeScope.Children, condition);
                    }
    
                    var invokePattern = currentLayer.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
    


    Imperative Version
    
                    Condition condition = new PropertyCondition(AutomationElement.NameProperty, "PC-DMIS CAD++ 2021.1 (release) - Offline");
                    AutomationElement pcdWindow = AutomationElement.RootElement.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "Execution ");
                    AutomationElement executionWindow = pcdWindow.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "PC-DMIS Message");
                    AutomationElement pcdMessageWindow = executionWindow.FindFirst(TreeScope.Children, condition);
    
                    condition = new PropertyCondition(AutomationElement.NameProperty, "OK");
                    AutomationElement okButton = pcdMessageWindow.FindFirst(TreeScope.Children, condition);
    
                    var invokePattern = currentLayer.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
                    invokePattern.Invoke();
    
Children
No Data