×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Use IF statement to loop send key

Use IF statement to loop send key

Use IF statement to loop send key

(OP)
I'm using KEA version 5.10 at work, and it's easy to capture my data to a text file as I've written several macros for excel to format the data for me.

However, I'm brand new to trying to write a macro. My report is easy to run, I just have to keep hitting the enter key after it dsiplays the page to get the next page of data. It's not terrible to do this manually, but sometimes there can be over 200 pages.

Are there any examples of an IF statement, that IF "< Tap Return to Continue, E to exit>" is on the screen, then send the Enter Key until "< Tap Return to Continue >" is on the screen, then end the macro?

I've looked up various do loop statements, and while I can usually modify loops in VBA for excel, I am running out of ideas on how to make it work in KEA. Maybe my problem isn't so easy as to match text and send key, but I sure hope one of you can school me!

 

RE: Use IF statement to loop send key


hi,

WHERE do you expect to "see" "< Tap Return to Continue, E to exit>?

You can use a method like GetString to get the data in that area of the screen, and then TEST that string.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Use IF statement to loop send key

(OP)
That part is a little bit tricky, as the line can move around in the bottom half of the screen, depending on how much data appears on the page. The report will spit out between 18 and 21 lines of data per page, and the <Tap Return to Continue, E to Exit> will be on one of these bottom lines.

I'm not sure how I could get the coordinates for where the text normally appears.

Sorry, confidential information and all, replaced by X's to show the screen layout. Y's are variable, sometimes there are two extra lines here that can push the final <Tap> line farther down the screen.

CODE




xxxxxxxxxxx              xxxxxxxx xxx - xxxxxxxx              xxxxxxxxx  xxxxxxxx
                            xxxxx xxxxx xxxx                            Page   x
                              xxxx x xxx

xxx xxxxxx   xxxx  xxxxx  xxxxxxx    xxxxxx                      xxxx
             xxxx   xxxx  xxxxxxx     xxxxx                 xxxx x xxxxxxxxxxx
----------   ----  -----  -------   ---------  -------------------------------------------------
 xxxxxxxx    xxx   xxxxx  xxxx xx   xx xxxxxx  xxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  xxxxxx xxxxxxxxxxx  xxxxxxxxx xxxxxx xxxxxx   xxxxxx  xxxxxxxxxxxxxxxxx        

 xxxxxxxx    xxx   xxxxx  xxxx xx   xx xxxxxx  xxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  xxxxxx xxxxxxxxxxx  xxxxxxxxx xxxxxx xxxxxx   xxxxxx  xxxxxxxxxxxxxxxxx        
            yyyyy yyyyyyy y                                                 

 xxxxxxxx    xxx   xxxxx  xxxx xx   xx xxxxxx  xxxxxx  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  xxxxxx xxxxxxxxxxx  xxxxxxxxx xxxxxx xxxxxx   xxxxxx  xxxxxxxxxxxxxxxxx      

        < Tap Return to Continue, E to exit>

xxxxxxxx





 

RE: Use IF statement to loop send key



Good practice for programming screens of this kind, dictates that messages of this kind ALWAYS appear in the same area, like ROW 24, or rows 22-24.

So you're saying that this is NOT the case?  Was this screen developed by your IT department or some other way?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Use IF statement to loop send key

(OP)
Developed a looooong time ago by who knows, very likely the IT dept in some manner or another. I work for a huge company, and this entire software and program is slotted to be replaced in the next few years, so there is zero support for it.

Anyways, yes, the text is very likely to end up in the bottom rows of 18-24, but no guarantees.

When I record my actions, it looks for  

CODE

TryMatch( "exit>", MaxTime=100, Idle=IdleTime )
SendKey( "Keypad Enter" )

If there was some way I could loop that continually, it seems like it should work in my head. When I did set it up with a simple loop, my first page of the report has already been displayed when I run the macro, so the text to match never gets "seen".

Sorry if this doesn't make much sense.

 

RE: Use IF statement to loop send key



"but no guarantees"

Then you might as well give up.

LOGIC assumes a guaranteed SOMETHING!

If there is not guarantee that this string will appear in rows 18-24 then what IS guaranteed?

