Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attachmate Screen Scrape

Status
Not open for further replies.

Dklein

IS-IT--Management
Nov 9, 2001
33
0
0
US
Hi,

Can anyone help please, I've not coded before in VB but have used the record funtions whenever I need to complete an automated action.

I now need to take data from an Attachmate screen and put it into a text document or even better in an excel spreadsheet. If someone could give be an example end-to-end code I could manipulate I would really appreciate it. or any help would be great.

Thanks in anticipation.

Dklein

 
Give a look.
I hope you find this useful. Bye bye.


'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "monitoraggio erogazioni"
' Date: 14/12/2001
' User: barsotti
'
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
' RESET

g_HostSettleTime = 300 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object, MyScreen As Object
Set Sess0 = System.ActiveSession
Set MyScreen = Sess0.Screen
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'--------------------------------------------------------------------------
' Collegarsi a SIBE2000, Interrogazione Pratica di Fido/Interr.Situazione Pratica
'



Dim rc%, row%, MaxColumns%, MaxRows%, filenum%, spia%, vmax%, vv1%, fnum2%, nprat$
Dim Screenbuf$, linebuf$, FileName$, v1$, v2$
' Determine the size of the Presentation Space
MaxRows% = Sess0.Screen.Rows()
MaxColumns% = Sess0.Screen.Cols()

'look if the screen is the right one....
v1$ = MyScreen.GetString(3, 23, 14)
if v1$ <> &quot;Interrogazione&quot; then
'no -> error!!!
msgbox &quot;Occhio: entrare nella maschera giusta per attivare la funzione!&quot;
exit sub
end if

' Initialize variables to hold screen information
Screenbuf$ = &quot;&quot;
linebuf$ = Space$ (MaxColumns%)

close
' Get the next available file number
filenum% = FreeFile


FileName$ = &quot;C:\documenti\monitndg.txt&quot;
Open FileName$ For OUTPUT as filenum%

fnum2% = freefile
' this file contains is a group of keys I need to interrogate
Open &quot;C:\documenti\ndgin.txt&quot; for input as fnum2%

do
if MyScreen.GetString(3, 23, 14) <> &quot;Interrogazione&quot; then
'Isn't the right screen?!?
msgbox &quot;Fine anomala&quot;
exit do
end if
if Sess0.Screen.Row <> 10 or Sess0.Screen.Col <>35 then
'Prepare the request
Sess0.Screen.Sendkeys(&quot;<Home>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
end if

input # fnum2%, nprat$
Sess0.Screen.Sendkeys(&quot;<Tab><Tab>&quot; + nprat$ +&quot;<Enter>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys(&quot;<Pf6>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
if MyScreen.GetString(3, 22, 14) = &quot;Interrogazione&quot; then
'Error !!!
Sess0.Screen.Sendkeys(&quot;<Reset>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Print # filenum%, nprat$ + &quot;Pratica inesistente&quot;
else
'Found data !!!
Sess0.Screen.Sendkeys(&quot;<Tab>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
'Here I write data to a .txt file I will open with MSexcel
'It will find easily the data as fixed lenght strings
'You may, instead, use a character [like tab -chr$(9)] to separate the data

Print # filenum%,MyScreen.GetString(2, 45, 7);
Print # filenum%,MyScreen.GetString(4, 8, 37);
Print # filenum%,MyScreen.GetString(6, 22, 30);
do
for row% = 17 to 20
linebuf$ = MyScreen.GetString(row%, 9, 5)
if linebuf$ = &quot; &quot; then exit for
Print # filenum%, MyScreen.GetString(row%, 9, 26);
next
if linebuf$ = &quot; &quot; then exit do
if MyScreen.GetString(21, 74, 4) = &quot;Fine&quot; then exit do
Sess0.Screen.Sendkeys(&quot;<RollUp>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
loop
Print # filenum%,&quot;&quot;
end if
Sess0.Screen.Sendkeys(&quot;<Pf3>&quot;)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
loop until eof(fnum2%)
close
System.TimeoutValue = OldSystemTimeout


End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top