Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am a c++ program beginner.

I used functions FindWindows() , EnumChildWindow() and GetWindowText() to get the current URL of chrome, but it is not work now.

By using spy++, I can't find the handle and class for the URL window with chrome ver 29...so my old solution doesn't work anymore.

I have searched google , but I still not find a solution.

Can anyone give a solution for me? thanks...
Posted
Comments
Richard MacCutchan 15-Sep-13 7:42am    
This is never guaranteed to work since Chrome, and other programs, may change from version to version. You probably need to write a browser extension for Chrome to extract the information.

Hi Shawn.Liao
This topic/question has already been on this site
Please see here:
Help me to get all url of current tabs in google chrome[^]
how to get URL form any web browser (like firefox,ie,google chrome,...) in C#[^]

Regards,
Alex
 
Share this answer
 
Comments
Shawn.Liao 10-Sep-13 3:05am    
Hello Alex,
Thanks for your response.
But both of above links seem not solved my question.
may you give me some examples for c++ program..? or other solution?
(especially for chrome ver 29)
With this Example,there are many useful functions!!
And they are easy to use in main();

http://msdn.microsoft.com/en-us/library/windows/desktop/dd373640(v=vs.85).aspx[^]

C++
#include <Windows.h>
#include <Oleacc.h>
HWINEVENTHOOK g_hook;
#pragma comment( lib,"Oleacc.lib")

int main()
{
     MSG msg;

     InitializeMSAA();

     while ( GetMessage(&msg, NULL, 0, 0) )
     {
                TranslateMessage(&msg);
                DispatchMessage(&msg);
     }

     ShutdownMSAA();
     return 0;
}


In SetWinEventHook()...
You'd better to get the "Process ID" of chrome.exe first.(you can get PID from task manager)
I choice the event from EVENT_OBJECT_VALUECHANGE to EVENT_OBJECT_VALUECHANGE

And in void CALLBACK HandleWinEvent()
You will see get_accName(). It will get the Object Name
But there is another function get_accValue() , you will see url after use it.

get_accName() will get the Object Name.
Example:Address and search bar
get_accValue() will get the Object Value....
This value is URL. Example: http://www.google.com/
 
Share this answer
 
v2
Comments
micutzu 1-Oct-13 10:41am    
Hello,

Do you know a different method that does not involve a hook? Maybe there is a way (which I did not find) that will allow using AccessibleObjectFromWindow and not AccessibleObjectFromEvent.

Thank you.
Shawn.Liao 2-Oct-13 5:38am    
Hello,
In fact, I have tried AccessibleObjectFromWindow() first, but did not work.
(maybe there are something i missed....)
So I tried AccessibleObjectFromEvent()....
micutzu 2-Oct-13 6:00am    
Hello,

I am missing something too :) but maybe I will figure it out and post an update.
Hallo, I have same problem.
It seems that google made some changes in the chrome design and it is not more possible
to get url from google chrome. Change is from version 28 or 29.
I tried also via IAccessible interface, via EnumChildWindow, FindWindowEx
I searched all the Internet with no success.
I need IT ALSO
 
Share this answer
 
Comments
Shawn.Liao 15-Sep-13 21:20pm    
Hello Opis-Kladno,

I finally use SetWinEventHook() and AccessibleObjectFromEvent() to get the chrome URL.

example please see>>>
http://msdn.microsoft.com/en-us/library/windows/desktop/dd373640(v=vs.85).aspx
Hallo,
Thanks for response. Can you send me small example of using SetWinEventHook function?
Which events are you handling and how you get URL ?
Thanks
 
Share this answer
 
Comments
Richard MacCutchan 16-Sep-13 9:04am    
Please do not post questions and comments as Solutions.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900