从网站表单 vc++ 的 textField hWnd 中检索文本

发布于 2024-10-21 05:02:24 字数 1597 浏览 1 评论 0原文

我正在编写一个应用程序,可以自动填充任何 win32 应用程序中保存的数据。该应用程序是用 vc++ for MFC 完成的。

工作过程是发送程序到托盘,全局挂机键盘,按下CTRL+SHIFT+K(K=A添加,R删除,S发送信息,M修改信息,Q退出),加密/解密并保存/从MySql数据库中检索信息。

当程序捕获用户操作时,它会按如下方式扫描活动顶部窗口:

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);

并且检索信息的函数:

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() 仍有待开发。 问题是:

1- 如何从网站表单(主要是 Mozilla、IExplore 或 Google Crome)检索信息?

2-有没有办法将信息与信息所在的控件相匹配,而不是使用 zOrder?我猜想可以从 hWnd 检索类似“控件名称”之类的东西。

欢迎任何评论!谢谢,

米格尔

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

顾挽 2024-10-28 05:02:24

好的,在深入了解网络之后,对于第一个问题,我发现:

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

http://msdn.microsoft.com/en-us/library/aa366510%28VS.85%29.aspx -->非常好的逐步示例

第二个问题仍然存在..

有什么方法可以唯一匹配窗口中的信息及其内容吗?具体来说,我正在寻找编辑和静态控件。

我发现的另一件有趣的事情是,某些应用程序并没有真正显示编辑或任何字段中的一些数据(主要是密码),但它们直观地显示该字段中存在一些数据,您知道它是如何完成的吗?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文