Creating and deploying plug-ins

A IBM Task Mining Agent plug-in is a C# class which inherits AgentPlugin class available in the TaskMining.Agent.Plugin.dll file. You can find this DLL file in your IBM Task Mining Agent installation directory (for example, C:\Program Files\IBM Task Mining Agent\TaskMining.Agent.Plugin.dll).

Creating a plug-in project

Note:

A IBM Task Mining Agent plug-in project must contain only one plug-in implementation. If multiple plug-ins are needed, create separate projects for each. Maintain a unique connection between the .NET project and the plug-in implementation.

To create a plug-in project, you can use any of the following methods:

  • Use Agent Plugin template available in Visual Studio 2022.
  • Create a net8.0-windows project with TaskMining.Agent.Plugin.dll reference.

An example for a plug-in project is shown in the following code snippet. HintPath specifies the path to the IBM Task Mining Agent installation directory:


    <Project Sdk="Microsoft.NET.Sdk">

        <PropertyGroup>
            <TargetFramework>net8.0-windows</TargetFramework>
        </PropertyGroup>

        <ItemGroup>
            <Reference Include="TaskMining.Agent.Plugin">
                <HintPath>C:\Program Files\IBM Task Mining Agent\TaskMining.Agent.Plugin.dll</HintPath>
            </Reference>
        </ItemGroup>

    </Project>

Creating an entry point

After creating the project, you must create an entry point for the plug-in. This is the class that inherits AgentPlugin class.

Important: You must specify the processNamein the base constructor in AgentPlugin class.

The following code snippet is an example of an entry point for the plug-in:

    using TaskMining.Agent.Plugin;

    namespace TaskMining.Notepad.Plugin
    {
        public class NotepadPlugin : AgentPlugin
        {
            public NotepadPlugin()
                : base("notepad")
            {

            }
        }
    }

The plug-in class is NotepadPlugin and the processName is notepad.

Enhancing hooks and watch properties

By default, IBM Task Mining Agent captures only the following events:

  • Mouse clicks
  • Keyboard buttons and combinations, such as Tab, Return, Ctrl+C and Ctrl+V.

IBM Task Mining Agent plug-ins add four more properties to this list to enhance keyboard hooks. By default, these values are set to false.

The following table shows the four additional properties for keyboard hooks:

Property Description
WatchAltKeys Enable or disable keyboard ALT keys events.
WatchCtrlKeys Enable or disable keyboard Control keys events.
WatchFunctionKeys Enable or disable keyboard Function keys events.
WatchNumberKeys Enable or disable keyboard Number keys events.

Modifying mouse and keyboard event recordings

To intercept any event recorded by the IBM Task Mining Agent, you can use MouseDown or KeyboardDown.

Both of these events have PluginMouseEventArgs and PluginKeyboardEventArgs with properties that let you understand, modify, or cancel the activity recorded:

The following table shows the three properties that you can use to edit the tasks in IBM Task Mining:

Property Description
Titles You can change the Page & URL Titles of events.
Selector You can change theTask name selector of events.
Cancel You can change the value to indicate whether the event should be canceled.

The following plug-in records only keyboard events and cancels the recording of all mouse actions. It also specifies to rename selector to Text editor and to record all the function key events:

    using TaskMining.Agent.Plugin;

    namespace TaskMining.Notepad.Plugin
    {
        public class NotepadPlugin : AgentPlugin
        {
            public NotepadPlugin() 
              : base("Notepad")
            {
                this.WatchFunctionKeys = true;
                this.KeyboardDown += NotepadPlugin_KeyboardDown;
                this.MouseDown += NotepadPlugin_MouseDown;
            }

            private void NotepadPlugin_MouseDown(object sender, PluginMouseEventArgs args)
            {
                args.Cancel = true;
            }

            private void NotepadPlugin_KeyboardDown(object sender, PluginKeyboardEventArgs args)
            {
                if (args.Selector == "Win32[@ClassName=RichEditD2DPT][@Type=document][@Name=Text editor]")
                {
                    args.Selector = "Text editor";
                }
                else
                {
                    args.Cancel = true;
                }
            }
        }
    }

Using AutomationContext

IBM Task Mining Agent records events when users click or press buttons on an element. This element is an AutomationElement and could be found inside PluginMouseEventArgs and PluginKeyboardEventArgs. AgentPlugin also allows to access any AutomationElement present on screen by using AutomationContext.

The following table shows the additional properties for AutomationElement:

Property Description
GetFocusedElement This property sets the currently focused element as an AutomationElement.
GetFromPoint This property creates an AutomationElement from a given point.
GetFromHandle This property creates an AutomationElement from a given windowshandle (HWND).

By using these properties, you can access any element present on the user screen, along with its details such as name, values, and location.

Creating events

You can use CreateActivity to create an event without waiting for MouseDown and KeyboardDown. This allows you to push any future tasks by running CreateActivity. It can be used for activities that are not run directly by the user. For example, an email in Microsoft Outlook can be intercepted and pushed to IBM Task Mining.

You can find more details on this from the code hints available in your IDE, such as Visual Studio IntelliSense.

Next steps