Click or drag to resize

swDialogWatcher Class

Allows user to perform UI actions such as button clicks on SOLIDWORKS dialogs.
Inheritance Hierarchy
SystemObject
  BindableBase
    CADSharpTools.SOLIDWORKS.UIAutomationswDialogWatcher

Namespace:  CADSharpTools.SOLIDWORKS.UIAutomation
Assembly:  CADSharpTools.PDM (in CADSharpTools.PDM.dll) Version: 1.4.16.0 (1.4.16)
Syntax
public class swDialogWatcher : BindableBase

The swDialogWatcher type exposes the following members.

Constructors
  NameDescription
Public methodswDialogWatcher
Creates a new instance of the SOLIDWORKS dialog watcher class.
Top
Properties
  NameDescription
Public propertyDialogs
Dialogs to be watched.
Public propertyGenericAction
Action to perform on all dialog if Dialogs is empty or null.
Public propertyIsIdle
Returns whether the dialog watcher class is idle or not. This property implements INotifyPropertyChanged.
Public propertyProcessId
Gets or sets process Id of the affected SOLIDWORKS instance.
Public propertySOLIDWORKSProcess
Gets the affected SOLIDWORKS process.
Top
Methods
  NameDescription
Public methodAddDialog
Adds a new dialog to be watched.
Public methodRemoveDialog
Remove a dialog from the watcher's list of dialogs to watch.
Public methodStart
Starts watching dialogs.
Public methodStop
Stops watching dialogs.
Top
Remarks
UI Automation is only valid for English language versions of SOLIDWORKS.
Examples
Create a console application and run the code below after install CADSharpTools.PDM via Nuget. Attempt to create a new document by going to File > New and the application will automatically click on OK.
using CADSharpTools.SOLIDWORKS;
using System;
using SolidWorks.Interop.sldworks;
namespace CADSharpTools.PDM.Tests
{
    public class Test
    {
        [STAThread]
       static void Main(string[] args)
        {
            var swApp = CADSharpTools.SOLIDWORKS.Singleton.GetApplication(-1, true);
            int processID = swApp.GetProcessID();
            var newDocumentDialog =
                new CADSharpTools.SOLIDWORKS.UIAutomation.swDialog("New SOLIDWORKS Document", null, SOLIDWORKS.UIAutomation.swDialogButtonAction_e.ClickOK, SOLIDWORKS.UIAutomation.swDialogCompareMethod_e.Title);
            var swDialogWatcher = new CADSharpTools.SOLIDWORKS.UIAutomation.swDialogWatcher(processID);
            swDialogWatcher.AddDialog(newDocumentDialog);
            swDialogWatcher.Start();
            // swDialogWatcher.Stop() stops watching.
            Console.ReadLine();
        }
    }
}
See Also