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

SendKeys 2

Status
Not open for further replies.

Paullac

Programmer
Jul 14, 2004
5
US
I am using VB6 to connect to a session of Extra and transfer a file from a mainframe account. I have to use a password to login to the account using sendkeys which works fine when I f8(step) through the code, but when I 'run' the code the sendkeys doesnt work and I dont get logged into the mainframe account. Here is the code I am using. Any help would be a God send.

Public Sub connect_Extra()
Dim Sessions As ExtraSessions
Dim session As ExtraSession
Dim strPath As String
Dim extraConn As ExtraConnectivity
Dim sysSession As New ExtraSystem
Dim screenHost As ExtraScreen
Dim waitobj As Object
Dim waitforKeys$
Dim wait1 As Object
Dim strPswrd As String
Dim strAccount As String

Set sysSession = CreateObject("Extra.system")

Set Sessions = sysSession.Sessions
Set session = Sessions.Open("C:\Program Files\Attachmate\E!E2K\Sessions\V037s1.edp")
Set screenHost = session.Screen

session.WindowState = xMAXIMIZED

screenHost.WaitHostQuiet (consSettleTime)

'login to mainframe
screenHost.SendKeys ("fuapms<Tab>end08use")
screenHost.SendKeys ("<Enter>")

session.FileTransferScheme = "C:\Program Files\Attachmate\E!2k\schemes\enu\Text Default.eis"
session.FileTransferHostOS = 0

session.ReceiveFile "\\file015\cso_grp\imc\policy services data\filenet data\daily image data\imgd0723.txt", "imgdacnt f040723 a"
screenHost.WaitHostQuiet (50000
 
Looks to me like you need to wait for a response from the host between these lines:

screenHost.SendKeys ("<Enter>")
Do While screenhost.OIA.Xstatus <> 0
DoEvents
Loop


session.FileTransferScheme = "C:\Program Files\Attachmate\E!2k\schemes\enu\Text Default.eis"

This will allow the host to stay in sync with your code.

calculus
 
I tried using the xstatus, but it still runs right through the sendkeys without logging in. I tried placing the dowhile statement after each of the sendkeys statement with no success. I stepped through the code and it never hits the DoEvents inside the loop. In the immediate window check Xstatus = 0 when stepping through.
 
Does the macro actually send the correct keys in this line?
screenHost.SendKeys ("fuapms<Tab>end08use")

If so, does it log on when you step through and send the <Enter>?

You may want to replace my previous Do While...Loop statement with a WaitForString. This would require you to know a string to expect after the <Enter> key is pressed.

screenHost.WaitForString YourStringHere,x,y

The x and y coordinates are optional in this statement. This will cause the macro to wait until it sees that string before continuing.

You may alternately try a Wait(milliseconds) command. This is very unreliable as if you don't wait long enough the macro will continue before it should.

calculus
 
Yes, when I step through it works just fine, logs in, sends the file, and closes the session
 
Then it sounds like you have a timing problem where your code and the system are out of sync. Try the options listed above to "Wait" for the system to accept the logon information and get ready for the rest.

calculus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top