InputText focus?

Is there a way to detect if an InputText has focus?

I’m trying to adapt A-Bot to do some other stuff, and one of the things is to filter the Inventory view. Unfortunately, I haven’t been able to tell if I’ve already clicked on the Search box, so it just keeps clicking on it (or maybe I just can’t tell how to get A-Bot to only do an action once).

My task is currently:

class FilterInventory : InventoryTask
{
public string FilterValue;

   IUIElementInputText WindowInventorySearchBox => WindowInventory?.InputText.FirstOrDefault(e => e.Text == "Search");

   public IEnumerable<IBotTask> Component
   {
       get
       {
           if (null == WindowInventorySearchBox || null != WindowInventory.SelectedRightFilterTextBox)
           {
               yield break;
           }
           if (null != WindowInventory.SelectedRightFilterButtonClear)
           {
               yield return new ClickUI { ClickTarget = WindowInventory.SelectedRightFilterButtonClear };
           }
           else if (null != WindowInventorySearchBox)
           {
               yield return new ClickUI { ClickTarget = WindowInventorySearchBox };
           }
           yield return new TypeInUI { Bot = Bot, FilterValue = FilterValue };
       }
   }

}

The problem is that the executed motion never makes it past the ClickUI task and so just continuously clicks on the search box. If a boolean for focus was available, I’d be able to just not execute the click event. Is there anything like that? Or a better way to accomplish this?

Thanks

You can use static parameter or different class for that purpose.
Something like

if (Memorized.TextBoxClicked == false) 
{
   Memorized.TextBoxClicked  = true
   (your code here)
}

And make it false later again