Home All Groups Group Topic Archive Search About
Author
21 Oct 2005 12:21 PM
Peter Newman
and if so how?

Im running VB6 (SP6) on Windows XP Pro. I have an application that opens an
Internet web page . Is it possible to send information to that webpage say
for instance to click a button or fill out info in  a text box ?

Const SMTO_BLOCK = &H1
Const SMTO_ABORTIFHUNG = &H2
Const WM_NULL = &H0

Public Declare Function SendMessageTimeout Lib "user32" Alias
"SendMessageTimeoutA" _
(ByVal hwnd As Long, ByVal msg As Long, ByVal Wparm As Long, lParm As Long, _
ByVal fuflags As Long, ByVal uTimout As Long, lpdwResult As Long) As Long

Public objIE As Object
Public lngRetVal As Long

Public Sub OpenIEWindow()
Dim lngResult As Long
Dim WndResponse As Boolean
' Create the Object
Set objIE = CreateObject("InternetExplorer.Application")
' Set the properties
objIE.Visible = True
objIE.Navigate2 "http://www.google.co.uk"

DoEvents
  ' Get the object Handle
lngIEHandle = objIE.hwnd
   Debug.Print "Window Handle " & CStr(lngIEHandle)

' Get return value
lngRetVal = SendMessageTimeout(lngIEHandle, WM_NULL, 0&, 0&,
SMTO_ABORTIFHUNG And SMTO_BLOCK, 1000, lngResult)


' Check return if browser is responding
     WndResponse = CheckWindow(lngIEHandle)
End Sub

Author
21 Oct 2005 3:49 PM
Matt Williamson
Peter-

You'll want to send post data directly to the page. I'd use Wininet api but
the internet control or winsock will get you there too.

HTH

Matt

Show quoteHide quote
"Peter Newman" <PeterNew***@discussions.microsoft.com> wrote in message
news:2A58BDA8-8CDD-4A23-87E8-539398666AC5@microsoft.com...
> and if so how?
>
> Im running VB6 (SP6) on Windows XP Pro. I have an application that opens
> an
> Internet web page . Is it possible to send information to that webpage say
> for instance to click a button or fill out info in  a text box ?
>
> Const SMTO_BLOCK = &H1
> Const SMTO_ABORTIFHUNG = &H2
> Const WM_NULL = &H0
>
> Public Declare Function SendMessageTimeout Lib "user32" Alias
> "SendMessageTimeoutA" _
> (ByVal hwnd As Long, ByVal msg As Long, ByVal Wparm As Long, lParm As
> Long, _
> ByVal fuflags As Long, ByVal uTimout As Long, lpdwResult As Long) As Long
>
> Public objIE As Object
> Public lngRetVal As Long
>
> Public Sub OpenIEWindow()
> Dim lngResult As Long
> Dim WndResponse As Boolean
> ' Create the Object
> Set objIE = CreateObject("InternetExplorer.Application")
> ' Set the properties
> objIE.Visible = True
> objIE.Navigate2 "http://www.google.co.uk"
>
> DoEvents
>  ' Get the object Handle
> lngIEHandle = objIE.hwnd
>   Debug.Print "Window Handle " & CStr(lngIEHandle)
>
> ' Get return value
> lngRetVal = SendMessageTimeout(lngIEHandle, WM_NULL, 0&, 0&,
> SMTO_ABORTIFHUNG And SMTO_BLOCK, 1000, lngResult)
>
>
> ' Check return if browser is responding
>     WndResponse = CheckWindow(lngIEHandle)
> End Sub
>
Author
22 Oct 2005 1:04 AM
Larry Serflaten
"Peter Newman" <PeterNew***@discussions.microsoft.com> wrote
> and if so how?

It is somethime possible to simulate by crafting a specific URL.  For example,
This URL adds these VB groups to the appropreate box at Google's search
page:

http://groups-beta.google.com/advanced_search?q=group:microsoft.public.vb.*&scoring=r&num=50&

