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!

Capture screen information

Status
Not open for further replies.

jamesbt

Technical User
May 30, 2011
24
GB
I use extra at work. I need to capture a line of txt that is displayed on the screen.
The txt will always appear on the same screen in my active session. It can however appear on different rows.

I need to find the txt on screen, XYZInformation:

I need to capture the 6 or seven charecters to the right of the:

This needs to a variable so I can use it else where in my macro.
I know it can be done. I really just cant get my head around how I do this.

Any help will truly be appreciated!
 


Hi,

Do you have any code? Please post.

Where are you stuck?



Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi Skip, I need to tidy up the code a little, im very new to this, but this has opened up so many doors, I've been reading fromt the forum for a while.

Any way, here goes.

Sess0.Screen.Sendkeys "dsdd"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
DesigB = Sess0.Screen.GetString(15, 28, 10)
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf12>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf12>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf24>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys "dps"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys ("<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.MoveTo 14,41
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys DesigB
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf8>")
sssid = Sess0.Screen.GetString(17, 52, 6)

' I need the txt to the right of this, the problem is the line 17 is sometimes 16, 19 or 20. I need to search the screen for

XYZInformation: 123456 (and capture the number) then insert at sssid


Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess1.Screen.Sendkeys("<Pf4>")
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)
Sess1.Screen.Sendkeys("7<Enter>")
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)
Sess1.Screen.Sendkeys "<Tab><Tab><Tab><Tab>"
Sess1.Screen.Sendkeys "sdh"
Sess1.Screen.Sendkeys("<Tab>1")
Sess1.Screen.Sendkeys sssid

' sssid this is number I need from above to put in session 1

Sess1.Screen.Sendkeys("<Tab>e<Enter>")
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys "dced"
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys ("<enter>")
System.TimeoutValue = OldSystemTimeout

End Sub
 
this should do the trick

Code:
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
	Set Sys = CreateObject("EXTRA.System")
	Set Sess = Sys.ActiveSession
	Set MyScreen = Sess.Screen

	MyScreen.MoveTo 1, 1
	Set MyArea = MyScreen.Search("XYZInformation:")
        MyScreen.MoveTo MyArea.Bottom, MyArea.right + 2
        
        row = MyScreen.row
        col = MyScreen.col
        
        msgbox "row: " & row  & "  /col: " & col
        
        ssid = trim(MyScreen.GetString(row, col, 7))
        
        msgbox ssid

adjust right + 2 as needed
 
vzachin thanks ever so much, I have it working as per what you have suggested, however I need to link two separate sessions together,
session1.edp, this is where i need to navigate to, then I use your script to capture the infomation, I now need to insert the sssid contents into session2.edp

Ive been trying for a while to do this, its really quite difficult to do,

You see, I created a macro that would naviagte between two sessions, however to elaberate, I now need to capture this infor and put it into the other session.

This is what I have so far,

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object


Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

g_HostSettleTime = 10 ' milliseconds


MyScreen.MoveTo 1, 1
Set MyArea = MyScreen.Search("SSSID OF ETHERNET SERIVCE :")
MyScreen.MoveTo MyArea.Bottom, MyArea.right + 2

row = MyScreen.row
col = MyScreen.col

msgbox "row: " & row & " /col: " & col

sssid = trim(MyScreen.GetString(row, col, 7))

msgbox sssid

(This where I need to add code to naviage to session2.ebm)

I tried a simple line of code after it displays the sssid ie

Sess.Screen.SendKeys sssid

However it doesnt appear in my active session?


End Sub

Thanks so much for helping me so far.


 
not knowing how you set your session1 and session 2, i wrote it this way

Code:
Sub Main()
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
        
Dim Sess1   As Object
Dim Sess2   As Object
Dim MyArea  As Object
        
        for i = 1 to sessions.count
        
            sess = sessions(i).name
            
            if sess = "Session1" then
                set sess1 = sessions(i)
            end if    
            
            if sess = "Session2" then
                set sess2 = sessions(i)
            end if  
        
        next i
        

    Set MyArea = sess1.screen.Search("SSSID OF ETHERNET SERIVCE      :")
    sess1.screen.MoveTo MyArea.Bottom, MyArea.right + 2
    
    row = sess1.screen.row
    col = sess1.screen.col
    
    msgbox "row: " & row  & "  /col: " & col
    
    ssid = trim(sess1.screen.GetString(row, col, 7))
            
    msgbox ssid
    

[blue]'----this places ssid on the 2nd screen ----[/blue]    
[blue]    sess2.screen.putstring ssid, 14,5[/blue]



End Sub

instead of using sendkeys on your 2nd screen, i used putstring instead. your choice
 
Vzachin,

Thats great, I now have it working, I really appreciate your help, I'm new to the world of VB, macros etc, but its really opened up eyes as to what can be done. I've lots of ideas on what I would like to do, for now.. More reading and learning, you guys are great.

Many thanks!!
 
I would like to look for something specific on the screen then do as I did before and capture the txt to the right of it.

I have used

For x = 9 To 22
strTemp = Sess0.screen.GetString(x, 13, 36)

Select Case strTemp

Case "Call it what you like" ' txt im searching for

End Select

Next x

As in previous post, once I find what it im looking for, how can I capture this as a variable name i wish for to use later?

Thanks.
 
wouldn't your variable name be the same as the value of strTemp?
 
Sorry I should have said, once I have found what it is im looking for on the screen, ie ive looked through 9 lines of txt, how do I then capture what is to the right of that case.

For x = 9 To 22
strTemp = Sess0.screen.GetString(x, 13, 38)

Select Case strTemp

Case "Call it what you like:" ' my txt im searching for


End Select

Next x

How do I now capture what is to the right of the : whatIneed

as a variable to use later?

Thanks so much, i guess I'm trying to run before I walk.

Thanks
 


OK lets think about it.

You found what you were looking for in Sess0.screen.GetString(x, 13, 36)

Now you need what is to the RIGHT of what you found.

Have you read the HELP on what GetString does and how it works?

What code have you tried in order to get the stuff to the right?

Please answer BOTH of these questions.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
jamesbt, i agree with skip. what code have you tried?

also, in your code
Code:
strTemp = Sess0.screen.GetString(x, 13, 38)
you are looking at 38 characters, whereas
Code:
Case "Call it what you like:"
contains only 21 characters.

you won't be able to find that string.

if your case string is truly 38 characters, then whatever to the right of 38 characters would begin in column position 51 so it would be like this
Code:
 foundstring = sess0.Screen.Getstring (x,51,y)<---[blue]replace y with the number of characters that you want[/blue]

can you post an example of what your screen would look like and how you propose on using the Case Statement?
 
Thanks again for your help,

Skip I have read through the help file on getstring.

The code I have used is this,

For x = 9 To 22
Search = Sess0.Screen.Getstring(x, 19, 32)

Select Case Search

Case Is = "SSSID OF ETHERNET SERIVCE :"

lookingfor = Sess0.Screen.Getstring(x, 52, 7)

End Select

Next x

MsgBox lookingfor
End Sub

This works for me and finds what it is im looking for in my session. I can then use the variable at a later stage.

I appreciate that it looks like im searching for the same thing as I asked for before vzachin, however, I can use this method other things I need to do.

The next step is looking at getting data from excel to extra and back, I understand there is alot more information for me to work through on this site.

Many thanks vzachin and skip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top