3

我正在编写一个程序,该程序需要记录哪些程序处于活动状态以及它正在访问的网站(如果它是浏览器)。我有可以在 IE 中获取地址栏窗口内容的代码,但是当我在 chrome 上使用 winspy 时,它全部作为一个窗口返回。有谁知道是否有办法抓取地址栏的内容?

我为 IE 工作的代码是:

HWND foreground = GetForegroundWindow();
HWND hwndEdit = FindWindowEx(foreground, NULL, "EDIT", NULL);

HWND handle = FindWindowEx(foreground, NULL, "WorkerW", "Navigation Bar");
if (NULL != handle)
{
handle = FindWindowEx(handle, NULL, "ReBarWindow32", NULL);
if (NULL != handle)
{
handle = FindWindowEx(handle, NULL, "Address Band Root", NULL);
}}
HWND hwndEdit = FindWindowEx(handle, NULL, "Edit", NULL);

const int bufferSize = 5024;
Char textBuffer[bufferSize] = "";
SendMessage(hwndEdit, WM_GETTEXT, (WPARAM)bufferSize, (LPARAM)textBuffer);

string addressbartext = textBuffer;
if(addressbartext == "AutoCompleteProxy")
{addressbartext = "";}
else
{addressbartext = textBuffer;
}

cout << addressbartext;
4

0 回答 0