nightster Posted March 30, 2007 Share Posted March 30, 2007 Hello, I have an AutoIT script which opens several IE windows. I then need to access these windows to perform different tasks. How can I reference the window I need? It seems you can only refer to a window by it's title text. Is that correct? If so, that's a real problem for me as all of my IE windows have the exact same title text! When I create an IE window with something like: $oIE[$i] = _IECreate ("http://www.google.com") Can I not use the variable I give it to refer to it later on, somehow? If so, how would I use that reference variable to make the window active? Any thoughts very much welcomed! Thanks, Rob. Link to comment Share on other sites More sharing options...
BillLuvsU Posted March 30, 2007 Share Posted March 30, 2007 Each window has a unique handle. In most functions involving windows you can use the handle instead of the Title. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Bert Posted March 30, 2007 Share Posted March 30, 2007 Each window will have a handle. Use the WinGetHandle command to get the info you need. You may want to put the different windows into a array first. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
nightster Posted March 30, 2007 Author Share Posted March 30, 2007 Each window will have a handle. Use the WinGetHandle command to get the info you need. You may want to put the different windows into a array first.Thanks Guys. However, the WinGetHandle function seems to take the title of the window as an argument. The titles of all my IE instances are the same (it's the same webpage opened several times for different reasons).Or am I missing something?Thanks! Link to comment Share on other sites More sharing options...
BillLuvsU Posted March 30, 2007 Share Posted March 30, 2007 just use an empty string ( ,"", ) for the argument and it will take the active window. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
Bert Posted March 30, 2007 Share Posted March 30, 2007 Try WinList. You may need to play around to see which window is which. Also, is the text in the window any different? You could try to use the IE tools to see if you can read what text is in the window. ANother thougth is to rename the window when it first appears so you can get a different name on each of them. The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
SpookMeister Posted March 30, 2007 Share Posted March 30, 2007 (edited) just use an empty string ( ,"", ) for the argument and it will take the active window. Here's some sample code to prove fear's theory #include <IE.au3> _IECreate("www.autoitscript.com", 1, 1, 0) $handle_1 = WinGetHandle("") _IECreate("my.yahoo.com", 1, 1, 0) $handle_2 = WinGetHandle("") While 1 Sleep(2000) $var = MsgBox(4099, "Swap between IE windows", _ "Click YES to switch to the Autoit website" & _ @CRLF & "Click NO to switch to Yahoo") Select Case $var = 6 WinActivate($handle_1) Case $var = 7 WinActivate($handle_2) Case Else Exit EndSelect WEnd Edited March 30, 2007 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
nightster Posted March 30, 2007 Author Share Posted March 30, 2007 Thanks. Still having trouble... Any idea what's wrong with this script: CODE#include <IE.au3> _IECreate("www.autoitscript.com", 1, 1, 0) $handle = WinGetHandle("") _IENavigate ($handle, "www.google.com") Thanks, Rob. Link to comment Share on other sites More sharing options...
DaleHohm Posted March 30, 2007 Share Posted March 30, 2007 $oIE1 = _IECreate(someURL) $oIE2 = _IECreate(someURL) $oIE3 = _IECreate(someURL) $oIE4 = _IECreate(someURL) $handle1 = _IEPropertyGet($oIE1, "hwnd") $handle2 = _IEPropertyGet($oIE2, "hwnd") $handle3 = _IEPropertyGet($oIE3, "hwnd") $handle4 = _IEPropertyGet($oIE4, "hwnd") Then use the handle in any of the standard AutoIt functions in place of the title... Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
nightster Posted March 30, 2007 Author Share Posted March 30, 2007 Thanks...but I still can't get this code to work... CODE#include <IE.au3> $oIE = _IECreate("www.autoitscript.com", 1, 1, 0) $handle = _IEPropertyGet($oIE, "hwnd") _IENavigate ($handle, "www.google.com") Any ideas? Thank you!! Link to comment Share on other sites More sharing options...
DaleHohm Posted March 30, 2007 Share Posted March 30, 2007 No, that won't work... use $oIE in _IENavigate Use the handle in functions like WinMove, WinActivate etc. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble 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