Domanda

I want to open Microsoft Security Essential program and click Scan now button with VC . I can find window but Can't find control. This is my code when I run this code it show Control not found . I try to test this code with click Browse button in Run program it work but when I try to use with Microsoft Security Essential it not found control. I don't know why maybe this control is in Tab . How to use FindWindowEx() click Scan now button in Microsoft Security Essential ?

int run_ms(){   

    ShellExecute(NULL, L"open", L"C:/Program Files/Microsoft Security Client/msseces.exe", NULL, NULL, SW_SHOWNORMAL);

        HWND w;
    w=FindWindow(NULL, L"Microsoft Security Essentials");

        if(w==NULL)
                MessageBox(NULL,L"Not found",L"",MB_OK);

        else{
                HWND cb;
                cb = FindWindowEx(w,NULL,NULL,_T("&Scan now"));     

            if(cb!=NULL)
            {
                SendMessage(cb,WM_LBUTTONDOWN, NULL,NULL);
                SendMessage(cb,WM_LBUTTONUP, NULL,NULL);
            }
            else
                MessageBox(NULL,L"Control not found",L"",MB_OK);
        }

            return 0;
}

I use Spy++ with button in Microsoft Security Essential it show like this

Caption : &Scan now
Class : ALT:BUTTON
I use FindWindowEx() like this cb = FindWindowEx(w,NULL,NULL,_T("&Scan now")); 

but it not found Control.

È stato utile?

Soluzione

The FindWindowEx function will not "drill down" into the window hierarchy - it will only look at the child windows of whatever you ask it to search. With that said, and from quickly looking at a screenshot of the Microsoft Security Essentials user interface, I am 99% certain that the "Scan now" button you are looking for isn't a direct child window of the main Microsoft Security Essentials Window. And that's why your FindWindowEx call fails.

I don't have access to the Microsoft Security Essentials software, but wit access to Spy++ it should be easy to find who the parent of the "Scan now" button is: the Microsoft Security Essentials window or another window that is, itself, the child of the Microsoft Security Essentials window.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top