开发者

retrieve text from a textField hWnd from a website form vc++

I'm writting an application that autofills saved data in any win32 application. This application is done in vc++ for MFC.

The working process is to send program to tray, global hook keyboard, catch CTRL+SHIFT+ K (K=A to add, R to remove, S to send info, M to modify info and Q to quit), encript/decript and save/retrieve the info from MySql database.

When the program catches an user action, it scans the active top window as follows:

HWND hWndMW = GetForegroundWindow();
wchar_t buff[512];

this->ClearBuffer<wchar_t>(buff, 512);
GetClassName(hWndMW, buff, 512);
String^ sClassName = gcnew String(buff);
this->ClearBuffer<wchar_t>(buff, 512);

GetWindowText(hWndMW, buff, 512);
String^ sText = gcnew String(buff);

zOrder=0;           
EnumChildWindowsDelegate^ ecwDel = gcnew AutoComplete::EnumChildWindowsDelegate(this, &AutoComplete::hWndControls);
EnumChildWindows(hWndMW, ecwDel, (LPARAM) NULL);

And the function that retrieves the info:

bool hWndControls(HWND hWnd, LPARAM lParam)
{
    wchar_t buff[512];
    zOrder++;

    this->ClearBuffer<wchar_t>(buff, 512);
    GetClassName(hWnd, buff, 512);
    String^ sClassName = gcnew String(buff);

    if (sClassName->ToUpper()->Contains("EDIT"))
    {
        char buff1[MAX_DATASIZE];
        this->ClearBuffer<char>(buff1, MAX_DATASIZE);
        int len = this->SendMessage(hWnd, WM_GETTEXT, MAX_DATASIZE, (LPARAM) buff1);
        buff1[len] = 0;
        String^ sTextInside = gcnew String(buff1);
        if(textInside!="") SaveData(hWndMW, hWnd, zOrder, sTextInside);
    }


    return true;
};
开发者_如何学运维

SaveData() is still to be developed. Questions are:

1- How to retrieve info from a website form (mainly in a Mozilla, IExplore or Google Crome)?

2- Is there any way to match the info with the control where the info is, instead of using zOrder? I guess something like "control name" that can be retrieved from hWnd..

Any comments are welcome! Thanks,

Miguel


Ok, after looking deep inside on the web, for the first question I found that:

http://www.codeproject.com/KB/applications/Sniffer.aspx

http://msdn.microsoft.com/en-us/library/aa366510%28VS.85%29.aspx --> very good step by step example

The second question is still alive..

Is there any way to uniquely match the info from a window and its content? In concret I am looking for EDIT and STATIC controls.

Another interesting thing I found is that some applications doesn't really show some of data in the EDIT or any field (mainly passwords) but they visualy show there is some data in the field, any idea on how is it done?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