From: Kenneth A. Larsen on

"Kenneth A. Larsen" <LarsenK(a)verizon.net> wrote in message
news:O0YdvzjNLHA.432(a)TK2MSFTNGP02.phx.gbl...
>
> "Kenneth A. Larsen" <LarsenK(a)verizon.net> wrote in message
> news:eOicYUbNLHA.6100(a)TK2MSFTNGP05.phx.gbl...
>>
>> "Kenneth A. Larsen" <kuhlpc#2(a)optimum.net> wrote in message
>> news:eDQjCTbNLHA.1868(a)TK2MSFTNGP05.phx.gbl...
>>>
>>> "MarceepooNu" <mbh2010(a)aol.com> wrote in message
>>> news:B6BDEC51-6359-4BED-9501-B47FA805DF05(a)microsoft.com...
>>>> Thank you. Thank you. Thank you
>>>>
>>>> to all of you, and especially you, Tom, and especically you, Mayayana
>>>> for
>>>> your help on this "project" of mine.
>>>>
>>>> FYI, Here's my version, which incorporates the use of the Hwnd, to
>>>> avoid
>>>> killing the wrong window:
>>>>
>>>>
>>>>
>>>> 'I sometimes use the Sub (shown below) named:
>>>> "subShowInHtmlWindow(strTexte)" to
>>>> ' report the output from a script to an html window.
>>>>
>>>> 'I use variations on this code to send an argument from script A to
>>>> script
>>>> B, and to have Sript A harvest
>>>> ' the output from Script B, and assign the output to a variable, for
>>>> further
>>>> ' computation.
>>>>
>>>> Public blnDataHarvest
>>>> Public g_strWindowHandle
>>>>
>>>> blnDataHarvested = False
>>>>
>>>> strWindowPassThruBodyText = "Harvey: " & Now
>>>> strWindowPassThruTitle = "WindowPassThru"
>>>>
>>>> subShowInHtmlWindow strWindowPassThruBodyText, strWindowPassThruTitle,
>>>> True
>>>> ' False True ' False
>>>> 'subShowInHtmlWindow strWindowPassThruBodyText, strWindowPassThruTitle,
>>>> False ' False True ' False
>>>>
>>>>
>>>> MsgBox "Line 60: The following info was sent to an InternetExplorer Web
>>>> page: " & _
>>>> "strWindowPassThruBodyText = Harvey: " & Now & vbCrLf & _
>>>> vbCrLf & _
>>>> "The follow info was harvested from an InternetExplorer Web page: " & _
>>>> vbCrLf & vbCrLf & fnHarvestGetIEWindowText(strWindowPassThruTitle) & "
>>>> " &
>>>> "Hi"
>>>>
>>>>
>>>>
>>>>
>>>> '* object.Popup Method
>>>> '* ValueDescriptionButtonTypes
>>>> '* 0ShowOKbutton.
>>>> '* 1ShowOKandCancelbuttons.
>>>> '* 2ShowAbort,Retry,andIgnorebuttons.
>>>> '* 3ShowYes,No,andCancelbuttons.
>>>> '* 4ShowYesandNobuttons.
>>>> '* 5ShowRetryandCancelbuttons.
>>>> '*
>>>> '* IconTypesValueDescription
>>>> '* 16Show"StopMark"icon.
>>>> '* 32Show"QuestionMark"icon.
>>>> '* 48Show"ExclamationMark"icon.
>>>> '* 64Show"InformationMark"icon.
>>>> '*
>>>> '* TheprevioustwotablesdonotcoverallvaluesfornType.
>>>> '* Foracompletelist,seetheMicrosoftWin32documentation.
>>>> '*
>>>> '* ThereturnvalueintButtondenotesthenumberofthebuttonthat
>>>> '* theuserclicked.
>>>> '* IftheuserdoesnotclickabuttonbeforenSecondsToWaitseconds,
>>>> '* intButtonissetto-1.
>>>> '*
>>>> '* RetValueDescription
>>>> '* 1OKbutton
>>>> '* 2Cancelbutton
>>>> '* 3Abortbutton
>>>> '* 4Retrybutton
>>>> '* 5Ignorebutton
>>>> '* 6Yesbutton
>>>> '* 7Nobutton
>>>> '*
>>>> '* EXAMPLE
>>>> '* Dim WshShell
>>>> Dim BtnCode
>>>> Set WshShell = WScript.CreateObject("WScript.Shell")
>>>> 'intButton =
>>>> object.Popup(strText,[nSecondsToWait],[strTitle],[nType])
>>>> BtnCode=WshShell.Popup("Do you want to close the 'Pass-Thru-Data
>>>> Window' ?",7,"Option to Close the Pass-Thru-Data Window",4+32)
>>>>
>>>> Select Case BtnCode
>>>> Case 6
>>>> subCloseHiddenWindow
>>>> Case 7
>>>>
>>>> Case -1
>>>> WScript.Echo"Isthereanybodyoutthere?"
>>>> End Select
>>>>
>>>>
>>>> 'subCloseHiddenWindow
>>>>
>>>>
>>>> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>>
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>> '* BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub
>>>> '*'
>>>> BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*'
>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>> Sub subShowInHtmlWindow(strWindowPassThruBodyTexte,
>>>> strWindowPassThruTitlee,
>>>> blnVisibleTFe)
>>>> Dim strText
>>>>
>>>> strWindowPassThruBodyText = strWindowPassThruBodyTexte
>>>> strWindowPassThruTitle = strWindowPassThruTitlee
>>>> blnVisibleTF = blnVisibleTFe
>>>>
>>>> Set objIE = CreateObject("InternetExplorer.Application")
>>>> objIE.Navigate("about:blank")
>>>>
>>>>
>>>>
>>>> g_strWindowHandle = objIE.hwnd
>>>>
>>>> Set objDoc = objIE.Document.Body
>>>> strHTML = strWindowPassThruBodyText
>>>> objDoc.InnerHTML = strHTML
>>>> objIE.Document.Title = strWindowPassThruTitle
>>>> MsgBox "Line 104: " & objIE.document.parentWindow.name
>>>>
>>>> ' While blnDataHarvested = False
>>>> ' fnSleep(1)
>>>> ' Wend
>>>> 'MsgBox strText
>>>>
>>>> 'MsgBox objIE.FullName
>>>> strMsgBoxMsg = objIE.LocationName & vbCrLf & _
>>>> objIE.LocationURL '& vbCrLf & _
>>>> 'objIE.Document(
>>>> 'MsgBox strMsgBoxMsg
>>>> objIE.Visible = blnVisibleTF ' False True ' False
>>>>
>>>> objIE.statusbar = True ' False True ' False
>>>> 'objIE.StatusBar = 0
>>>> objIE.addressbar = True ' False True ' False
>>>> 'objIE.ToolBar = 0
>>>> objIE.ToolBar = False ' False True ' False
>>>> objIE.resizable = True ' False True ' False
>>>> objIE.height = 230
>>>> objIE.width = 400
>>>> 'subAppActivateWindow("Date String")
>>>>
>>>> End Sub 'subShowInHtmlWindow
>>>>
>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>> '* END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub
>>>> '*'
>>>> END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub
>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>>
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>> Function fnHarvestGetIEWindowText(sTitle)
>>>> '
>>>> http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=&cr=&guid=&sloc=en-us&dg=microsoft.public.scripting.vbscript&p=1&tid=80469831-e8b7-47c4-8a16-6ff9a428e901
>>>> ' How to "harvest" the contents of a hidden or "about blank" webpage in
>>>> VBScript .2010.06.28.
>>>> '
>>>> http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_US_8e0bf598-2567-4b0b-8241-d4942bda87dc&lang=en&cr=US
>>>>
>>>> 'MsgBox fnHarvestGetIEWindowText("Date String")
>>>>
>>>> Dim IE, stype
>>>>
>>>> For Each IE In CreateObject("Shell.Application").windows
>>>> sType = typename(IE.document)
>>>> If InStr(1, sType,"htmldocument", vbTextCompare) <> 0 Then
>>>> If instr(1, IE.document.title, sTitle, vbTextCompare) = 1 Then
>>>> 'fnHarvestGetIEWindowText = IE.document.innerText
>>>> fnHarvestGetIEWindowText = IE.document.body.innerText
>>>> Exit Function
>>>> End If
>>>> End If
>>>> Next
>>>>
>>>> End Function ' fnHarvestGetIEWindowText
>>>>
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>> Sub fnSleep(strSeconds) '
>>>> Dim objShell
>>>> Dim strCmd
>>>> set objShell = CreateObject("wscript.Shell")
>>>>
>>>> 'cmdline = "mshta.exe """ & currentDirectory & "child.hta"" """ &
>>>> login.value & """ """ & password.Value & """"
>>>> 'objShell.Run cmdline,1,False
>>>>
>>>> strCmd = "%COMSPEC% /c ping -n " & strSeconds & " 127.0.0.1>nul"
>>>> objShell.Run strCmd,0,1
>>>> End Sub
>>>>
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>> Sub subCloseHiddenWindow
>>>>
>>>> 'http://us.generation-nt.com/answer/get-window-title-pid-help-118380921.html
>>>> ' TODO: Keep looking for a way to get: (1) the PID of the Window,
>>>>
>>>>
>>>> Set sa = CreateObject("Shell.Application")
>>>> Set windows = sa.Windows()
>>>> For Each window in sa.windows
>>>> If left(window.LocationUrl, 5) <> "file:" Then
>>>> 'MsgBox window.hwnd
>>>> ' logic for selecting windows goes here
>>>> If StrComp(window.hwnd, g_strWindowHandle, vbTextCompare) = 0 Then
>>>> If window.locationUrl = "about:blank" Then
>>>> 'TO DO: verify that the window you're closing is the one that
>>>> ' contains the text you just exported to a window.
>>>> 'strWindowContents = window.document.body.innerText
>>>> window.Quit()
>>>> End If
>>>> End If
>>>> End If 'If left(window.LocationUrl, 5) <> "file:" Then
>>>> Next
>>>>
>>>> End Sub '
>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> MarceepooNu
>>>>
>>>>
>>>> "Tom Lavedas" wrote:
>>>>
>>>>> On Jun 29, 8:15 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
>>>>> > On Jun 28, 10:27 pm, MarceepooNu <mbh2...(a)aol.com> wrote:
>>>>> >
>>>>> >
>>>>> >
>>>>> > > Dear Tom:
>>>>> >
>>>>> > > Here's the error message I get when I try to do what you
>>>>> > > suggested:
>>>>> >
>>>>> > > strTitle = "Date String"
>>>>> > > MsgBox GetIEWindowText(strTitle)
>>>>> > > ''''''''''''''''''''''''''''''''''''''''
>>>>> > > Function GetIEWindowText(sTitle)
>>>>> > > Dim IE, stype
>>>>> >
>>>>> > > For Each IE In CreateObject("Shell.Application").windows
>>>>> > > sType = typename(IE.document)
>>>>> > > if instr(sType,"htmldocument", 1, vbTextCompare) <> 0 then
>>>>> >
>>>>> > > ' the next line triggers the following error message:
>>>>> > > 'Column: 1; Error: Object doesn't support this
>>>>> > > property or method:
>>>>> > > 'IE.document.title'
>>>>> > > 'Code: 800A01B6 ; Source: Microsoft VBScript runtime
>>>>> > > error
>>>>> > > if instr(IE.document.title, sTitle, 1, vbTextCompare) = 1
>>>>> > > then
>>>>> > > GetIEWindowText = IE.document.innerText
>>>>> > > exit function
>>>>> > > end if
>>>>> > > end if
>>>>> > > Next
>>>>> >
>>>>> > > end function ' GetIEWindowText
>>>>> >
>>>>> > > I apologize for not being able to find the fix. I spent almost
>>>>> > > two hours
>>>>> > > trying, before I imposed on your time again by asking for more
>>>>> > > help. (I
>>>>> > > mention this so that you won't feel that I'm imposing on your time
>>>>> > > whimsically, i.e., I did try.)
>>>>> >
>>>>> > > 1. When you post the fix, could you include some info about where
>>>>> > > I could
>>>>> > > learn why the solution works?
>>>>> >
>>>>> > > 2. Is there a good book or url you can suggest where I could
>>>>> > > learn more
>>>>> > > about scripting Internet Explorer and how to use the DOM? I find
>>>>> > > IE
>>>>> > > scripting extraordinarily obscure, as compared with
>>>>> > > filesystemobject
>>>>> > > scripting, for which the documentation and tutorials seem much
>>>>> > > more
>>>>> > > accessible .... to me. I don't know where to go to learn that
>>>>> > > stuff.
>>>>> >
>>>>> > > Thanks again,
>>>>> >
>>>>> > > MarceepooNu
>>>>> > > --
>>>>> > > MarceepooNu
>>>>> >
>>>>> > > "Tom Lavedas" wrote:
>>>>> > > > On Jun 28, 2:35 pm, MarceepooNu <mbh2...(a)aol.com> wrote:
>>>>> > > > > I sometimes use the Sub (shown below) named:
>>>>> > > > > "subShowInHtmlWindow(strTexte)"
>>>>> > > > > to
>>>>> > > > > report the output from a script to an html window.
>>>>> >
>>>>> > > > > I'd love to send an argument from script A to script B, and
>>>>> > > > > have Sript A
>>>>> > > > > harvest
>>>>> > > > > the output from Script B, and assign the output to a
>>>>> > > > > variable, for further
>>>>> > > > > computation.
>>>>> >
>>>>> > > > > I came across the Sub (shown below) named:
>>>>> > > > > "subListTheContentsOfaWebPage",
>>>>> > > > > which
>>>>> > > > > would serve as a way to harvest Script B's output, if I
>>>>> > > > > could make Script B
>>>>> > > > > work properly where the Window has a "phony" url, i.e.,
>>>>> > > > > "about:blank"
>>>>> >
>>>>> > > > > If anyone has any ideas about how to "harvest" the contents of
>>>>> > > > > a hidden or
>>>>> > > > > "about blank" webpage, I'd appreciate it very much.
>>>>> >
>>>>> > > > > Thank you for your time, consideration and effort,
>>>>> >
>>>>> > > > > MarceepooNu
>>>>> > > > > {snip}
>>>>> >
>>>>> > > > Try something like this instead ...
>>>>> >
>>>>> > > > Function GetIEWindowText(sTitle)
>>>>> > > > Dim IE, stype
>>>>> >
>>>>> > > > For Each IE In CreateObject("Shell.Application").windows
>>>>> > > > sType = typename(IE.document)
>>>>> > > > if instr(sType,"htmldocument", 1, vbTextCompare) <> 0 then
>>>>> > > > if instr(IE.document.title, sTitle, 1, vbTextCompare) = 1
>>>>> > > > then
>>>>> > > > GetIEWindowText = IE.document.innerText
>>>>> > > > exit function
>>>>> > > > end if
>>>>> > > > end if
>>>>> > > > Next
>>>>> >
>>>>> > > > end function ' GetIEWindowText
>>>>> >
>>>>> > > > Just supply the title of IE window B, as created by Script B and
>>>>> > > > it
>>>>> > > > will return the text found in that window at the time the
>>>>> > > > request is
>>>>> > > > issued. For example, ...
>>>>> >
>>>>> > > > sText_B = GetIEWindowText("about:blank")
>>>>> >
>>>>> > > > It will return the contents of the first window it finds. If
>>>>> > > > the
>>>>> > > > result is empty, the second window was not found. The window
>>>>> > > > does NOT
>>>>> > > > have to be visible.
>>>>> > > > _____________________
>>>>> > > > Tom Lavedas
>>>>> >
>>>>> > Sorry. As Mayayana said, it was 'air code' and the error in the
>>>>> > InStr() syntax is probably the whole problem with the routine. That
>>>>> > is because it causes lines of code that should not be executed to be
>>>>> > executed. Try the correct syntax and see if that fixes the
>>>>> > problem ...
>>>>> >
>>>>> > Function GetIEWindowText(sTitle)
>>>>> > Dim IE, stype
>>>>> >
>>>>> > For Each IE In CreateObject("Shell.Application").windows
>>>>> > sType = typename(IE.document)
>>>>> > if instr(1, sType,"htmldocument", vbTextCompare) <> 0 then
>>>>> > if instr(1, IE.document.title, sTitle, vbTextCompare) = 1 then
>>>>> > GetIEWindowText = IE.document.innerText
>>>>> > exit function
>>>>> > end if
>>>>> > end if
>>>>> > Next
>>>>> >
>>>>> > end function ' GetIEWindowText
>>>>> >
>>>>> > Regarding information on using IE DOM, this is the reference I use,
>>>>> > though it is not particularly tutorial, it is useful,
>>>>> > sometimes:http://msdn.microsoft.com/en-us/library/ms533050(VS.85).aspx
>>>>> > ________________________
>>>>> > Tom Lavedas
>>>>>
>>>>> Sorry, there's still one more error. This line ...
>>>>>
>>>>> GetIEWindowText = IE.document.innerText
>>>>>
>>>>> should read ...
>>>>>
>>>>> GetIEWindowText = IE.document.body.innerText
>>>>> ________________________
>>>>> Tom Lavedas
>>>>> .
>>>>>I admit your command.
>>>
>>>
>>
>>
>
>


From: Kenneth A. Larsen on

"Kenneth A. Larsen" <kuhlpc#2(a)optimum.net> wrote in message
news:enf%23KjwNLHA.5984(a)TK2MSFTNGP06.phx.gbl...
>
> "Kenneth A. Larsen" <LarsenK(a)verizon.net> wrote in message
> news:O0YdvzjNLHA.432(a)TK2MSFTNGP02.phx.gbl...
>>
>> "Kenneth A. Larsen" <LarsenK(a)verizon.net> wrote in message
>> news:eOicYUbNLHA.6100(a)TK2MSFTNGP05.phx.gbl...
>>>
>>> "Kenneth A. Larsen" <kuhlpc#2(a)optimum.net> wrote in message
>>> news:eDQjCTbNLHA.1868(a)TK2MSFTNGP05.phx.gbl...
>>>>
>>>> "MarceepooNu" <mbh2010(a)aol.com> wrote in message
>>>> news:B6BDEC51-6359-4BED-9501-B47FA805DF05(a)microsoft.com...
>>>>> Thank you. Thank you. Thank you
>>>>>
>>>>> to all of you, and especially you, Tom, and especically you,
>>>>> Mayayana for
>>>>> your help on this "project" of mine.
>>>>>
>>>>> FYI, Here's my version, which incorporates the use of the Hwnd, to
>>>>> avoid
>>>>> killing the wrong window:
>>>>>
>>>>>
>>>>>
>>>>> 'I sometimes use the Sub (shown below) named:
>>>>> "subShowInHtmlWindow(strTexte)" to
>>>>> ' report the output from a script to an html window.
>>>>>
>>>>> 'I use variations on this code to send an argument from script A to
>>>>> script
>>>>> B, and to have Sript A harvest
>>>>> ' the output from Script B, and assign the output to a variable, for
>>>>> further
>>>>> ' computation.
>>>>>
>>>>> Public blnDataHarvest
>>>>> Public g_strWindowHandle
>>>>>
>>>>> blnDataHarvested = False
>>>>>
>>>>> strWindowPassThruBodyText = "Harvey: " & Now
>>>>> strWindowPassThruTitle = "WindowPassThru"
>>>>>
>>>>> subShowInHtmlWindow strWindowPassThruBodyText, strWindowPassThruTitle,
>>>>> True
>>>>> ' False True ' False
>>>>> 'subShowInHtmlWindow strWindowPassThruBodyText,
>>>>> strWindowPassThruTitle,
>>>>> False ' False True ' False
>>>>>
>>>>>
>>>>> MsgBox "Line 60: The following info was sent to an InternetExplorer
>>>>> Web
>>>>> page: " & _
>>>>> "strWindowPassThruBodyText = Harvey: " & Now & vbCrLf & _
>>>>> vbCrLf & _
>>>>> "The follow info was harvested from an InternetExplorer Web page: " &
>>>>> _
>>>>> vbCrLf & vbCrLf & fnHarvestGetIEWindowText(strWindowPassThruTitle) & "
>>>>> " &
>>>>> "Hi"
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> '* object.Popup Method
>>>>> '* ValueDescriptionButtonTypes
>>>>> '* 0ShowOKbutton.
>>>>> '* 1ShowOKandCancelbuttons.
>>>>> '* 2ShowAbort,Retry,andIgnorebuttons.
>>>>> '* 3ShowYes,No,andCancelbuttons.
>>>>> '* 4ShowYesandNobuttons.
>>>>> '* 5ShowRetryandCancelbuttons.
>>>>> '*
>>>>> '* IconTypesValueDescription
>>>>> '* 16Show"StopMark"icon.
>>>>> '* 32Show"QuestionMark"icon.
>>>>> '* 48Show"ExclamationMark"icon.
>>>>> '* 64Show"InformationMark"icon.
>>>>> '*
>>>>> '* TheprevioustwotablesdonotcoverallvaluesfornType.
>>>>> '* Foracompletelist,seetheMicrosoftWin32documentation.
>>>>> '*
>>>>> '* ThereturnvalueintButtondenotesthenumberofthebuttonthat
>>>>> '* theuserclicked.
>>>>> '* IftheuserdoesnotclickabuttonbeforenSecondsToWaitseconds,
>>>>> '* intButtonissetto-1.
>>>>> '*
>>>>> '* RetValueDescription
>>>>> '* 1OKbutton
>>>>> '* 2Cancelbutton
>>>>> '* 3Abortbutton
>>>>> '* 4Retrybutton
>>>>> '* 5Ignorebutton
>>>>> '* 6Yesbutton
>>>>> '* 7Nobutton
>>>>> '*
>>>>> '* EXAMPLE
>>>>> '* Dim WshShell
>>>>> Dim BtnCode
>>>>> Set WshShell = WScript.CreateObject("WScript.Shell")
>>>>> 'intButton =
>>>>> object.Popup(strText,[nSecondsToWait],[strTitle],[nType])
>>>>> BtnCode=WshShell.Popup("Do you want to close the 'Pass-Thru-Data
>>>>> Window' ?",7,"Option to Close the Pass-Thru-Data Window",4+32)
>>>>>
>>>>> Select Case BtnCode
>>>>> Case 6
>>>>> subCloseHiddenWindow
>>>>> Case 7
>>>>>
>>>>> Case -1
>>>>> WScript.Echo"Isthereanybodyoutthere?"
>>>>> End Select
>>>>>
>>>>>
>>>>> 'subCloseHiddenWindow
>>>>>
>>>>>
>>>>> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>>
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>> '* BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub
>>>>> '*'
>>>>> BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*' BEGIN_Sub '*'
>>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>> Sub subShowInHtmlWindow(strWindowPassThruBodyTexte,
>>>>> strWindowPassThruTitlee,
>>>>> blnVisibleTFe)
>>>>> Dim strText
>>>>>
>>>>> strWindowPassThruBodyText = strWindowPassThruBodyTexte
>>>>> strWindowPassThruTitle = strWindowPassThruTitlee
>>>>> blnVisibleTF = blnVisibleTFe
>>>>>
>>>>> Set objIE = CreateObject("InternetExplorer.Application")
>>>>> objIE.Navigate("about:blank")
>>>>>
>>>>>
>>>>>
>>>>> g_strWindowHandle = objIE.hwnd
>>>>>
>>>>> Set objDoc = objIE.Document.Body
>>>>> strHTML = strWindowPassThruBodyText
>>>>> objDoc.InnerHTML = strHTML
>>>>> objIE.Document.Title = strWindowPassThruTitle
>>>>> MsgBox "Line 104: " & objIE.document.parentWindow.name
>>>>>
>>>>> ' While blnDataHarvested = False
>>>>> ' fnSleep(1)
>>>>> ' Wend
>>>>> 'MsgBox strText
>>>>>
>>>>> 'MsgBox objIE.FullName
>>>>> strMsgBoxMsg = objIE.LocationName & vbCrLf & _
>>>>> objIE.LocationURL '& vbCrLf & _
>>>>> 'objIE.Document(
>>>>> 'MsgBox strMsgBoxMsg
>>>>> objIE.Visible = blnVisibleTF ' False True ' False
>>>>>
>>>>> objIE.statusbar = True ' False True ' False
>>>>> 'objIE.StatusBar = 0
>>>>> objIE.addressbar = True ' False True ' False
>>>>> 'objIE.ToolBar = 0
>>>>> objIE.ToolBar = False ' False True ' False
>>>>> objIE.resizable = True ' False True ' False
>>>>> objIE.height = 230
>>>>> objIE.width = 400
>>>>> 'subAppActivateWindow("Date String")
>>>>>
>>>>> End Sub 'subShowInHtmlWindow
>>>>>
>>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>> '* END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub
>>>>> '*'
>>>>> END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub '*' END_Sub
>>>>> '*''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>>
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>> Function fnHarvestGetIEWindowText(sTitle)
>>>>> '
>>>>> http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?&lang=&cr=&guid=&sloc=en-us&dg=microsoft.public.scripting.vbscript&p=1&tid=80469831-e8b7-47c4-8a16-6ff9a428e901
>>>>> ' How to "harvest" the contents of a hidden or "about blank" webpage
>>>>> in
>>>>> VBScript .2010.06.28.
>>>>> '
>>>>> http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.scripting.vbscript&cat=en_US_8e0bf598-2567-4b0b-8241-d4942bda87dc&lang=en&cr=US
>>>>>
>>>>> 'MsgBox fnHarvestGetIEWindowText("Date String")
>>>>>
>>>>> Dim IE, stype
>>>>>
>>>>> For Each IE In CreateObject("Shell.Application").windows
>>>>> sType = typename(IE.document)
>>>>> If InStr(1, sType,"htmldocument", vbTextCompare) <> 0 Then
>>>>> If instr(1, IE.document.title, sTitle, vbTextCompare) = 1 Then
>>>>> 'fnHarvestGetIEWindowText = IE.document.innerText
>>>>> fnHarvestGetIEWindowText = IE.document.body.innerText
>>>>> Exit Function
>>>>> End If
>>>>> End If
>>>>> Next
>>>>>
>>>>> End Function ' fnHarvestGetIEWindowText
>>>>>
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>> Sub fnSleep(strSeconds) '
>>>>> Dim objShell
>>>>> Dim strCmd
>>>>> set objShell = CreateObject("wscript.Shell")
>>>>>
>>>>> 'cmdline = "mshta.exe """ & currentDirectory & "child.hta"" """ &
>>>>> login.value & """ """ & password.Value & """"
>>>>> 'objShell.Run cmdline,1,False
>>>>>
>>>>> strCmd = "%COMSPEC% /c ping -n " & strSeconds & " 127.0.0.1>nul"
>>>>> objShell.Run strCmd,0,1
>>>>> End Sub
>>>>>
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>> Sub subCloseHiddenWindow
>>>>>
>>>>> 'http://us.generation-nt.com/answer/get-window-title-pid-help-118380921.html
>>>>> ' TODO: Keep looking for a way to get: (1) the PID of the Window,
>>>>>
>>>>>
>>>>> Set sa = CreateObject("Shell.Application")
>>>>> Set windows = sa.Windows()
>>>>> For Each window in sa.windows
>>>>> If left(window.LocationUrl, 5) <> "file:" Then
>>>>> 'MsgBox window.hwnd
>>>>> ' logic for selecting windows goes here
>>>>> If StrComp(window.hwnd, g_strWindowHandle, vbTextCompare) = 0 Then
>>>>> If window.locationUrl = "about:blank" Then
>>>>> 'TO DO: verify that the window you're closing is the one that
>>>>> ' contains the text you just exported to a window.
>>>>> 'strWindowContents = window.document.body.innerText
>>>>> window.Quit()
>>>>> End If
>>>>> End If
>>>>> End If 'If left(window.LocationUrl, 5) <> "file:" Then
>>>>> Next
>>>>>
>>>>> End Sub '
>>>>> '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> MarceepooNu
>>>>>
>>>>>
>>>>> "Tom Lavedas" wrote:
>>>>>
>>>>>> On Jun 29, 8:15 am, Tom Lavedas <tglba...(a)verizon.net> wrote:
>>>>>> > On Jun 28, 10:27 pm, MarceepooNu <mbh2...(a)aol.com> wrote:
>>>>>> >
>>>>>> >
>>>>>> >
>>>>>> > > Dear Tom:
>>>>>> >
>>>>>> > > Here's the error message I get when I try to do what you
>>>>>> > > suggested:
>>>>>> >
>>>>>> > > strTitle = "Date String"
>>>>>> > > MsgBox GetIEWindowText(strTitle)
>>>>>> > > ''''''''''''''''''''''''''''''''''''''''
>>>>>> > > Function GetIEWindowText(sTitle)
>>>>>> > > Dim IE, stype
>>>>>> >
>>>>>> > > For Each IE In CreateObject("Shell.Application").windows
>>>>>> > > sType = typename(IE.document)
>>>>>> > > if instr(sType,"htmldocument", 1, vbTextCompare) <> 0 then
>>>>>> >
>>>>>> > > ' the next line triggers the following error message:
>>>>>> > > 'Column: 1; Error: Object doesn't support this
>>>>>> > > property or method:
>>>>>> > > 'IE.document.title'
>>>>>> > > 'Code: 800A01B6 ; Source: Microsoft VBScript
>>>>>> > > runtime error
>>>>>> > > if instr(IE.document.title, sTitle, 1, vbTextCompare) = 1
>>>>>> > > then
>>>>>> > > GetIEWindowText = IE.document.innerText
>>>>>> > > exit function
>>>>>> > > end if
>>>>>> > > end if
>>>>>> > > Next
>>>>>> >
>>>>>> > > end function ' GetIEWindowText
>>>>>> >
>>>>>> > > I apologize for not being able to find the fix. I spent almost
>>>>>> > > two hours
>>>>>> > > trying, before I imposed on your time again by asking for more
>>>>>> > > help. (I
>>>>>> > > mention this so that you won't feel that I'm imposing on your
>>>>>> > > time
>>>>>> > > whimsically, i.e., I did try.)
>>>>>> >
>>>>>> > > 1. When you post the fix, could you include some info about
>>>>>> > > where I could
>>>>>> > > learn why the solution works?
>>>>>> >
>>>>>> > > 2. Is there a good book or url you can suggest where I could
>>>>>> > > learn more
>>>>>> > > about scripting Internet Explorer and how to use the DOM? I find
>>>>>> > > IE
>>>>>> > > scripting extraordinarily obscure, as compared with
>>>>>> > > filesystemobject
>>>>>> > > scripting, for which the documentation and tutorials seem much
>>>>>> > > more
>>>>>> > > accessible .... to me. I don't know where to go to learn that
>>>>>> > > stuff.
>>>>>> >
>>>>>> > > Thanks again,
>>>>>> >
>>>>>> > > MarceepooNu
>>>>>> > > --
>>>>>> > > MarceepooNu
>>>>>> >
>>>>>> > > "Tom Lavedas" wrote:
>>>>>> > > > On Jun 28, 2:35 pm, MarceepooNu <mbh2...(a)aol.com> wrote:
>>>>>> > > > > I sometimes use the Sub (shown below) named:
>>>>>> > > > > "subShowInHtmlWindow(strTexte)"
>>>>>> > > > > to
>>>>>> > > > > report the output from a script to an html window.
>>>>>> >
>>>>>> > > > > I'd love to send an argument from script A to script B, and
>>>>>> > > > > have Sript A
>>>>>> > > > > harvest
>>>>>> > > > > the output from Script B, and assign the output to a
>>>>>> > > > > variable, for further
>>>>>> > > > > computation.
>>>>>> >
>>>>>> > > > > I came across the Sub (shown below) named:
>>>>>> > > > > "subListTheContentsOfaWebPage",
>>>>>> > > > > which
>>>>>> > > > > would serve as a way to harvest Script B's output, if I
>>>>>> > > > > could make Script B
>>>>>> > > > > work properly where the Window has a "phony" url, i.e.,
>>>>>> > > > > "about:blank"
>>>>>> >
>>>>>> > > > > If anyone has any ideas about how to "harvest" the contents
>>>>>> > > > > of a hidden or
>>>>>> > > > > "about blank" webpage, I'd appreciate it very much.
>>>>>> >
>>>>>> > > > > Thank you for your time, consideration and effort,
>>>>>> >
>>>>>> > > > > MarceepooNu
>>>>>> > > > > {snip}
>>>>>> >
>>>>>> > > > Try something like this instead ...
>>>>>> >
>>>>>> > > > Function GetIEWindowText(sTitle)
>>>>>> > > > Dim IE, stype
>>>>>> >
>>>>>> > > > For Each IE In CreateObject("Shell.Application").windows
>>>>>> > > > sType = typename(IE.document)
>>>>>> > > > if instr(sType,"htmldocument", 1, vbTextCompare) <> 0 then
>>>>>> > > > if instr(IE.document.title, sTitle, 1, vbTextCompare) = 1
>>>>>> > > > then
>>>>>> > > > GetIEWindowText = IE.document.innerText
>>>>>> > > > exit function
>>>>>> > > > end if
>>>>>> > > > end if
>>>>>> > > > Next
>>>>>> >
>>>>>> > > > end function ' GetIEWindowText
>>>>>> >
>>>>>> > > > Just supply the title of IE window B, as created by Script B
>>>>>> > > > and it
>>>>>> > > > will return the text found in that window at the time the
>>>>>> > > > request is
>>>>>> > > > issued. For example, ...
>>>>>> >
>>>>>> > > > sText_B = GetIEWindowText("about:blank")
>>>>>> >
>>>>>> > > > It will return the contents of the first window it finds. If
>>>>>> > > > the
>>>>>> > > > result is empty, the second window was not found. The window
>>>>>> > > > does NOT
>>>>>> > > > have to be visible.
>>>>>> > > > _____________________
>>>>>> > > > Tom Lavedas
>>>>>> >
>>>>>> > Sorry. As Mayayana said, it was 'air code' and the error in the
>>>>>> > InStr() syntax is probably the whole problem with the routine.
>>>>>> > That
>>>>>> > is because it causes lines of code that should not be executed to
>>>>>> > be
>>>>>> > executed. Try the correct syntax and see if that fixes the
>>>>>> > problem ...
>>>>>> >
>>>>>> > Function GetIEWindowText(sTitle)
>>>>>> > Dim IE, stype
>>>>>> >
>>>>>> > For Each IE In CreateObject("Shell.Application").windows
>>>>>> > sType = typename(IE.document)
>>>>>> > if instr(1, sType,"htmldocument", vbTextCompare) <> 0 then
>>>>>> > if instr(1, IE.document.title, sTitle, vbTextCompare) = 1
>>>>>> > then
>>>>>> > GetIEWindowText = IE.document.innerText
>>>>>> > exit function
>>>>>> > end if
>>>>>> > end if
>>>>>> > Next
>>>>>> >
>>>>>> > end function ' GetIEWindowText
>>>>>> >
>>>>>> > Regarding information on using IE DOM, this is the reference I use,
>>>>>> > though it is not particularly tutorial, it is useful,
>>>>>> > sometimes:http://msdn.microsoft.com/en-us/library/ms533050(VS.85).aspx
>>>>>> > ________________________
>>>>>> > Tom Lavedas
>>>>>>
>>>>>> Sorry, there's still one more error. This line ...
>>>>>>
>>>>>> GetIEWindowText = IE.document.innerText
>>>>>>
>>>>>> should read ...
>>>>>>
>>>>>> GetIEWindowText = IE.document.body.innerText
>>>>>> ________________________
>>>>>> Tom Lavedas
>>>>>> .
>>>>>>I admit your command.
>>>>
>>>>
>>>
>>>
>>
>>
>
>