×
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

SendKeys "Y" code not working.

SendKeys "Y" code not working.

SendKeys "Y" code not working.

(OP)
I am using Reflections 11. The VBA code works but when it comes to pass the osCurrentScreen.SendKeys "Y", It does not pass the "Y" Key. Why is that? This only happens in my If Then Else statement.
Any help would be appreciated.
Thank You

If (Line22) = "Do you wish to continue? N" Then

osCurrentScreen.SendKeys "Y"

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

For x = 1 To 2

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Next x

Else

For x = 1 To 3

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Next x

End If

RE: SendKeys "Y" code not working.

Please post ACTUAL code: COPY 'n' PASTE here.

RE: SendKeys "Y" code not working.

(OP)
Here is my Module Code. Thanks

Sub BATCH_TRANS_OPT9_Loop()

Dim hostSettleTimeout As Integer
Dim hostSettleTime As Integer
Dim osCurrentScreen As Screen
Dim osCurrentTerminal As Terminal
Dim returnValue As Integer
Dim hiddenTextEntry As String

hostSettleTimeout = 5000
hostSettleTime = 300

Set osCurrentTerminal = ThisFrame.SelectedView.control
Set osCurrentScreen = osCurrentTerminal.Screen

Dim myUser As String
myUser = Environ("username")

' ******** This is for Any BATCH TRANS to OPT9*************************
' Reading File from S:\FinAdj\Master_Files\BATCH_DISPO_9_FILE.csv

MyFile = "S:\FinAdj\Master_Files\BATCH_DISPO_9_FILE.csv"
Open MyFile For Input As #1 ' Open file for input.

Do While Not EOF(1) ' Loop until end of file.

Input #1, PosVar, LessorVar, ContractVar, Contract2Var, TransVar ' Read data into variables.

osCurrentScreen.SendKeys "1"

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Call osCurrentScreen.SendKeys(LessorVar) ' Lessor

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Call osCurrentScreen.SendKeys(ContractVar) ' Contract Number

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendKeys "."

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Call osCurrentScreen.SendKeys(Contract2Var) ' Contract Number

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendKeys "6"

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Call osCurrentScreen.SendKeys(TransVar) ' Trans Number

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Call GrabScreen

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(100)

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts, Line1
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreenFile.txt")

Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)

Line22 = ts.ReadLine ' Twenty-First Line on File

ts.Close

If (Line22) = "Do you wish to continue? N" Then

osCurrentScreen.SendKeys "Y"

For x = 1 To 3

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Next x

Else

For x = 1 To 3

osCurrentScreen.SendControlKey ControlKeyCode_Enter

'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(50)

Next x

End If

Loop

Close #1 ' Close file.

End Sub

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