sending data to a web page

new topic     » topic index » view thread      » older message » newer message

For an existing application I need to open a web page and enter text into one 
of its frames, I have a macro which does it (for IBM Personnel communications), 
but I cannot launch the macro from my program so I need to somehow perform the
same
actions.. Can anyone see how the macro below is doing it and is there a way to
do the same with EU? (you will not be able to access the web page as it is an 
intranet site)

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
 Dim mtype, subtype, oIE, cgi_param, ie_busy, obj_shell
 autECLConnMgr.autECLConnList.Refresh
 autECLSession.SetConnectionByName (ThisSessionName)

'INITIALISE: Get machine type & model
 mtype = autECLSession.autECLPS.GetText(10, 8, 4)
 subtype = "-" & autECLSession.autECLPS.GetText(10, 32, 3)
 If InStr(mtype, " ") > 0 Then
   mtype = ""
   subtype = ""
 End If
 If InStr(subtype, " ") Then
   subtype = ""
 End If

'---DEBUG: Display data values---
'MsgBox("Active Session = " & ThisSessionName & "." & vbCr & _
' "Type = " & mtype & "." & vbCr & _
' "Subtype = " & subtype & "."

'OPEN INTERNET EXPLORER: Change child frames to the correct URLs
cgi_param = "info?page=" & mtype & subtype
Set oIE = CreateObject("InternetExplorer.Application") 'NOTE: 2nd param of "IE_"
and function "Sub IE_onQuit():ie_active=0:End Sub" fails within an RCMS macro
(but not a VB script), so... find an alternative method e.g. "On Error".
oIE.Visible = 1

On Error Resume Next 'Do not crash, with errors if IE is closed down - handle
with code instead.
oIE.navigate "http://w3.pc.ibm.com/helpcenter/infotips/"
If Len(mtype) > 0 Then
Do:ie_busy=0:ie_busy=oIE.Busy:Loop Until (ie_busy<>True)   'IMPORTANT: Wait
  till MSIE is ready
  If (ie_busy=False) Then
oIE.document.frames("changeFrame").frames("mainBody").Navigate
   "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/family" & cgi_param
oIE.document.frames("changeFrame").frames("SearchResults").Navigate
   "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/hotnews" & cgi_param &
   ";doctype=Hot+news"
oIE.document.frames("changeFrame").frames("leftSide").Navigate
   "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brand" & cgi_param
  End If
  Set obj_shell = CreateObject("WScript.Shell")
  obj_shell.AppActivate "IBM Worldwide HelpCenters InfoTips"
  Set obj_shell = Nothing
Do:ie_busy=0:ie_busy=oIE.Busy:Loop Until (ie_busy<>True)   'IMPORTANT: Wait
  till MSIE is ready

'Middle Frame (3 possible results): password.html (webpage not loaded),
  not_found.html (machine not found), ?page=2136-E04 (success)
Wait(0.2) 'Make allowances for IE (found this is sometimes needed during
  extensive testing)
  If (ie_busy=False) Then
If
    Right(oIE.document.frames("changeFrame").frames("mainBody").location.href, 13) =
    "password.html" Then 'CHILD FRAMES FAILED TO LOAD --> RETRY.
oIE.document.frames("changeFrame").frames("mainBody").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/family" & cgi_param
oIE.document.frames("changeFrame").frames("SearchResults").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/hotnews" & cgi_param &
      ";doctype=Hot+news"
oIE.document.frames("changeFrame").frames("leftSide").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brand" & cgi_param
Do:ie_busy=0:ie_busy=oIE.Busy:Loop Until (ie_busy<>True)   'IMPORTANT:
      Wait till MSIE is ready
Wait(0.2) 'Make allowances for IE (found this is sometimes needed during
      extensive testing)
    End If
  End If

  If (ie_busy=False) Then
If
    Right(oIE.document.frames("changeFrame").frames("mainBody").location.href, 14) =
    "not_found.html" Then 'RETRY: Use Machine Type only
      cgi_param = "info?page=" & mtype
oIE.document.frames("changeFrame").frames("mainBody").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/family" & cgi_param
oIE.document.frames("changeFrame").frames("SearchResults").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/hotnews" & cgi_param &
      ";doctype=Hot+news"
oIE.document.frames("changeFrame").frames("leftSide").Navigate
      "http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brand" & cgi_param
Do:ie_busy=0:ie_busy=oIE.Busy:Loop Until (ie_busy<>True)   'IMPORTANT:
      Wait till MSIE is ready
Wait(0.2) 'Make allowances for IE (found this is sometimes needed during
      extensive testing)
      If (ie_busy=False) Then
If
        Right(oIE.document.frames("changeFrame").frames("mainBody").location.href, 14) =
        "not_found.html" Then
oIE.document.frames("changeFrame").frames("mainBody").Navigate
          "http://w3.pc.ibm.com/helpcenter/infotips/password.html"
'NOTE: No need to change LHS & RHS frame, as these will show the
          default page, rather than a not found webpage
          MsgBox "Machine type '" & mtype & subtype & "' was not found!"
        End If
      End If
    End If
  End If

End If
oIE.Visible = 1  'Re-active IE as active window
On Error Goto 0

Function Wait(secs)
' WScript.Sleep milli_secs 'WScript object not available in Pers. Com. macro -
  use Timer instead.
  Dim t
  t = Timer
  Do Until (Timer - t) > secs 'Wait X seconds
  Loop
End Function

'Example frame URLs: Machine Type/Model
'(changeFrame.leftSide)
http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brandinfo?page=2144-0R6
'(changeFrame.mainBody)
http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/familyinfo?page=2144-0R6
'(changeFrame.SearchResults)
http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/hotnewsinfo?page=2144-0R6;doctype=Hot+news

'Example frame URLs: Machine Type/Model, Category: "Hints and Tips\ECA"
'http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brandinfo?page=2144-0R6
'http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/familyinfo?page=2144-0R6
'http://w3.pc.ibm.com/cgi-bin/helpcenter/infotips/brandinfo?page=2144-0R6;doctype=Hints+and+tips;subtype=ECA;docstart=0

'Sub IE_onQuit()
'  MsgBox "Quit..."
'  WScript.Quit  'NOTE: Can not use "WScript" or "Quit()" within an RCMS macro.
'End Sub

 Thanks, Pete.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu