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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Screen Scrapes

Status
Not open for further replies.

M626

Programmer
Mar 13, 2002
299
0
0
I am trying to do a screen scrape of a specific length off a Pcomm Session, Anyone have any ideas of examples how to do this?
 
Try doing a search on the web for Pushkeys - it's a dll that can send and receive info to and from other programs.
 
Excuse my ignorance but what's a screen scrape and what is Pcomm?
 
Pcomm is a Imulator and Screen Scrapes is to capture data from a screen kinda like copy, paste.
 
M626

I didn't have any joy receiving info back via push keys.

I wanted to do something similar with Telnet and ended up sending keys to open up the Telnet - Terminal\Start Logging menu, send the filename to Telnet with Sendkeys and then read the log file during the connection to check the responses coming back from the remote device.

A bit cumbersome but it works fine.

I hope this helps.
 
Hi,

do you need a special part (a rectangle of the current screen) or do you only need the values ?

In case you need only values, try the help-system of Emu 3270 (keyword vbscript). You will find a good way to access the emu with vba. Every part of the screen ist added to an array of strings.

In case you need a rectangle try something like this:

appactivate &quot;<Title of Session>&quot; ' your Emu Session ist activated and brought to front
sendkeys ... with the sendkeys command you can simulate keystrokes in any activated process.
Send the command für Edit/Copy (look it up in the menu bar, it is a shortcut.
After that you can activate your VBA Tool and paste it to an area, for example, a worksheet in excel.

I don't know if this is the thing you are looking for, but here it is...

I prefer the first way, because it is faster and safer and of course more the way of programming in a sophisticated way.

Best greetings,

Jay
 
Hi

If you only need a Pic of a selected portion of the screen
try doing a Google search for ScreenThief (ScnThief.Zip).


good luck

Bob

 
M626,
You are talking about IBM's Personal Communications Software right? If you are. There are several redbooks available from IBM. The Key words that you are looking for are "Host Access Class Library" or HACL. We utilize these calls quite often in my shop. One thing to be very careful of is that IBM has a few bugs in that particular product. One of which is the PCOMM Bloating (on LU Connected session not IP...from what I understand) But eventually the emulators will stop communicating with your program. There is a work around (kind of). We have some very intesive scraping apps and we were getting no connection on the connection attempt. One way to avoid this is to simply leave your app running all the time. Sometimes this may bother your users but you will only have to make one connection (usually on login) and that connection will stay valid for some time. But remember the more intesive your scraping app is the more likely you are to run into a problem getting your session to accept commands. One way around the "up and running" is to invisible your form when the operation is complete then send a post message to the caption of the form. have a timer looking at the caption and if the caption changes to something then you change the caption back to what is should be then visible the form again. I have quite abit of knowledge on this subject.

One other thing Screen scraping is consider "old tech" we are currently working to convert our "HACL" calls to MQ requests. Be sure that is not you need before go investing the time in getting your HACL programs to work.

I will mark this thread. If you want more info just respond

Scoty ::)

&quot;Learn from others' mistakes. You could not live long enough to make them all yourself.&quot;
-- Hyman George Rickover (1900-86),
 
I would like to use visual basic though MS access to control IBM's Personal communications software. Scoty do you have any tips on what dll's i should use and any other tips or pointers?
 
touregg,
Sorry I missed this. You may have already discovered a solution. But I will post my code just in case someone else runs across this problem.

Again sorry.


Just paste the code into a standard module

Code:
'HACLmod was the brainchild of Scott Farren
'All code included with this application is the product of Scott Farren unless otherwise noted
'If you wish to use this code in any other project it must be noted with this information as a condition of use
'Thank you

Option Explicit
Global psA As Object
Global psB As Object
Global psC As Object
Global psD As Object
Global psE As Object
Global psF As Object
Global OIAA As Object
Global OIAB As Object
Global OIAC As Object
Global OIAD As Object
Global OIAE As Object
Global OIAF As Object
Global E As String
Global C As String


Public Sub StartUp()
 On Error GoTo Error_Trap


E = "[enter]"
C = "[clear]"
Set psA = CreateObject("PCOMM.autECLPS")
Set psB = CreateObject("PCOMM.autECLPS")
Set psC = CreateObject("PCOMM.autECLPS")
Set psD = CreateObject("PCOMM.autECLPS")
Set psE = CreateObject("PCOMM.autECLPS")
Set psF = CreateObject("PCOMM.autECLPS")
Set OIAA = CreateObject("PCOMM.autECLOIA")
Set OIAB = CreateObject("PCOMM.autECLOIA")
Set OIAC = CreateObject("PCOMM.autECLOIA")
Set OIAD = CreateObject("PCOMM.autECLOIA")
Set OIAE = CreateObject("PCOMM.autECLOIA")
Set OIAF = CreateObject("PCOMM.autECLOIA")
Connect

Exit Sub

Error_Trap:
MsgBox Err.Number & "-" & Err.Description

End Sub

Public Sub Connect()
Dim ErrCounter As Integer

 On Error GoTo Error_Trap