We have to start with SOME KNOWNS!

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

RE: Use IF statement to loop send key

(OP)
I have to work on the assumption that the text will appear in the 18-24 lines. If not, then end the macro. Since I'm the only person using it, I would know that I need to finish the report manually. It is only pushing the enter button. :)

I will start doing some searching on this site to see if any GetString and TEST examples will work.

RE: Use IF statement to loop send key


i don't know KEA however i do use Attachmate.

in Attachmate, i would simply either look for the string or test each row for the string.

rem

RE: Use IF statement to loop send key

(OP)
I can log in using Attachmate, and maybe that's what I will have to end up doing, but Kea! Attachmate works so much better with this terminal connection.

RE: Use IF statement to loop send key

(OP)
I've tested this bit of code, and it works. It finds the text using the search feature, but I am not sure how to make it loop Until Sess0.Screen.GetString(1, 23, 13) = "Enter Option". Any ideas?

CODE

'Declare Variables
    Dim stringFind As String
    Dim userInput As String
    
    
        
'Set the user input to the string entered in the InputBox
    userInput = "        < Tap Return to Continue, E to exit>"
            
'Start the search for the string
     While stringFind <> userInput
        stringFind = Sess0.Screen.Search(userInput)
        
        If stringFind = userInput Then
        'This is where the select will go
            Sess0.Screen.SendKeys ("<ENTER>")
            'Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        Else
            
            GoTo NotFound
            
        End If
        
                   
    Wend
        
    MsgBox ("End")
    Exit Sub
    
NotFound:
    MsgBox ("Not Found!")
    Exit Sub

theend:

    End Sub

RE: Use IF statement to loop send key

see if this works for you

CODE

'Declare Variables
Dim stringFind As String
Dim userInput As String
'Set the user input to the string entered in the InputBox
userInput = "        < Tap Return to Continue, E to exit>"
'Start the search for the string

Do
    While stringFind <> userInput
        stringFind = Sess0.Screen.Search(userInput)
        If stringFind = userInput Then        'This is where the select will go
            Sess0.Screen.SendKeys ("<ENTER>")
            'Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        Else
            'GoTo NotFound
            MsgBox ("Not Found!")
            Exit Sub
        End If
    Wend
Loop Until Sess0.Screen.GetString(1, 23, 13) = "Enter Option"

MsgBox ("End")
'Exit Sub
'NotFound:
'MsgBox ("Not Found!")
'Exit Subtheend:
End Sub

RE: Use IF statement to loop send key

(OP)
Thanks Remy, makes sense.

I was working on other projects since this last post, but thought I should come back with my solution. I flipped around the search string and this works like a charm. I can't use this macro with Attachmate Kea!340 (it uses another language that seems very similar, but does not work written as-is) The company I work for has the Attachmate extra locked down pretty well, I can't even select text using their version, but it's not too much of a problem to use it to connect to and run this report.

CODE

' 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 g_HostSettleTime = 1000 ' milliseconds OldSystemTimeout& = System.TimeoutValue If (g_HostSettleTime > OldSystemTimeout) Then System.TimeoutValue = g_HostSettleTime End If ' Get the necessary Session Object Dim Sess0 As Object Set Sess0 = System.ActiveSession 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) 'recorded events --------------------------------------------------------- 'Declare Variables Dim stringFind As String Dim userInput As String 'Set the user input to the string entered in the InputBox userInput = " < Tap Return to Continue >" 'Start the search for the string Do While stringFind <> userInput stringFind = Sess0.Screen.Search(userInput) If stringFind = userInput Then 'This is where the select will go Sess0.Screen.SendKeys ("<ENTER>") MsgBox ("Complete") Exit Sub Else Sess0.Screen.SendKeys ("<ENTER>") Sess0.Screen.WaitHostQuiet (g_HostSettleTime) End If Wend Loop Until Sess0.Screen.GetString(1, 23, 13) = "Enter Option" MsgBox ("End") End Sub



RE: Use IF statement to loop send key

(OP)
Err, forgot to remove the extras after loop in my above post (blue).

CODE

Loop 'Until Sess0.Screen.GetString(1, 23, 13) = "Enter Option"

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close