If you are using UI Automation to manipulate your own user interface then you should be aware of the threading issues involved. Refer to Understanding Threading Issues
UI Automation -Invoke:An empty dialog is opened
I have a Windows application(Print Driver).
We use UI Automation to click a button("Authentication" button). After clicking the button, the Windows application will open an "Authentication" dialog, we need to provide the user name and password in the corresponding text boxes, and then click the "OK" button. The normal dialog is as follows:
But after clicking the button ("Authentication" button), an empty "Authentication" dialog opened. The empty dialog is as follows:
Why would such phenomenon happen?
Hope to get your help, thanks!
2 answers
Sort by: Most helpful
-
-
Rita Han - MSFT 2,161 Reputation points
2020-09-28T03:10:04.707+00:00 Hello @@ZhangHX ,
I didn't reproduce this issue also when I use the accessibility insights tool.
But when I use the VB programming language to call the invoke method, there are occasional exceptions. Can you try this way?I invoke the button with Win32 C++ application for 20 times continuously, the display language is Japanese and input method is also Japanese. It works for me without reproducing this issue.
The following is how I invoke the button in Win32 C++ you can refer to. For programming issue related to VB you can ask a question at MSDN forum for VB for more professional support.
winapi-ui
tag focus on Win32 C++ related issue.IUIAutomationElement *pElement; hr = pElementFound->GetElement(i, &pElement); hr = pElement->get_CurrentName(&name); memcpy(controlName, name, sizeof(controlName)); if (!lstrcmp(targetButtonName, controlName)) { IUIAutomationInvokePattern* invoke = NULL; hr = pElement->GetCurrentPatternAs(UIA_InvokePatternId,IID_PPV_ARGS(&invoke)); hr = invoke->Invoke(); // Click the button here. }
Thank you!
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.