psA.SetConnectionByName ("A")
psB.SetConnectionByName ("B")
psC.SetConnectionByName ("C")
psC.SetConnectionByName ("E")
psD.SetConnectionByName ("D")
psE.SetConnectionByName ("E")
psF.SetConnectionByName ("F")
OIAA.SetConnectionByName ("A")
OIAB.SetConnectionByName ("B")
OIAC.SetConnectionByName ("C")
OIAD.SetConnectionByName ("D")
OIAE.SetConnectionByName ("E")
OIAF.SetConnectionByName ("F")
Exit Sub

Error_Trap:

If Err.Number = -2147352567 Then
    'this is the pcomm bloat problem
    MsgBox "Please do a shutdown restart.  This is a CMMouse issue and is being addressed.  Thank you.", vbOKOnly
End If

MsgBox Err.Number & "-" & Err.Description

End Sub


Public Function GetIt(PS As Object, Optional R As Long, Optional C As Long, Optional L As Long) As String

On Error GoTo Error_Trap

If R = 0 Then 'Get whole scree
    GetIt = PS.GetText()
Else: 'Get selected area
    GetIt = PS.GetText(R, C, L)
End If

Exit Function

Error_Trap:
If Err.Number = 91 Then 'you did not run the startup sub this will do it for you
    StartUp
    Resume
End If
WhereAmI = WhereAmI & " " & "GetIt"
MsgBox Err.Number & "-" & Err.Description
Resume
End Function

Public Sub SendIt(PS As Object, Info As String, Optional R As Long, Optional C As Long)

If frmMain.Visible = False Then QuitIt: Exit Sub
Dim WaitTime
Dim ErrorCount As Single

TryAgain:
Err().Number = 0
On Error GoTo Error_Trap

If R = 0 Then
    DoEvents
    R = PS.CursorPosRow
    DoEvents
    C = PS.CursorPosCol
    DoEvents
End If
    
PS.SendKeys Info, R, C


'set WaitTime to 25sec
WaitTime = Timer + 25
'wait
Select Case PS.Name
    Case "A"
        Do Until OIAA.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
    Case "B"
        Do Until OIAB.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
    Case "C"
        Do Until OIAC.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                NotStayOnTop frmMain
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
    Case "D"
        Do Until OIAD.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                NotStayOnTop frmMain
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
    Case "E"
       Do Until OIAE.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                NotStayOnTop frmMain
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
    Case "F"
        Do Until OIAE.InputInhibited = 0
            DoEvents
            If Timer > WaitTime Then
                NotStayOnTop frmMain
                Select Case MsgBox("The '" & PS.Name & "' Emulator appears to be clocking" & Chr(13) & _
                    "Do you wish to continue waiting?" & "If you select No this program will end", vbYesNo, "Wait?")
                Case vbYes
                    WaitTime = Timer + 25
                Case vbNo
                    Set psA = Nothing
                    Set psB = Nothing
                    Set psC = Nothing
                    Set psD = Nothing
                    Set psE = Nothing
                    Set psF = Nothing
                    Set OIAA = Nothing
                    Set OIAB = Nothing
                    Set OIAC = Nothing
                    Set OIAD = Nothing
                    Set OIAE = Nothing
                    Set OIAF = Nothing
                    End
                End Select
            End If
        Loop
End Select

Exit Sub

Error_Trap:
    If Err().Number = -2147352567 Then
        PS.SendKeys "[reset]", 1, 1
        Resume TryAgain
    Else:
        If Err.Number = 91 Then 'you did not run the startup sub this will do it for you
            StartUp
            Resume
        Else:
            MsgBox Err.Number & "-" & Err.Description
            Resume
        End If
    End If

End Sub

Public Sub Enter(PS As Object)

On Error GoTo Error_Trap

Dim lsUnTarget As String
lsUnTarget = GetIt(PS)

SendIt PS, E

PagesCount = PagesCount + 1

Do Until GetIt(PS) <> lsUnTarget
    DoEvents
Loop

Exit Sub

Error_Trap:
    MsgBox Err.Number & "-" & Err.Description
End Sub

Public Sub Clear(PS As Object)

On Error GoTo Error_Trap

TryAgain:

SendIt PS, C & C

Loop Until Trim(GetIt(PS)) = ""
    DoEvents
Loop

Exit Sub

Error_Trap:
    MsgBox Err.Number & "-" & Err.Description
End Sub

Usage
GetIt (psB, 1, 1, 4) 'get row one column one for four character spots

GetIt (psB) 'get the entire presentation space

SendIt (psC, "Hello World", 1, 1) 'Send Hello World to row one column one

SendIt (psC, "Where is the cursor?") 'Send the text to the current cursor location

Enter psA 'send an Enter command to the A emulator

Clear psD 'Clear the D emulator

Hope you find this helpful

Scoty ::)



&quot;Learn from others' mistakes. You could not live long enough to make them all yourself.&quot;
-- Hyman George Rickover (1900-86),
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top