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

SendKeys "Y" code not working.

Status
Not open for further replies.

airwolf09

Technical User
Dec 7, 2012
24
US
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
 
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

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top