Attachmate Macro
Attachmate Macro
(OP)
I am looking for help in creating an Attachmate Macro that will Trap a typed command that closes the entire program after the Macro Finishes running. Can this be done or am I just dreaming?
Example Open program macro runs necessary operations and finishes. Person performs necessary steps and type "OFF" to close the session. That is when I want to have the program close without the user intervention. Thanks for the advise.
Example Open program macro runs necessary operations and finishes. Person performs necessary steps and type "OFF" to close the session. That is when I want to have the program close without the user intervention. Thanks for the advise.
RE: Attachmate Macro
Hi,
Let's see what code you have developed so far.
Skip,
Just traded in my old subtlety...
for a NUANCE!
RE: Attachmate Macro
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 3000 ' milliseconds
g_MenuSettleTime = 1000 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' This section of code contains the recorded events
Sess0.Screen.Sendkeys("<Pa1>")
Sess0.Screen.WaitHostQuiet(g_MenuSettleTime)
Sess0.Screen.Sendkeys("4<Enter>")
Sess0.Screen.WaitHostQuiet(g_MenuSettleTime)
Sess0.Screen.Sendkeys("1<Enter>")
Sess0.Screen.WaitHostQuiet(g_MenuSettleTime)
System.TimeoutValue = OldSystemTimeout
' Minimize Attachmate
SendKeys("% ")
SendKeys("n")
' This is my insertion of the code I need for the wait
'I have no idea how to tie this in
Dim w1 as Object
Dim waits as Object
' Get a Waits collection object
Set waits = System.Waits
' Trap for Function Key (Exit Macro)
Set w1 = Sess0.Screen.WaitForKeys(off)
'not sure how to tie the below in to set as a
Sess0.Screen.Sendkeys("off<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Application.Sessions.CloseAll
End Sub