×
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!
  • Students Click Here

*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

Jobs

SendKey for Enter from vbscript to Attachmate

SendKey for Enter from vbscript to Attachmate

SendKey for Enter from vbscript to Attachmate

(OP)
Hi,

I have a requirement, which requires connecting to Attachmate using VBScripts. My problem is fairly basic. I have tried a LOT of things, but I just can't get the SendKeys operation for Enter to work.

I have tried :

' gobjTerminal is the Terminal object for the current session
' Set gobjScreen = gobjTerminal.Screen

1. gobjScreen.SendKeys ("<Enter>")
2. gobjScreen.SendControlKeys_Transmit
3. gobjScreen.TransmitTerminalKey ([ENTER])
4. gobjScreen.TransmitTerminalKey (289)
5. Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys "{ENTER}"
6. gobjScreen.SendKeys "{ENTER}"

None seem to work. I am fairly new to Attachmate, right now I'm completely lost. Any assistance would be highly appreciated !!

PS :- A doubt :
in many posts I have seen the following line
Sess0.Screen.SendKeys ("<ENTER>")

What is Sess0 ? And what is its definition ?

RE: SendKey for Enter from vbscript to Attachmate

(OP)
I'm sorry ...

its actually :
2. gobjScreen.SendControlKeys ControlKeyCode_Transmit

RE: SendKey for Enter from vbscript to Attachmate

(OP)
Any help please ?? Really desperate... Cannot do any sendkey function like F11 or F8 either....

RE: SendKey for Enter from vbscript to Attachmate

hi,

Attachmate Extra has no terminal object!

To get you started...

CODE

Set oSystem = CreateObject("Extra.System")
'this happens to be where my emulator is stored   
    Set oSess = oSystem.Sessions.Open("C:\Program Files\E!PC\Sessions\Mainframe.edp")

    With oSess
        .Visible = True
        .WindowState = xNORMAL
    End With

    Set oScrn = oSess.SCREEN

    oScrn.SendKeys ("<ENTER>") 

Skip,

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

RE: SendKey for Enter from vbscript to Attachmate

(OP)
I am using Attachmate Reflection Suite 4x 2011, running the script in QTP. I really new to this so I'm really sure if this is different from Attachmate Extra.

This is how I am creating the object:
Set gobjApplication = CreateObject("Attachmate_Reflection_Objects_Framework.ApplicationObject")

.Sessions.Open throws an error saying the code is not supported.

RE: SendKey for Enter from vbscript to Attachmate

Use your HELP feature to find the available objects and methods.

Skip,

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

RE: SendKey for Enter from vbscript to Attachmate

(OP)
The HELP ain't very helpful :/

These are members of IBMScreen objects (From Attachmate HELP):
.SendControlKeySync ControlKeyCode_Transmit
.SendControlKeys ControlKeyCode_Transmit

But these dont work either. Nothing happens on the screen. No error is thrown either.

RE: SendKey for Enter from vbscript to Attachmate

Can't help you with Reflection.

I'd only say, start with the application object and work down.

Skip,

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

RE: SendKey for Enter from vbscript to Attachmate

(OP)
Okay.. Thanks anyways..

RE: SendKey for Enter from vbscript to Attachmate

Hi,

I wrote this a few years ago to automate working with Extra

Its basically a wrapper Class Module which you can add to your Project,

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
To use it just add a line like to your code dont forget to add a reference to Extra!

Private WithEvents Tool As clsExtra ' declare (Tool is just a name)

then just say something like Tool. and it will list the methods in the class, or you can add your own methods

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Here's the Code for the class, just add a class to your project and paste this into it. Worked for me for years...

Option Explicit

' *********************************************************************************
' clsEasyExtra, Steve Carr 15/9/03. Please modify or distribute freely.
' A simple class designed to allow you to i/face your VB application with Extra
' I have only inserted some common methods which I think you may find useful
' You may of course insert as many as you like, or modify the code to suit your
' own application. DONT FORGET TO SET UP A REFERENCE TO THE EXTRA OBJECT LIBRARY
' *********************************************************************************

Private objSystem As EXTRA.ExtraSystem ' declare some objects
Private objSession As EXTRA.ExtraSession
Private objScreen As EXTRA.ExtraScreen
Private objSessions As EXTRA.ExtraSessions


' Class Event Handlers

Private Sub Class_Initialize()

On Error GoTo Class_Initialize_Error

' Establish connection to Host via a valid Session
Dim intSessionCount As Integer

Set objSystem = New EXTRA.ExtraSystem
Set objSessions = New EXTRA.ExtraSessions


objSystem.TimeoutValue = 500

For intSessionCount = 1 To objSystem.Sessions.Count

Set objSession = objSystem.Sessions.Item(intSessionCount)
Set objScreen = objSession.Screen
objSession.Visible = True