Now if you type in "WithEvents InternetExplorer" into the top box, you get
taken to this URL:

http://groups.google.com/groups?as_q=WithEvents+InternetExplorer&num=50&scoring=r&hl=en&as_epq=&as_oq=&as_eq=&as_ugroup=microsoft.public.vb.*&as_usubject=&as_uauthors=&lr=&as_drrb=q&as_qdr=&as_mind=1&as_minm=1&as_miny=1981&as_maxd=21&as_maxm=10&as_maxy=2005&safe=off

So that URL is the same as you would get, if you went to google, typed in
the text, and pressed the button, is it not?

Also, check out a few of the replies from that second link, some of them
show how you can catch events from IE, while others show how you can
access objects on the page....

HTH
LFS
Author
22 Oct 2005 2:02 AM
Someone
Yes it is, through automation, not by using SendMessage which may not get
you anywhere. You can't find the hWnd for a text box inside a web page and
use WM_SETTEXT to set its value. Add "Microsoft Internet Controls" and
"Microsoft HTML Object Library" reference to your project and use that to
loop access the objects in the web page. Example:

Dim WithEvents ie As InternetExplorer
Dim oHTML As IHTMLDocument2

Private Sub Command1_Click()
    ie.Visible = True
    ie.Navigate "http://ww.cnn.com"
End Sub

Private Sub ie_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
On Error GoTo ErrorHandler
    Dim oHTMLfrm As MSHTML.IHTMLFormElement
    Dim oElement As MSHTML.IHTMLInputElement

    Set oHTML = ie.Document
    Debug.Print "oHTML.Forms.length = "; oHTML.Forms.length
    For Each oHTMLfrm In oHTML.Forms
        Debug.Print "'"; oHTMLfrm.Name; "'"
        For Each oElement In oHTMLfrm.elements
            Debug.Print "oElement = "; oElement.Name; ", Value = ";
oElement.Value
        Next
        'oHTMLfrm.submit ' If you want to submit a form
    Next

    Set oHTMLfrm = Nothing
    Set oHTML = Nothing

ExitMe:
    On Error GoTo 0
    Exit Sub
ErrorHandler:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume ExitMe
End Sub

Private Sub Form_Load()
    Set ie = New InternetExplorer
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set ie = Nothing
End Sub


Show quoteHide quote
"Peter Newman" <PeterNew***@discussions.microsoft.com> wrote in message
news:2A58BDA8-8CDD-4A23-87E8-539398666AC5@microsoft.com...
> and if so how?
>
> Im running VB6 (SP6) on Windows XP Pro. I have an application that opens
> an
> Internet web page . Is it possible to send information to that webpage say
> for instance to click a button or fill out info in  a text box ?
>
> Const SMTO_BLOCK = &H1
> Const SMTO_ABORTIFHUNG = &H2
> Const WM_NULL = &H0
>
> Public Declare Function SendMessageTimeout Lib "user32" Alias
> "SendMessageTimeoutA" _
> (ByVal hwnd As Long, ByVal msg As Long, ByVal Wparm As Long, lParm As
> Long, _
> ByVal fuflags As Long, ByVal uTimout As Long, lpdwResult As Long) As Long
>
> Public objIE As Object
> Public lngRetVal As Long
>
> Public Sub OpenIEWindow()
> Dim lngResult As Long
> Dim WndResponse As Boolean
> ' Create the Object
> Set objIE = CreateObject("InternetExplorer.Application")
> ' Set the properties
> objIE.Visible = True
> objIE.Navigate2 "http://www.google.co.uk"
>
> DoEvents
>  ' Get the object Handle
> lngIEHandle = objIE.hwnd
>   Debug.Print "Window Handle " & CStr(lngIEHandle)
>
> ' Get return value
> lngRetVal = SendMessageTimeout(lngIEHandle, WM_NULL, 0&, 0&,
> SMTO_ABORTIFHUNG And SMTO_BLOCK, 1000, lngResult)
>
>
> ' Check return if browser is responding
>     WndResponse = CheckWindow(lngIEHandle)
> End Sub
>
Author
22 Oct 2005 2:10 AM
Someone
Try:

