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

Attachmate Macro

Status
Not open for further replies.

theyareallusedup

IS-IT--Management
Dec 31, 2009
2
US
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.
 



Hi,

Let's see what code you have developed so far.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Well that is where the problem lies. I need to know if that will work or not first. But here is what I have thought of. Please don't laugh at my hacking as I am not working with any real knowledge here just piecing this together. I have included comments where I am looking at inserting the DIM object. I really should get a VB book and really learn how to program.

' 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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top