The SendKey Script

My first attempt at automation

Return to Introduction


 
Sample of data from Comma delimited text file used by this script.
PRODUCTA,VIRGINIA,120
PRODUCTA,VIRGINIA,121
PRODUCTB,MARYLAND,14
PRODUCTB,MARYLAND,153
PRODUCTB,MARYLAND,123
PRODUCTC,NEW YORK,43

Source code of SendKey Word Macro
Sub SendKeyScript()

'SendKey script to Change Call setup charges
'Macro created 08/15/00 by Colin Riley

Dim ReturnValue
Dim Product As String
Dim ServArea As String
Dim TableNum As String
Dim SourceItem As String
Close #1
ReturnValue = "Session A"
' Terminal emulator Session ID
SourceItem = "C:/My Documents/Surchlist.txt
' Text file listing records to be changed
Open SourceItem For Input As #1
AppActivate ReturnValue
' Change focus to the emulator session
GoSub WaitTime
' Slow down macro to allow screen changes in session
Dim Cnt As Integer
Input #1, Product
SendKeys "+{F2}",True
' Enter f14
GoSub WaitTime
GoSub WaitTime
SendKeys Product, True
SendKeys "+{F3}", True
' Enter f15
GoSub WaitTime
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "X", True
GoSub WaitTime
SendKeys "{ENTER}", True
GoSub WaitTime
Input #1, ServArea
GoSub WaitTime
SendKeys "+{F2}", True
GoSub WaitTime
SendKeys "+{F3}", True
' Enter f15
GoSub WaitTime
SendKeys "{TAB}", True
SendKeys "X", True
SendKeys "{ENTER}", True
GoSub WaitTime
SendKeys "{TAB}", True
SendKeys "{END}", True
SendKeys "CT", True
SendKeys "{F8}", True
GoSub WaitTime
'slow keys until screen changes
SendKeys "{TAB}", True
SendKeys "X", True
Input #1, TableNum
SendKeys "{F8}", True
GoSub WaitTime
'slow keys until screen changes
SendKeys TableNum, True
SendKeys "+{F3}", True
' Enter f15
GoSub WaitTime
SendKeys "{TAB}", True
SendKeys "{TAB}", True
SendKeys "X", True
SendKeys "{F8}", True
GoSub WaitTime
SendKeys "X", True
SendKeys "{F10}", True
GoSub WaitTime
SendKeys "{TAB}", True
SendKeys "0000.25", True
'Everything before this was navigation This is the


'only value to change


SendKeys "{F10}", True
GoSub WaitTime
SendKeys "{F12}", True
GoSub WaitTime
SendKeys "{F12}", True
GoSub WaitTime
GoSub WaitTime
Cnt = Cnt +1
' Count number of records so that if it fails I know where it stopped.
Loop
Close #1
MsgBox "I am finished", vbOKOnly
Exit Sub
WaitTime:
' Subroutine to occupy PC while session is changing
'Delay
Dim CountRep As Long
Dim Total As Long
Dim Count As Long
Count = 0
Total = 0
CountRep = 0
For CountRep = 0 To 1000000
Count = Count - 1
Total = CountRep + Count
Next CountRep
Return
End Sub
 
 
 

 

Hosted by www.Geocities.ws

1