my code is below
IntPtr hwnd = FindWindow(null, "dingding");
GetWindowThreadProcessId(hwnd, out dingID);
var myapp = FlaUI.Core.Application.Attach(dingID);
var myautomation = new UIA3Automation());
var searchTextBox = dingdingWindow.FindFirstDescendant(cf => cf.ByName("search"))?.AsTextBox();
most time it works well but sometimes when it goes to "var serchTextBox........", the result is null and the hwnd is ok and dingID is ok and searchTextBox is spotted with inspect.exe. I have to relaunch my app, then everything goes fine.
I am just curious about that? Can somebody tell me why and how to modify the code?