UI Automation -Invoke:An empty dialog is opened

ZhangHX 1 Reputation point
2020-09-08T05:57:21.817+00:00

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:
23106-normal.jpg

But after clicking the button ("Authentication" button), an empty "Authentication" dialog opened. The empty dialog is as follows:
23098-error.jpg

Why would such phenomenon happen?
Hope to get your help, thanks!

Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,420 questions
{count} votes

2 answers

Sort by: Most helpful
  1. RLWA32 40,286 Reputation points
    2020-09-09T18:04:14.49+00:00

    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

    0 comments No comments

  2. 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.

    0 comments No comments