Sneerz Posted June 7, 2015 Share Posted June 7, 2015 I am trying to automate internet explorer that involves having multiple tabs open on the same page, that also have the same titles for all of them. Due to this, I can't simply attach to a window with a particular title, as all of these windows/tabs share the same title. The only thing that differentiates them is the handles, but I am not really sure how that will help me. What i need to to is search the first window for a particular button (which I use _IEGetObjById). This works for the first tab and the first tab only, and the rest of the buttons on the other tabs can't be found. I assume this is because _IEAttach is only attaching to the first tab, and ignoring the rest. In the end, I want to have 4 tabs open, each one is searched for a particular button, and then moves on to the next one. If there is a method to search all of the tabs without attaching to a particular one, that would work as well. Thank you. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 8, 2015 Moderators Share Posted June 8, 2015 Hi, Sneerz, welcome to the forum. You will find the first response when asking the forum for help is always going to be the same: please provide your code (even if it is not running just as you would like it to), so we can see what you're trying to accomplish. Without your code, we have to guess at what you're trying to do, which usually delays you from getting the answers you need. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Sneerz Posted June 11, 2015 Author Share Posted June 11, 2015 (edited) Here is what I am trying to do. Look at the comments to see what I'm doing.$oIE1 = _IECreate("http://example.com/specific.html") __IENavigate($oIE1, "http://example.com/specific.html", 0, 0x800) $oIE1 = _IEAttach ("Title of Page") $oLink = _IEGetObjById($oIE1, "btn-" & $year & $month & $day & $time & $identifier & $numberSlots) $testo = _IEAction($oLink, "click")) Sleep(1000) _IEAction($oLink, "focus") ; next part is to get rid of pop up message $hwnd1 = _IEPropertyGet($oIE1, "hwnd") ControlSend($hwnd1, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") ; first part works perfectly ; i copied the same code and i am not sure what exactly to do to connect to the second tab, and i assumed that this wouldnt work. $oIE1 = _IEAttach ("Title of Page") ;notice the title is the same name as the first tab, but this needs to target the second tab now $oLink = _IEGetObjById($oIE1, "btn-" & $year & $month & $day & $time+8 & $identifier & $numberSlots) ;the +8 is looking for a different button $testo = _IEAction($oLink, "click") Sleep(1000) _IEAction($oLink, "focus") ; next part is to get rid of pop up message $hwnd1 = _IEPropertyGet($oIE1, "hwnd") ControlSend($hwnd1, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") MsgBox($MB_OK,"script", "script completed.") EndIfThanks. Edited June 11, 2015 by Sneerz Link to comment Share on other sites More sharing options...
Sneerz Posted June 11, 2015 Author Share Posted June 11, 2015 Can anyone offer some assistance? I am really not sure how do work with multiple tabs/windows with the same name. Link to comment Share on other sites More sharing options...
Sneerz Posted June 13, 2015 Author Share Posted June 13, 2015 So I know I didn't dig deep enough with my solution but I have made some progress. I decided to get the hwnd upon creation of the ie window and save it for later. The hwnd _IEattach works fine for the first window, but when it comes to the second window, i have the hwnd for the second window and I have confirmed that it is different from the first, but it still doesn't work? This is very strange behavior and based on my knowledge of how this should be working, I shouldn't be having a problem with my method. Link to comment Share on other sites More sharing options...
Danp2 Posted June 13, 2015 Share Posted June 13, 2015 Post your updated code so that we can review. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Sneerz Posted June 13, 2015 Author Share Posted June 13, 2015 (edited) Here is my updated code. $oIE1 = _IECreate("http://example.com/specific.html") $hwnd1 = _IEPropertyGet($oIE1, "hwnd") $oIE2 = _IECreate("http://example.com/specific.html") ;instead of opening two tabs, i open two windows as it allows me to grab the hwnd of both. Also notice that they are both the exact same webpage. $hwnd2 = _IEPropertyGet($oIE2, "hwnd") $oIE1 = _IEAttach($hwnd1, "hwnd") ;using the first hwnd to attach to the first window. $oLink = _IEGetObjById($oIE1, "btn-" & $year & $month & $day & $time & $identifier & $numberSlots) ;searching for button $testo = _IEAction($oLink, "click")) Sleep(1000) _IEAction($oLink, "focus") ; next part is to get rid of pop up message ControlSend($hwnd1, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") ;first part works perfectly ;i copied the same code and i am not sure what exactly to do to connect to the second tab, and i assumed that this wouldn't work. $oIE2 = _IEAttach($hwnd2, "hwnd") ;attach to the 2nd hwnd here. $oLink = _IEGetObjById($oIE2, "btn-" & $year & $month & $day & $time+8 & $identifier & $numberSlots) ;the +8 is looking for a different button $testo = _IEAction($oLink, "click") Sleep(1000) _IEAction($oLink, "focus") ; next part is to get rid of pop up message ControlSend($hwnd2, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") MsgBox($MB_OK,"script", "script completed.") Edited June 13, 2015 by Sneerz Link to comment Share on other sites More sharing options...
Danp2 Posted June 13, 2015 Share Posted June 13, 2015 You're script uses variables that aren't present. Please post a working example that we can actually run.Also, please explain why you are using ControlSend. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Sneerz Posted June 13, 2015 Author Share Posted June 13, 2015 Well I tested a completely unrelated website and my code worked. I had a specific error that pertained the particular site I was working on. Hwnd is working as expected now and I am able to work with multiple windows with the same name. Thanks for attempting to help, it was an easy to overlook error on my part. 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