Exit Sub

Next

Exit Sub

Class_Initialize_Error:
MsgBox "Valid Host Session not Available", vbCritical, "Critical Application Error"
End Sub

Private Sub Class_Terminate()

On Error Resume Next

Set objSystem = Nothing ' dispose
Set objSession = Nothing
Set objScreen = Nothing

End Sub

' General class methods

'Sends a Reset to Host

Public Sub Reset()

objScreen.SendKeys "<pf24>"
WaitForHost 1

End Sub

'Make Host Screen visible

Public Sub OpenSession()

objSession.NavigateTo Me

End Sub



Public Sub CloseSession()


objSession.Close

End Sub

Public Sub Show()

objSession.Visible = True

End Sub

'Make Host Screen invisible

Public Sub Hide()

objSession.Visible = False

End Sub

'Host Page Forward

Public Sub PageForward()

objScreen.SendKeys "<pf8>"
WaitForHost 1

End Sub

'Host Page Back

Public Sub PageBack()

objScreen.SendKeys "<pf7>"
WaitForHost 1

End Sub

'Save Host Screen

Public Sub Save()

objScreen.SendKeys "<pf20>"
WaitForHost 1

End Sub

'Recall saved Screen

Public Sub Recall()
objScreen.SendKeys "<pf21>"
WaitForHost 1

End Sub

'Goto Home ie. Screen position 01/02

Public Sub Home()

objScreen.SendKeys "<home>"
WaitForHost 1

End Sub

'Send Enter to Host

Public Sub Enter()

objScreen.SendKeys "<enter>"
WaitForHost 1

End Sub

'Send PF9 to Host

Public Sub A1()

objScreen.SendKeys "<pf9>"
WaitForHost 1

End Sub

'Delete line

Public Sub EraseEOF()

objScreen.SendKeys "<EraseEOF>"

End Sub


'Send data to Host with screen position x,y

Public Sub SendMessageParams(ByVal message As String, X As Integer, y As Integer)
objScreen.PutString message, X, y
End Sub

'Send data to Host without screen position

Public Sub SendMessage(message As String)
objScreen.PutString message
End Sub

'Send a command to Host

Public Sub SendCommand(command As String)
objScreen.SendKeys command
WaitForHost 1
End Sub


'Read text at cursor position

Public Function GetText(X As Integer, y As Integer, chars As Integer) As String

GetText = objScreen.GetString(X, y, chars)

End Function


'Wait for x seconds until host settles

Public Sub WaitForHost(seconds As Integer)

Do While objScreen.OIA.XStatus = 5
objScreen.WaitHostQuiet seconds ' x milliseconds
Loop

End Sub

' Minimize Host Screen

Public Sub MinimizeScreen()

objSession.WindowState = xMINIMIZED

End Sub

' Maximize Host Screen

Public Sub MaximizeScreen()

objSession.WindowState = xMAXIMIZED

End Sub

' Send Clear to Host

Public Sub Clear()

objScreen.SendKeys ("<clear>")

End Sub

' Restore Host screen to Normal

Public Sub RestoreScreen()

objSession.WindowState = xNORMAL

End Sub

*********************************************************************************************************************


Hope it helps,

Steve...

!ExtraDunce

RE: SendKey for Enter from vbscript to Attachmate

Hi,,

oops!!

I missed off one really important bit, in your startup form or Sub Main() you'll need to instantiate the class like below

Tool = New clsExtra

then you can use the intellisense Tool. and it should drop you a list of the methods in the class.

This was written for an IBM Host Session, I've got a couple of bits and peices for a Unix Host if you need any more.

Steve

!ExtraDunce

RE: SendKey for Enter from vbscript to Attachmate

(OP)
Hey Steve,

As mentioned earlier, I am using Attachmate Reflection Suite 4x 2011. Is this the same as the version you are talking about ?
Instead of a Session object, an Application object gets created.. so I really dont know how to go forward with that.

RE: SendKey for Enter from vbscript to Attachmate

BTW, using a WAIT method for a specified time, is like saying, "When I get to the traffic light, I'll wait for 10 seconds, then I'll go!" Sometimes you'll be waiting TOO long. Sometimes you'll not be waiting long enough (and loose data)!!!

1. use MoveRelative to move the cursor away from the screen's Cursor rest Postion.

2. Issue the Control Key String using SendKeys

3. Loop until the cursor appears at the screen's Cursor rest Postion.

CODE

With oScreen
        .MoveRelative 1, 1, 1
        .SendKeys ("<enter>")
        Do Until .WaitForCursor(3, 19)
            DoEvents
        Loop
   End With 

Skip,

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

RE: SendKey for Enter from vbscript to Attachmate

(OP)
Thanks a lot, Steve and Skip.

And I agree about the "WAIT". I was wondering how to go around that, so thanks again Skip :)

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