ie.Navigate "http://ww.google.com"

instead for better result.


Show quoteHide quote
"Someone" <nob***@cox.net> wrote in message
news:eQZQ2yq1FHA.980@TK2MSFTNGP14.phx.gbl...
> Yes it is, through automation, not by using SendMessage which may not get
> you anywhere. You can't find the hWnd for a text box inside a web page and
> use WM_SETTEXT to set its value. Add "Microsoft Internet Controls" and
> "Microsoft HTML Object Library" reference to your project and use that to
> loop access the objects in the web page. Example:
>
> Dim WithEvents ie As InternetExplorer
> Dim oHTML As IHTMLDocument2
>
> Private Sub Command1_Click()
>    ie.Visible = True
>    ie.Navigate "http://ww.cnn.com"
> End Sub
>
> Private Sub ie_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
> On Error GoTo ErrorHandler
>    Dim oHTMLfrm As MSHTML.IHTMLFormElement
>    Dim oElement As MSHTML.IHTMLInputElement
>
>    Set oHTML = ie.Document
>    Debug.Print "oHTML.Forms.length = "; oHTML.Forms.length
>    For Each oHTMLfrm In oHTML.Forms
>        Debug.Print "'"; oHTMLfrm.Name; "'"
>        For Each oElement In oHTMLfrm.elements
>            Debug.Print "oElement = "; oElement.Name; ", Value = ";
> oElement.Value
>        Next
>        'oHTMLfrm.submit ' If you want to submit a form
>    Next
>
>    Set oHTMLfrm = Nothing
>    Set oHTML = Nothing
>
> ExitMe:
>    On Error GoTo 0
>    Exit Sub
> ErrorHandler:
>    MsgBox "Error " & Err.Number & ": " & Err.Description
>    Resume ExitMe
> End Sub
>
> Private Sub Form_Load()
>    Set ie = New InternetExplorer
> End Sub
>
> Private Sub Form_Unload(Cancel As Integer)
>    Set ie = Nothing
> End Sub
>
>
> "Peter Newman" <PeterNew***@discussions.microsoft.com> wrote in message
> news:2A58BDA8-8CDD-4A23-87E8-539398666AC5@microsoft.com...
>> and if so how?
>>
>> Im running VB6 (SP6) on Windows XP Pro. I have an application that opens
>> an
>> Internet web page . Is it possible to send information to that webpage
>> say
>> for instance to click a button or fill out info in  a text box ?
>>
>> Const SMTO_BLOCK = &H1
>> Const SMTO_ABORTIFHUNG = &H2
>> Const WM_NULL = &H0
>>
>> Public Declare Function SendMessageTimeout Lib "user32" Alias
>> "SendMessageTimeoutA" _
>> (ByVal hwnd As Long, ByVal msg As Long, ByVal Wparm As Long, lParm As
>> Long, _
>> ByVal fuflags As Long, ByVal uTimout As Long, lpdwResult As Long) As Long
>>
>> Public objIE As Object
>> Public lngRetVal As Long
>>
>> Public Sub OpenIEWindow()
>> Dim lngResult As Long
>> Dim WndResponse As Boolean
>> ' Create the Object
>> Set objIE = CreateObject("InternetExplorer.Application")
>> ' Set the properties
>> objIE.Visible = True
>> objIE.Navigate2 "http://www.google.co.uk"
>>
>> DoEvents
>>  ' Get the object Handle
>> lngIEHandle = objIE.hwnd
>>   Debug.Print "Window Handle " & CStr(lngIEHandle)
>>
>> ' Get return value
>> lngRetVal = SendMessageTimeout(lngIEHandle, WM_NULL, 0&, 0&,
>> SMTO_ABORTIFHUNG And SMTO_BLOCK, 1000, lngResult)
>>
>>
>> ' Check return if browser is responding
>>     WndResponse = CheckWindow(lngIEHandle)
>> End Sub
>>
>
>