Sub GrabScreen()
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
' ******** This is for Grabbing the Screen Lease Contract Maintenance/Inquiry.*************************
' Select and copy text from the screen
osCurrentScreen.SelectText 1, 1, 24, 80, RegionOption_Wrapped
' Press EditCopy (Copy the selection and put it on the Clipboard).
osCurrentScreen.Copy
' ******** This is for Placing the Grabbed Information to Clipboard.*************************
' Clipboard to Variable strClip
Dim MyData As DataObject
Dim strClip As String
Set MyData = New DataObject
MyData.GetFromClipboard
strClip = MyData.GetText
Dim myUser As String
myUser = Environ("username")
MyFile = "C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreenFile.txt"
' ******** This is for MODULE_GrabScreen.*************************
' Writing to File C:\Users\Username\Documents\AHK\Batch_Manipulator\GrabScreenFile.txt
Set fs = CreateObject("Scripting.FileSystemObject")
Set A = fs.CreateTextFile("C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreenFile.txt", True)
A.WriteLine (strClip)
A.Close
' ******** This is for AHK GrabScreen.*************************
' Run Executable C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreen.exe
Dim RetVal
RetVal = Shell("C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreen.exe", 1) ' Run GrabScreen.exe.
End Sub
*************************************************************************************************************************************************
Sub WriteToTextFile ()
'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(300)
Call GrabScreen
'Wait for host to 'be quiet' before continuing
returnValue = osCurrentScreen.WaitForHostSettle(300)
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Dim fs, f, ts
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile("C:\Users\" & myUser & "\Documents\AHK\Batch_Manipulator\GrabScreenFile.txt")
Set ts = f.OpenAsTextStream(ForReading, TristateUseDefault)
Line1 = ts.ReadLine ' First Line on File
Line2 = ts.ReadLine ' Second Line on File
Line3 = ts.ReadLine ' Third Line on File
Line4 = ts.ReadLine ' Fourth Line on File
Line5 = ts.ReadLine ' Fifth Line on File
Line6 = ts.ReadLine ' Sixth Line on File
Line7 = ts.ReadLine ' Seventh Line on File
Line8 = ts.ReadLine ' Eight Line on File
Line9 = ts.ReadLine ' Nineth Line on File
Line10 = ts.ReadLine ' Tenth Line on File
Line11 = ts.ReadLine ' Eleventh Line on File
Line12 = ts.ReadLine ' Twelveth Line on File
Line13 = ts.ReadLine ' Thirteenth Line on File
Line14 = ts.ReadLine ' Fourteenth Line on File
Line15 = ts.ReadLine ' Fifteenth Line on File
Line16 = ts.ReadLine ' Sixteenth Line on File
Line17 = ts.ReadLine ' Seventeenth Line on File
Line18 = ts.ReadLine ' Eighteenth Line on File
Line19 = ts.ReadLine ' Nineteenth Line on File
Line20 = ts.ReadLine ' Twentyth Line on File
Line21 = ts.ReadLine ' Twenty-First Line on File
Line22 = ts.ReadLine ' Twentyth Line on File
Line23 = ts.ReadLine ' Twenty-First Line on File
Line24 = ts.ReadLine ' Twentyth Line on File
ts.Close
Dim ContractVar As String
ContractVar = Mid(Line4, 24, 7)
End Sub