Prev: Script
Next: Script for IBM AS/400 session keystrokes
From: Csaba Gabor on 11 Nov 2009 03:36 On Nov 8, 11:56 am, "AvWG" <dretr...(a)hotmail.com> wrote: > Hi, > > With vbscript I.ve created the following: > I start the IE-application, use sendkeys to login in on a site. Next I > create 10 more tabs (internet-pages), each with slightly another address. > When this is done I want to go to the 2nd tab, save the source information > and do this for the rest of the 9 remaining tabs.... > > The problem is: I can't get the focus off the first (login) tab. Though I > can go to the next tab with sendkeys :-( , the html-source I want to review > is still of the first tab... > > Manually I can click on the tabs and get the source. But first this time > consuming and second I want to read many more internetpages/tabs then the 10 > I mentioned. > > So is there a vbscript-"command" to switch to other tabs? I've read this thread, and I don't see any justification for wanting to put the pages in different tabs. Specifically, there is no mention of user interaction. Assuming that there is no user involvement and that you are simply after information on those pages, I think you would be better off creating an IE instance for each page to which you'd like to navigate. For example, an array of IE instances which (eventually) should run hidden. However, there is a second problem, which is already evident in your code, and that is that you are having a significant problem determining when pages are ready. This is, in general, quite a difficult issue. I think it would be far easier for you to spawn a different process for each page you'd like to load so that it can be dealt with separately. However, doing this with 10 pages or so can be a massive hit on the CPU, so I don't recommend this route. Parallel processing of pages is really messy. Unless you have a REALLY SPECIFIC reason for needing the parallel aspect, your posted code implies that you are doing background processing. That being the case, you could just as well process each page one at a time (which also reduces the chance that the remote site will ban you for robotic access of their pages). So you could have the original IE for your starting page, and then create a second IE for your array of links (so that you can get back to your original IE when done with processing said array). Now process each link one at a time (taking into account what to do if you've gotten to some timeout limit and the page hasn't loaded). Csaba Gabor from Vienna > Part of the script: > Set oIE = CreateObject("InternetExplorer.Application") ', "oIE_") > oIE.Visible = True > oIE.FullScreen = False > > 'open a new window > oIE.Navigate2 aLinks(0) > Do While oIE.Busy > WScript.Sleep 50 > Loop > > 'open url In new tab > Logon() ' My own logon subroutine > > WScript.Sleep 2000 > For J=1 To 9 > oIE.Navigate2 aLinks(J), navOpenInBackgroundTab 'navOpenInNewTab ' > Do While oIE.Busy > WScript.Sleep 50 > Loop > WScript.Sleep 3000 > Next > > WshShell.SendKeys "^{TAB}" 'go to the 2nd tab > WScript.Sleep 100 > on error goto 0 > > WScript.Sleep 2000 > WScript.Echo "***********************************************************" > > Here I used code as > oIE.Document.body.innerHTML > or > Set oHTML = CreateObject("Microsoft.XMLHTTP") > oHTML.open "GET" , sURL, True > > Does anybody have suggestions how to stear between the tabs? By the way, I haven't tried this, and I don't have a tabbed IE here to do so with, but if you click on the different tabs of IE, do you get a different title in the title bar? If so, it's conceivable (though perhaps not likely) that you could activate a specific tab through AppActivate. Has anyone tried that? I wouldn't want to take bets on it, but...
From: AvWG on 11 Nov 2009 16:32 Hi Csaba, Thank you for your message. I've already done what you described. One Instance, two instances, 25 instances. But that's not the problem. One of the problems is that it is not possible to go to the 12th tab after creating 25 tabs (with ie VBScript) .The other problem: When I use something like sendkeys and end at the 12th tab, I don't get the source of that page. What I do get is the source of the very first page I need to start, with credentials in order to have access to that particular site. Manually on that page I can click on 'Source' in the menu and get the source I want... So no methodes to freely move between tabs and not getting the right source dump.... Andr� "Csaba Gabor" <danswer(a)gmail.com> schreef in bericht news:f8a0bc95-0728-4f4e-95e6-bcd17049a100(a)s31g2000yqs.googlegroups.com... On Nov 8, 11:56 am, "AvWG" <dretr...(a)hotmail.com> wrote: > Hi, > > With vbscript I.ve created the following: > I start the IE-application, use sendkeys to login in on a site. Next I > create 10 more tabs (internet-pages), each with slightly another address. > When this is done I want to go to the 2nd tab, save the source information > and do this for the rest of the 9 remaining tabs.... > > The problem is: I can't get the focus off the first (login) tab. Though I > can go to the next tab with sendkeys :-( , the html-source I want to > review > is still of the first tab... > > Manually I can click on the tabs and get the source. But first this time > consuming and second I want to read many more internetpages/tabs then the > 10 > I mentioned. > > So is there a vbscript-"command" to switch to other tabs? I've read this thread, and I don't see any justification for wanting to put the pages in different tabs. Specifically, there is no mention of user interaction. Assuming that there is no user involvement and that you are simply after information on those pages, I think you would be better off creating an IE instance for each page to which you'd like to navigate. For example, an array of IE instances which (eventually) should run hidden. However, there is a second problem, which is already evident in your code, and that is that you are having a significant problem determining when pages are ready. This is, in general, quite a difficult issue. I think it would be far easier for you to spawn a different process for each page you'd like to load so that it can be dealt with separately. However, doing this with 10 pages or so can be a massive hit on the CPU, so I don't recommend this route. Parallel processing of pages is really messy. Unless you have a REALLY SPECIFIC reason for needing the parallel aspect, your posted code implies that you are doing background processing. That being the case, you could just as well process each page one at a time (which also reduces the chance that the remote site will ban you for robotic access of their pages). So you could have the original IE for your starting page, and then create a second IE for your array of links (so that you can get back to your original IE when done with processing said array). Now process each link one at a time (taking into account what to do if you've gotten to some timeout limit and the page hasn't loaded). Csaba Gabor from Vienna > Part of the script: > Set oIE = CreateObject("InternetExplorer.Application") ', "oIE_") > oIE.Visible = True > oIE.FullScreen = False > > 'open a new window > oIE.Navigate2 aLinks(0) > Do While oIE.Busy > WScript.Sleep 50 > Loop > > 'open url In new tab > Logon() ' My own logon subroutine > > WScript.Sleep 2000 > For J=1 To 9 > oIE.Navigate2 aLinks(J), navOpenInBackgroundTab 'navOpenInNewTab ' > Do While oIE.Busy > WScript.Sleep 50 > Loop > WScript.Sleep 3000 > Next > > WshShell.SendKeys "^{TAB}" 'go to the 2nd tab > WScript.Sleep 100 > on error goto 0 > > WScript.Sleep 2000 > WScript.Echo "***********************************************************" > > Here I used code as > oIE.Document.body.innerHTML > or > Set oHTML = CreateObject("Microsoft.XMLHTTP") > oHTML.open "GET" , sURL, True > > Does anybody have suggestions how to stear between the tabs? By the way, I haven't tried this, and I don't have a tabbed IE here to do so with, but if you click on the different tabs of IE, do you get a different title in the title bar? If so, it's conceivable (though perhaps not likely) that you could activate a specific tab through AppActivate. Has anyone tried that? I wouldn't want to take bets on it, but...
From: mayayana on 11 Nov 2009 17:47 > One > Instance, two instances, 25 instances. But that's not the problem. > > One of the problems is that it is not possible to go to the 12th tab after > creating 25 tabs (with ie VBScript) . I think Csaba Gabor is saying the same thing I suggested a few days ago: Don't use tabs! Navigate in a single window to each page, one at a time. Then you only have one page loaded at a time and the source code is available.
From: Csaba Gabor on 11 Nov 2009 20:52 On Nov 11, 10:32 pm, "AvWG" <dretr...(a)hotmail.com> wrote: > Hi Csaba, > > Thank you for your message. I've already done what you described. I've recommended two main things, and described a few things that I recommended against. The first recommendation was to stay away from tabs (using multiple instances or multiple invocations were two possible alternatives (but I certainly don't recommend either one)), especially by using single instance serial navigation. The second was a possible way to get ahold of a tab (using AppActivate) if you nevertheless insist on tabs. Which is it that you have already done? > One Instance, two instances, 25 instances. But that's not the > problem. > > One of the problems is that it is not possible to go to the 12th tab > after creating 25 tabs (with ie VBScript). You have not motivated the problem. What makes it compelling to create any tabs whatsoever? I'm not saying there couldn't be a reason, but without guiding our thinking a bit, it is hard to wrap our heads around why. Specifically, the internet world existed pretty well before tabs came along. They did so as a user convenience rather than a user necessity. So I would think you have to be doing something pretty darned unusual to be requiring tabs. > The other problem: When I use something like sendkeys and end > at the 12th tab, I don't get the source of that page. What I do Oh, and that's the other thing. You should really be avoiding send keys, when at all possible. It is only a method of last resort, and it is really easy to mess up doing the kinds of things that you are doing (as you have come to realize). Without looking more at your specifics, my first inclination is to think that you have timing issues. One possiblility for you is to really slow the send keys down (if your architecture doesn't permit this, the timing issues become much more probable) so you can see it as it happens. How do you avoid send keys? The answer is to fill out the form on the page (for example, something like: ie.document.getElementById("myId").value = "myEntry" or var body = ie.document.body body.getElementsByTagName("INPUT")(0).value = "myEntry") You can direct links and targets to a specific window by setting their target attribute to the name of the window or frame in question. Oh, and yes, mayayana expressed both the principle of not using tabs nor using send keys much more succinctly in his Nov 8 post. > get is the source of the very first page I need to start, with > credentials in order to have access to that particular site. Manually on > that page I can click on 'Source' in the menu and get the source I want.... > > So no methodes to freely move between tabs and not getting the right source > dump.... > > André > > "Csaba Gabor" <dans...(a)gmail.com> schreef in berichtnews:f8a0bc95-0728-4f4e-95e6-bcd17049a100(a)s31g2000yqs.googlegroups.com... > On Nov 8, 11:56 am, "AvWG" <dretr...(a)hotmail.com> wrote: > > > Hi, > > > With vbscript I.ve created the following: > > I start the IE-application, use sendkeys to login in on a site. Next I > > create 10 more tabs (internet-pages), each with slightly another address. > > When this is done I want to go to the 2nd tab, save the source information > > and do this for the rest of the 9 remaining tabs.... > > > The problem is: I can't get the focus off the first (login) tab. Though I > > can go to the next tab with sendkeys :-( , the html-source I want to > > review > > is still of the first tab... > > > Manually I can click on the tabs and get the source. But first this time > > consuming and second I want to read many more internetpages/tabs then the > > 10 > > I mentioned. > > > So is there a vbscript-"command" to switch to other tabs? > > I've read this thread, and I don't see any justification for wanting > to put the pages in different tabs. Specifically, there is no mention > of user interaction. Assuming that there is no user involvement > and that you are simply after information on those pages, I think > you would be better off creating an IE instance for each page > to which you'd like to navigate. For example, an array of > IE instances which (eventually) should run hidden. > > However, there is a second problem, which is already evident > in your code, and that is that you are having a significant > problem determining when pages are ready. This is, in general, > quite a difficult issue. I think it would be far easier for you to > spawn a different process for each page you'd like to load so > that it can be dealt with separately. However, doing this > with 10 pages or so can be a massive hit on the CPU, so I > don't recommend this route. > > Parallel processing of pages is really messy. Unless you > have a REALLY SPECIFIC reason for needing the parallel > aspect, your posted code implies that you are doing > background processing. That being the case, you could > just as well process each page one at a time (which also > reduces the chance that the remote site will ban you for > robotic access of their pages). So you could have the > original IE for your starting page, and then create a > second IE for your array of links (so that you can get > back to your original IE when done with processing said > array). Now process each link one at a time (taking into > account what to do if you've gotten to some timeout limit > and the page hasn't loaded). > > Csaba Gabor from Vienna > > > > > > > Part of the script: > > Set oIE = CreateObject("InternetExplorer.Application") ', "oIE_") > > oIE.Visible = True > > oIE.FullScreen = False > > > 'open a new window > > oIE.Navigate2 aLinks(0) > > Do While oIE.Busy > > WScript.Sleep 50 > > Loop > > > 'open url In new tab > > Logon() ' My own logon subroutine > > > WScript.Sleep 2000 > > For J=1 To 9 > > oIE.Navigate2 aLinks(J), navOpenInBackgroundTab 'navOpenInNewTab ' > > Do While oIE.Busy > > WScript.Sleep 50 > > Loop > > WScript.Sleep 3000 > > Next > > > WshShell.SendKeys "^{TAB}" 'go to the 2nd tab > > WScript.Sleep 100 > > on error goto 0 > > > WScript.Sleep 2000 > > WScript.Echo "***********************************************************" > > > Here I used code as > > oIE.Document.body.innerHTML > > or > > Set oHTML = CreateObject("Microsoft.XMLHTTP") > > oHTML.open "GET" , sURL, True > > > Does anybody have suggestions how to stear between the tabs? > > By the way, I haven't tried this, and I don't have a tabbed IE here > to do so with, but if you click on the different tabs of IE, do you > get a different title in the title bar? If so, it's conceivable > (though > perhaps not likely) that you could activate a specific tab through > AppActivate. Has anyone tried that? I wouldn't want to take bets > on it, but...
From: AvWG on 12 Nov 2009 16:47
Hi, I've done all, with and without tabs. And in both cases I can't get the "same" source of a page, manually vs vbscript. So, for me, the problem is that vbscript can't do the job for me and I doubt another language can... I believe the problem is the internet.application-object does not provide the right "tools" Btw: for my current job I automate every thing with vbscript and till now there was little I couldn't handle.... :-( Andr� "Csaba Gabor" <danswer(a)gmail.com> schreef in bericht news:0ddc3d94-fccc-4a53-a9f6-b4aaa5baba80(a)d5g2000yqm.googlegroups.com... On Nov 11, 10:32 pm, "AvWG" <dretr...(a)hotmail.com> wrote: > Hi Csaba, > > Thank you for your message. I've already done what you described. I've recommended two main things, and described a few things that I recommended against. The first recommendation was to stay away from tabs (using multiple instances or multiple invocations were two possible alternatives (but I certainly don't recommend either one)), especially by using single instance serial navigation. The second was a possible way to get ahold of a tab (using AppActivate) if you nevertheless insist on tabs. Which is it that you have already done? > One Instance, two instances, 25 instances. But that's not the > problem. > > One of the problems is that it is not possible to go to the 12th tab > after creating 25 tabs (with ie VBScript). You have not motivated the problem. What makes it compelling to create any tabs whatsoever? I'm not saying there couldn't be a reason, but without guiding our thinking a bit, it is hard to wrap our heads around why. Specifically, the internet world existed pretty well before tabs came along. They did so as a user convenience rather than a user necessity. So I would think you have to be doing something pretty darned unusual to be requiring tabs. > The other problem: When I use something like sendkeys and end > at the 12th tab, I don't get the source of that page. What I do Oh, and that's the other thing. You should really be avoiding send keys, when at all possible. It is only a method of last resort, and it is really easy to mess up doing the kinds of things that you are doing (as you have come to realize). Without looking more at your specifics, my first inclination is to think that you have timing issues. One possiblility for you is to really slow the send keys down (if your architecture doesn't permit this, the timing issues become much more probable) so you can see it as it happens. How do you avoid send keys? The answer is to fill out the form on the page (for example, something like: ie.document.getElementById("myId").value = "myEntry" or var body = ie.document.body body.getElementsByTagName("INPUT")(0).value = "myEntry") You can direct links and targets to a specific window by setting their target attribute to the name of the window or frame in question. Oh, and yes, mayayana expressed both the principle of not using tabs nor using send keys much more succinctly in his Nov 8 post. > get is the source of the very first page I need to start, with > credentials in order to have access to that particular site. Manually on > that page I can click on 'Source' in the menu and get the source I want... > > So no methodes to freely move between tabs and not getting the right > source > dump.... > > Andr� > > "Csaba Gabor" <dans...(a)gmail.com> schreef in > berichtnews:f8a0bc95-0728-4f4e-95e6-bcd17049a100(a)s31g2000yqs.googlegroups.com... > On Nov 8, 11:56 am, "AvWG" <dretr...(a)hotmail.com> wrote: > > > Hi, > > > With vbscript I.ve created the following: > > I start the IE-application, use sendkeys to login in on a site. Next I > > create 10 more tabs (internet-pages), each with slightly another > > address. > > When this is done I want to go to the 2nd tab, save the source > > information > > and do this for the rest of the 9 remaining tabs.... > > > The problem is: I can't get the focus off the first (login) tab. Though > > I > > can go to the next tab with sendkeys :-( , the html-source I want to > > review > > is still of the first tab... > > > Manually I can click on the tabs and get the source. But first this time > > consuming and second I want to read many more internetpages/tabs then > > the > > 10 > > I mentioned. > > > So is there a vbscript-"command" to switch to other tabs? > > I've read this thread, and I don't see any justification for wanting > to put the pages in different tabs. Specifically, there is no mention > of user interaction. Assuming that there is no user involvement > and that you are simply after information on those pages, I think > you would be better off creating an IE instance for each page > to which you'd like to navigate. For example, an array of > IE instances which (eventually) should run hidden. > > However, there is a second problem, which is already evident > in your code, and that is that you are having a significant > problem determining when pages are ready. This is, in general, > quite a difficult issue. I think it would be far easier for you to > spawn a different process for each page you'd like to load so > that it can be dealt with separately. However, doing this > with 10 pages or so can be a massive hit on the CPU, so I > don't recommend this route. > > Parallel processing of pages is really messy. Unless you > have a REALLY SPECIFIC reason for needing the parallel > aspect, your posted code implies that you are doing > background processing. That being the case, you could > just as well process each page one at a time (which also > reduces the chance that the remote site will ban you for > robotic access of their pages). So you could have the > original IE for your starting page, and then create a > second IE for your array of links (so that you can get > back to your original IE when done with processing said > array). Now process each link one at a time (taking into > account what to do if you've gotten to some timeout limit > and the page hasn't loaded). > > Csaba Gabor from Vienna > > > > > > > Part of the script: > > Set oIE = CreateObject("InternetExplorer.Application") ', "oIE_") > > oIE.Visible = True > > oIE.FullScreen = False > > > 'open a new window > > oIE.Navigate2 aLinks(0) > > Do While oIE.Busy > > WScript.Sleep 50 > > Loop > > > 'open url In new tab > > Logon() ' My own logon subroutine > > > WScript.Sleep 2000 > > For J=1 To 9 > > oIE.Navigate2 aLinks(J), navOpenInBackgroundTab 'navOpenInNewTab ' > > Do While oIE.Busy > > WScript.Sleep 50 > > Loop > > WScript.Sleep 3000 > > Next > > > WshShell.SendKeys "^{TAB}" 'go to the 2nd tab > > WScript.Sleep 100 > > on error goto 0 > > > WScript.Sleep 2000 > > WScript.Echo > > "***********************************************************" > > > Here I used code as > > oIE.Document.body.innerHTML > > or > > Set oHTML = CreateObject("Microsoft.XMLHTTP") > > oHTML.open "GET" , sURL, True > > > Does anybody have suggestions how to stear between the tabs? > > By the way, I haven't tried this, and I don't have a tabbed IE here > to do so with, but if you click on the different tabs of IE, do you > get a different title in the title bar? If so, it's conceivable > (though > perhaps not likely) that you could activate a specific tab through > AppActivate. Has anyone tried that? I wouldn't want to take bets > on it, but... |