From: Paul Randall on 21 Apr 2010 09:31 "at" <at(a)noemail.fr> wrote in message news:4bceabef$0$2973$ba4acef3(a)reader.news.orange.fr... > Paul Randall a exprim� avec pr�cision : >> "at" <at(a)noemail.fr> wrote in message >> news:4bce14a2$0$2946$ba4acef3(a)reader.news.orange.fr... >>> Paul Randall a expos� le 20/04/2010 : >>> >>>> I don't know how to get the JScript array directly transferred to a >>>> VBScript array. I would have my standalone VBScript load the HTML file >>>> in an IE object and use the DOM to get at what I want. Of course, >>>> sometimes you can't get directly to the web page that you are >>>> interested in, so you may have to set up a way to pause your script >>>> while you manually navigate, in the script's IE window, to the page of >>>> interest, and then have the script do its thing of getting the info of >>>> interest. A message box works fine for pausing the script, and when you >>>> continue the script by clicking OK on the message box, you will want to >>>> get the current IE document with something like Set oIEDoc = >>>> oIE.Document. >>>> >>>> One fairly quick way to learn about how to manipulate many of the >>>> features of the HTML DOM is to study a Microsoft HTA that can be used >>>> to build other HTAs, called HTA Helpomatic. All of its scripting is >>>> VBScript. HTAs use objects identical to those in HTML. Download it >>>> here: >>>> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=231d8143-f21b-4707-b583-ae7b9152e6d9 >>>> >>>> The URL is long, so you may have to unwrap it. >>>> -Paul Randall >>> >>> In the web page, i found this: >>> >>> ... >>> var dhcp_data = new Array(); >>> dhcp_data[0] = new Array(find_userfriendlyname(js_host_list, >>> '00:a0:aa:aa:1a:a0'), '192.168.1.18', '00:9a:da:aa:18:a0', null, null); >>> dhcp_data[1] = new Array(find_userfriendlyname(js_host_list, >>> '00:0e:ee:de:eb:e9'), '192.168.1.19', '00:aa:e4:d7:3b:a9', null, null); >>> ... >>> >>> >>> I try to read value in dhcp_data[1] with vbscript after load document >>> with >>> >>> Set ie = CreateObject("InternetExplorer.Application") >>> ie.navigate "http://www.example_page.com" >>> ... >>> >>> >>> it's possible ? >> >> Here is an HTA example using Evertjan's method: >> >> <html> >> <head> >> <title>JS Array to VBS array</title> >> <script language="vbscript"> >> 'Putting this script here prepositions the window. >> 'Windowstate=Maximize would override this. >> Const wdDlg = 600, htDlg = 380 ' dialog size >> Const pxLeft = 100, pxTop = 100 ' positioning >> window.ResizeTo wdDlg,htDlg >> window.MoveTo pxLeft,pxTop >> </SCRIPT> >> <HTA:APPLICATION >> ID="Put your ID here" >> APPLICATIONNAME="Put your application name here" >> SCROLL="yes" >> SINGLEINSTANCE="no" >> WINDOWSTATE="" >>> >> </head> >> >> <SCRIPT Language="JScript"> >> var a, b; >> a = new Array(0,1,2,3,4); >> b = a.join("-"); >> >> </SCRIPT> >> >> <SCRIPT Language="VBScript"> >> msgbox b >> myArray = split(b,"-") >> msgbox join(myarray, vbcrlf) >> </SCRIPT> >> <body> >> </body> >> </html> > > But you place the VBscript in web page! I want found the array value with > an external script. > > And the web page contain: > > var dhcp_data = new Array(); > dhcp_data[0] = new Array(find_userfriendlyname(js_host_list, > '00:a0:aa:aa:1a:a0'), '192.168.1.18', '00:9a:da:aa:18:a0', null, null); > dhcp_data[1] = new Array(find_userfriendlyname(js_host_list, > '00:0e:ee:de:eb:e9'), '192.168.1.19', '00:aa:e4:d7:3b:a9', null, null); > > and i try to view value in dhcp_data[1] with the Vbscript launch from > windows, not in the web page. > > With another example with a internet web page: > > > <html> > > <script type='text/javascript'>var js_mbv_dhcpserverenabled = '1';var > js_mbv_ipinterfaceipaddress = '192.168.1.1'; > > </script> > > <body> > > <form method="POST" action="bot"> > > <p><input type="text" name="lacase" size="20" value="hello"><input > type="submit" value="Send" name="B1"><input type="reset" value="Cancel" > name="B2"></p> > > </form> > > </body> > </html> > > > > Now,i can view value "lacase" with a Windows VBScript > > > ' VBSCRIPT ------------------ > Set objShell = WScript.CreateObject("WScript.Shell" ) > Set ie = CreateObject("InternetExplorer.Application") > ie.navigate "d:\example.htm" > msgbox ie.document.All.tags("input").Item("lacase").Value > ' -------------------------------- > > Now, how to retrieve value in "js_mbv_ipinterfaceipaddress" ? > > Regard. OK, now I think I understand your question. You know how to get properties of objects that are exposed by the DHTML DOM, and you are asking whether the DOM exposes the values of variables used within scripts. I'm thinking the answer is no, you can't get them. Hopefully someone will prove me wrong and post an example that does it. The docs: http://msdn.microsoft.com/en-us/library/ms535892(v=VS.85).aspx don't mention variables used in the script. It does mention that you can get info about the script, including its namespace with something like this: msgbox ie.document.All.tags("script").item(0).text msgbox ie.document.All.tags("script").Item(0).uniqueID msgbox ie.document.All.tags("script").item(0).text msgbox ie.document.All.tags("script").Item(0).scopeName but I don't know how to get a list of the items in that namespace. -Paul Randall
From: at on 21 Apr 2010 10:43 Paul Randall a �mis l'id�e suivante : > OK, now I think I understand your question. You know how to get properties > of objects that are exposed by the DHTML DOM, and you are asking whether the > DOM exposes the values of variables used within scripts. > > I'm thinking the answer is no, you can't get them. Hopefully someone will > prove me wrong and post an example that does it. > > The docs: http://msdn.microsoft.com/en-us/library/ms535892(v=VS.85).aspx > don't mention variables used in the script. It does mention that you can get > info about the script, including its namespace with something like this: > msgbox ie.document.All.tags("script").item(0).text > msgbox ie.document.All.tags("script").Item(0).uniqueID > msgbox ie.document.All.tags("script").item(0).text > msgbox ie.document.All.tags("script").Item(0).scopeName > but I don't know how to get a list of the items in that namespace. > > -Paul Randall For now, this is a good tips, thx.
From: Tom Lavedas on 21 Apr 2010 11:31 On Apr 21, 9:14 am, at <a...(a)noemail.fr> wrote: > Tom Lavedas a utilisé son clavier pour écrire : > > > Try something like this ... > > > Set objShell = WScript.CreateObject("WScript.Shell" ) > > Set ie = CreateObject("InternetExplorer.Application") > > ie.navigate "d:\example.htm" > > wsh.echo ie.document.parentWindow.js_mbv_ipinterfaceipaddress > > > I think the same approach will access the array variable, but I'm not > > certain whether JScript arrays are compatible with VBScript. Try > > something like this ... > > > wsh.echo Join(ie.document.parentWindow.dhcp_data, vbCRLF) > > Thx, i try it, but not work. Regard. I tested this and it worked fine with the second example you posted ... Set ie = CreateObject("InternetExplorer.Application") ie.navigate "d:\example.html" do until ie.readystate = 4: wsh.sleep 100 : loop wsh.echo ie.document.parentWindow.js_mbv_ipinterfaceipaddress ie.document.parentWindow.opener = "Me" ie.document.parentWindow.close This same approach also worked for connecting to the dhcp_data variable in your first example, but as I expected, JScript arrays are a problem in VBS. From a quick search, I found that JScript arrays are *objects* and need to be treated as such. They are NOT directly usable as VBS arrays. I did not find an example of a way to convert an arbitrary JS array into a VBS array. Most of the examples I found modified the JS array and wrote JS functions to provide indexing into the JS array so it could be converted to a VBS array, element by element. Your problem is even more complex in that your target variable is an array of arrays. Good luck. This problem is beyond my skills. - Maybe a rewrite of your VBS script into JS is the way to go. _____________________ Tom Lavedas
From: at on 21 Apr 2010 12:10 Tom Lavedas avait pr�tendu : > I tested this and it worked fine with the second example you > posted ... > > Set ie = CreateObject("InternetExplorer.Application") > ie.navigate "d:\example.html" > do until ie.readystate = 4: wsh.sleep 100 : loop > wsh.echo ie.document.parentWindow.js_mbv_ipinterfaceipaddress > ie.document.parentWindow.opener = "Me" > ie.document.parentWindow.close Yes it's Work! I have add ie.visible=true and found the problem: iexplore lock script and answer for unlock... > This same approach also worked for connecting to the dhcp_data > variable in your first example, but as I expected, JScript arrays are > a problem in VBS. From a quick search, I found that JScript arrays > are *objects* and need to be treated as such. They are NOT directly > usable as VBS arrays. I did not find an example of a way to convert > an arbitrary JS array into a VBS array. Most of the examples I found > modified the JS array and wrote JS functions to provide indexing into > the JS array so it could be converted to a VBS array, element by > element. Your problem is even more complex in that your target > variable is an array of arrays. Good luck. This problem is beyond my > skills. - Maybe a rewrite of your VBS script into JS is the way to go. > _____________________ > Tom Lavedas Very good help, thanks.
From: Paul Randall on 21 Apr 2010 15:42 "Tom Lavedas" <tglbatch(a)verizon.net> wrote in message news:f7f1e9e1-7e8f-494f-a36e-d938c01f35db(a)n5g2000yqh.googlegroups.com... On Apr 21, 9:14 am, at <a...(a)noemail.fr> wrote: > Tom Lavedas a utilis� son clavier pour �crire : > > > Try something like this ... > > > Set objShell = WScript.CreateObject("WScript.Shell" ) > > Set ie = CreateObject("InternetExplorer.Application") > > ie.navigate "d:\example.htm" > > wsh.echo ie.document.parentWindow.js_mbv_ipinterfaceipaddress > > > I think the same approach will access the array variable, but I'm not > > certain whether JScript arrays are compatible with VBScript. Try > > something like this ... > > > wsh.echo Join(ie.document.parentWindow.dhcp_data, vbCRLF) > > Thx, i try it, but not work. Regard. I tested this and it worked fine with the second example you posted ... Set ie = CreateObject("InternetExplorer.Application") ie.navigate "d:\example.html" do until ie.readystate = 4: wsh.sleep 100 : loop wsh.echo ie.document.parentWindow.js_mbv_ipinterfaceipaddress ie.document.parentWindow.opener = "Me" ie.document.parentWindow.close This same approach also worked for connecting to the dhcp_data variable in your first example, but as I expected, JScript arrays are a problem in VBS. From a quick search, I found that JScript arrays are *objects* and need to be treated as such. They are NOT directly usable as VBS arrays. I did not find an example of a way to convert an arbitrary JS array into a VBS array. Most of the examples I found modified the JS array and wrote JS functions to provide indexing into the JS array so it could be converted to a VBS array, element by element. Your problem is even more complex in that your target variable is an array of arrays. Good luck. This problem is beyond my skills. - Maybe a rewrite of your VBS script into JS is the way to go. _____________________ Tom Lavedas Hi, Tom I tried your script and get this: Script: G:\VBScript\JS-VB-Array\Test2.vbs Line: 4 Char: 1 Error: Object doesn't support this property or method: 'ie.document.parentWindow.js_mbv_ipinterfaceipaddress' Code: 800A01B6 Source: Microsoft VBScript runtime error Same error with ie.visible true or false. Is it perhaps a security level setting that is the problem? I'm running IE6 on WXP SP2. -Paul Randall
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Is scripting what I need? Next: VBScript to get header info from FLV (flash video) files |