dcsimg
Results 1 to 2 of 2

Thread: Converting VBscript to use Chrome instead of IE

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2019
    Posts
    1

    Question Converting VBscript to use Chrome instead of IE

    I should start by saying I am very Novice in VB. I wrote the following script while gathering code from many forums on each step and compiling them together until I accomplished what I wanted to do. In short the script opens IE and gets the innerhtml and then manipulates it to get a few strings I am after and puts those strings in a file.

    It currently works perfectly, but I will be losing compatibility with IE browsers in the very near future. Thus I would like to accomplish the same thing in chrome. From everything I have read, it doesn't seem to be possible with VB, but I wanted to check here and get others opinions before making any drastic changes. If it can't be done I would greatly appreciate someone pointing me in the right direction on how I can accomplish it even if in another language.

    I am sure the code could probably be improved, but for not knowing what I was doing it works fine

    Code:
    'File Settings
    path = "Z:\Box\schedule.txt"
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(path, 8, true)
    Set ie = createobject("internetexplorer.application") 
    Set objShell = CreateObject("WScript.Shell")
    Dim data1 : Dim data2
    
    'Get Schedule
    Call GetSchedule
    pos1 = InStr(1,data1,"ThisDay-day-")
    pos2 = InStr(pos1+1,data1,"ThisDay-day-")
    pos3 = InStr(pos2+1,data1,"ThisDay-day-")
    pos4 = InStr(pos3+1,data1,"ThisDay-day-")
    wlength = pos4 - pos3
    If pos3 = 0 then
    	objFile.WriteLine "ErrorPos3"
    	Call EndVBS
    End If
    data2 = mid(data1,pos3+0,wlength+0)
    thisPos1 = InStr(1,data2,"title=")
    thisPos2 = InStr(thisPos1+1,data2,"title=")
    thisPos3 = InStr(thisPos2+1,data2,"title=")
    thisPos4 = InStr(thisPos3+1,data2,"title=")
    thisPos5 = InStr(thisPos4+1,data2,"title=")
    thisPos6 = InStr(thisPos5+1,data2,"title=")
    thisPos7 = InStr(thisPos6+1,data2,"title=")
    thisPos8 = InStr(thisPos7+1,data2,"title=")
    showlg = 250
    ' Get all schedules - never more than 8
    If thisPos1 > 0 then
    	sched = mid(data2,thisPos1+0,showlg+0)
    	'objFile.WriteLine "Scheduled Recordings:"
    	Call StripName
    Else
    	'objFile.WriteLine "No Scheduled Recordings Today"
    	Call EndVBS
    End If
    If thisPos2 > 0 then
    	sched = mid(data2,thisPos2+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    If thisPos3 > 0 then
    	sched = mid(data2,thisPos3+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    If thisPos4 > 0 then
    	sched = mid(data2,thisPos4+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    If thisPos5 > 0 then
    	sched = mid(data2,thisPos5+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    If thisPos6 > 0 then
    	sched = mid(data2,thisPos6+0,showlg+0)
    	StripName
    Else
    	Call EndVBS
    End If
    If thisPos7 > 0 then
    	sched = mid(data2,thisPos7+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    If thisPos8 > 0 then
    	sched = mid(data2,thisPos8+0,showlg+0)
    	Call StripName
    Else
    	Call EndVBS
    End If
    objFile.WriteLine "ErrorPos9"
    objFile.Close 
    WScript.Quit
    
    Sub GetSchedule
    wscript.sleep 2000
    ie.Visible = true
    URL = "http://127.0.0.1:99999/web/schedule" 
    ie.navigate URL
    'wait until URL loads
    do while ie.busy: wscript.sleep 100: loop
    While ie.Busy: Wscript.Sleep 100: Wend
    While ie.ReadyState <> 4: Wscript.Sleep 100: Wend
    While ie.document.readystate <> "complete": wscript.sleep 100: Wend
    'reposition and make sure window is full screen
    ie.top = 0 : ie.left = 0 : ie.width = 1920 : ie.height = 1080
    wscript.sleep 5000 'Extra sleep to make sure loaded
    data1 = ie.document.body.innerhtml
    ie.quit
    End Sub
    
    Sub StripName
    thisPosa = InStr(1,sched,">")
    thisPosb = InStr(1,sched,"<")
    thisPosl = thisPosb - thisPosa
    sched = mid(sched,thisPosa+1,thisPosl-1)
    objFile.WriteLine sched
    End Sub
    
    Sub EndVBS
    objFile.Close
    WScript.Quit
    End Sub
    Thanks for any help,
    Don

  2. #2
    Frenzied Member jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    1,378

    Re: Converting VBscript to use Chrome instead of IE


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width