Xaver Posted January 9, 2007 Share Posted January 9, 2007 Dear Ladies and Sirs, I'm new to AutoIt3. The language seems to be great and relatively easy to learn. So the first thing is that I want to express my thanks to the authors of AutoIt. Up to now everything I tried with AutoIt worked rather well, with the exception of the problem I ran into: Description of problem: Via WinList() and some additional code I obtained the handles and names of all the visible windows. Via WinActive("Windowname") I know the active IE window. Therefore I also know the handle of the active IE window. Where I fail is to obtain the URL of the website shown in the active IE window, for I don't seem to have found the right way to use the handle. My request: Would anybody be so kind and show me how to get the URL of an IE window when its handle is known. Thank you very much and all the best for 2007, Xaver Link to comment Share on other sites More sharing options...
Immensee Posted January 9, 2007 Share Posted January 9, 2007 (edited) Hello!I'm not sure what your asking, im 14 (tomorrow 15) and dutch soz, but i thinkyou want a code that finds the url of a program.well, im not very used to with the new IE capabilities of AutoIt, but i once have learned programming DOM. A programming code for creating websites.i've checked it out at the 'AutoIt Help' thing and found out that you can use the command_IEdocGetObj for getting information about a particular internet window.here's the code if you don't understand me ;; This include is required #include <IE.au3> ;; The window with internet Explorer / firefox etc. $MyWebsite = _IECreate("http://www.google.nl") ;; The command _IDocGetObj needs a handler, look above $Result = _IEDocGetObj($MyWebsite) ;; Print out the result MsgBox(0, "Searching for the URL", $Result.URL)Well, this research helped me too and i hope that i helped you...bye bye,- me-------Edit:this might be handy if you don't know the HTML DOM language code:http://www.w3schools.com/htmldom/dom_obj_document.aspwell cya, Edited January 9, 2007 by Immense Link to comment Share on other sites More sharing options...
Xaver Posted January 9, 2007 Author Share Posted January 9, 2007 Hello! I'm not sure what your asking, im 14 (tomorrow 15) and dutch soz, but i think you want a code that finds the url of a program. well, im not very used to with the new IE capabilities of AutoIt, but i once have learned programming DOM. A programming code for creating websites. i've checked it out at the 'AutoIt Help' thing and found out that you can use the command _IEdocGetObj for getting information about a particular internet window. here's the code if you don't understand me ;; This include is required #include <IE.au3> ;; The window with internet Explorer / firefox etc. $MyWebsite = _IECreate("http://www.google.nl") ;; The command _IDocGetObj needs a handler, look above $Result = _IEDocGetObj($MyWebsite) ;; Print out the result MsgBox(0, "Searching for the URL", $Result.URL) Well, this research helped me too and i hope that i helped you... bye bye, - me ------- Edit: this might be handy if you don't know the HTML DOM language code: http://www.w3schools.com/htmldom/dom_obj_document.asp well cya, Link to comment Share on other sites More sharing options...
Immensee Posted January 9, 2007 Share Posted January 9, 2007 (edited) eh, uhm eh? you have quoted my reply but haven't answered yourself? that's something new is that a way for thank you? Edited January 9, 2007 by Immense Link to comment Share on other sites More sharing options...
Xaver Posted January 9, 2007 Author Share Posted January 9, 2007 eh, uhm eh? you have quoted my reply but haven't answered yourself?that's something new is that a way for thank you? Dir Sir,please excuse my clumsiness, but I'm not used to the workings of this forum. Thank you very muchfor your reply.Oh, and I hope you don't consider it as bad omen if I wish you all the best for the age of 15. Thatwas about he age when I started with computers...Regarding your statement "I'm not sure what your asking", I want to stress that I want to retrieve theURL from an already existing IE window. I don't want to create a new IE object or window, especiallyif I have to create with a URL because it would be pointless to create an IE application via an URL andthe retrieving the same URL.Best regards,Xaver Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 9, 2007 Moderators Share Posted January 9, 2007 This should get what you need. #include <IE.au3> Opt("WinTitleMatchMode", 2) ; Grab the handle of an existing IE Window $HWnd = WinGetHandle("Internet Explorer") ; Attach to the existing IE Window by handle $oIE = _IEAttach($HWnd, "hwnd") ; Get the URL of the previously attached window $sURL = _IEPropertyGet($oIE, "locationurl") ; Write the URL to the console ConsoleWrite($sURL & @CR) Link to comment Share on other sites More sharing options...
Immensee Posted January 9, 2007 Share Posted January 9, 2007 Dir Sir, please excuse my clumsiness, but I'm not used to the workings of this forum. Thank you very much for your reply. Oh, and I hope you don't consider it as bad omen if I wish you all the best for the age of 15. That was about he age when I started with computers... Regarding your statement "I'm not sure what your asking", I want to stress that I want to retrieve the URL from an already existing IE window. I don't want to create a new IE object or window, especially if I have to create with a URL because it would be pointless to create an IE application via an URL and the retrieving the same URL. Best regards, Xaver Hmm, you don't need to be so (how do you say that?) formal but it's good, well, if you use my script on your script it would work. If i read your message, i can see that you have already created an IE object. This object, when created gives you a certain 'handle'. With this handle, you can use the DOM command to find the URL that's currently on the IE object. To retrieve a certain handle, you must store it first into a variable. $MyWebsite = _IECreate("http://www.google.nl") ;; Now you have the variable: $MyWebsite setted to the handle of the just made (_IECreate) IE object. Now you have done this, you must also convert the handle into a DOM Object. $DOMObject = _IEDocGetObj($MyWebsite) With the just converted handle, you can call up stuff from the IE Object with the DOM Object. This is the way how you do that: $DOMObject. <My DOM call code> you can put a certain DOM code inside the < >. So, like you said, you want the URL of the IE Object: $URL = $DOMObject.URL That's all in super small steps! - me Link to comment Share on other sites More sharing options...
Xaver Posted January 9, 2007 Author Share Posted January 9, 2007 This should get what you need. #include <IE.au3> Opt("WinTitleMatchMode", 2) ; Grab the handle of an existing IE Window $HWnd = WinGetHandle("Internet Explorer") ; Attach to the existing IE Window by handle $oIE = _IEAttach($HWnd, "hwnd") ; Get the URL of the previously attached window $sURL = _IEPropertyGet($oIE, "locationurl") ; Write the URL to the console ConsoleWrite($sURL & @CR) Dear Sir, thank you very much for your efforts and your answer to my request. Your suggestion worked well. The funny thing about your solution is, that I already had the handle via the function WinList(). Now I'm going to compare both handles for the same IE window and hopefully learn something useful. Best regards, Xaver Link to comment Share on other sites More sharing options...
Xaver Posted January 9, 2007 Author Share Posted January 9, 2007 Dear Sir,thank you very much for your efforts and your answer to my request. Your suggestion worked well.The funny thing about your solution is, that I already had the handle via the function WinList(). NowI'm going to compare both handles for the same IE window and hopefully learn something useful.Best regards,XaverDear Sir,now I compared the $HWnd = WinGetHandle("Window name") from your script with the handle I gotWinList(). The handles are identical. What my initial program lacked was the the line$oIE = _IEAttach(Window handle , "hwnd").Yesterday night I experimented with _IEAttach but didn't recognize that the parameter "hwnd" exists.Thanks to you now everything works really fine.Best regards,Xaver Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted January 9, 2007 Moderators Share Posted January 9, 2007 @Immense - _IECreate() does NOT return a handle, it returns an InternetExplorer.Application object. He was explaining that he had an IE Window that was not opened by way of script, thus requiring _IEAttach() to get a reference to the InternetExplorer.Application object. @Xaver - I only added WinGetHandle() to my example script so it would be functional, but from the looks of it you got it sorted anyway. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now