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

I need to set this macro to run in a loop.

Status
Not open for further replies.

bigdaddyjohn

Technical User
Feb 11, 2011
2
US
Hello,

I need to set this simple macro to run in a loop indefinitely until I manually stop it. Can someone edit this code so that I can just paste it right into the macro? Basically, I want Pf1 to run once every few seconds, all day, no matter what the condition is.


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

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("<Pf1>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout
End Sub
 
Check out this thread. There may be a solution in it for you.

thread99-1402160

It's always better to ask stupid questions; stupid questions have been known to reduce the frequency of stupid mistakes. :eek:)
 
This one too may be helpful, as well.

thread1-1552700

It's always better to ask stupid questions; stupid questions have been known to reduce the frequency of stupid mistakes. :eek:)
 
Thanks! So far I'm not having any luck. Either I get an error message that the macro cannot execute, or session just stops responding all-together. As far as the screen refresh goes, that is exactly what I'm looking for. The only difference is that my refresh is done by PF1 instead of ENTER.

Any other ideas?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top