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!

How To Give WINDOW Focus Back to the Parent Window??

Status
Not open for further replies.
Jan 13, 2012
1
US
Hello:

I really have learned much from using this forum - Thanks!

I have written the macro listed below (EXTRA! 9.1), which is invoked by a calling program. It successfully connects to an IBM mainframe, navigates the menus to the COMMAND window, feeds back values to the calling program. When the calling program transmits an OFF string, the WHILE loop successfully terminates the EXTRA window. Additionally, the window is minimized via the "Sess0.WindowState = 0" command. This all works fine.

My one final objective is this:

After my EXTRA! session connects and is ready for commands, how to I programmatically hand FOCUS or control back to the window of the calling program?
While the macro is executing, the window of the calling program is "GRAYED-OUT". The only way to transfer control is to mouse-click within the window of the calling program.

Please help - Thanks!

==============================================================


'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "LCDE 12-05-2011 Test Session.edp"
' Date: Tuesday, December 06, 2011 09:16:16
'
'--------------------------------------------------------------------------------

' Global variable declarations

Global Attachmate_Waiting
Global ABC_Ended_string$

Global ABC_Launch_string$
Global ABC_Exit_string$

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 = 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
Sess0.Windowstate = 0
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events
Sess0.Connected = True
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("p<Enter>")
FoundTSmenu = Sess0.Screen.WaitForString("TDC ", 10, 11, , , 3000)
If FoundTSmenu Then
' Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("4<Enter>")
End If
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("2<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

System.TimeoutValue = OldSystemTimeout

ABC_Exit_string$ = "<Pf8>"
ABC_Ended_string$ = " ===>"
ABC_Menu_Selection$ = "2<Enter>"
Host_Settle_Time = 15000 ' 15 seconds
Attachmate_Waiting = false
' Setup for waiting
Dim w1 as Object, w2 as Object
Dim waits as Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
Set Sess0 = System.ActiveSession
' Get a Waits collection object
Set waits = System.Waits

' Launch ABC application
Sess0.Screen.Sendkeys(ABC_Launch_String)
Sess0.Screen.SendKeys "+ {TAB}"

' Trap for Function Key (Exit Macro)
Set w1 = Sess0.Screen.WaitForKeys (ABC_Exit_string$)

' Trap for ABC application termination
Set w2 = Sess0.Screen.WaitForString (ABC_Ended_string$)

id1 = waits.Add(w1)
id2 = waits.Add(w2)

Attachmate_Waiting = true
While Attachmate_Waiting = true
retval = waits.Wait(0)
Select Case retval
Case id1
' User press macro exit string
Waits.RemoveAll
Sess0.Screen.Sendkeys("off<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Attachmate_Waiting = false
Case id2
' ABC application ended
Waits.RemoveAll
Attachmate_Waiting = false
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
End Select
DoEvents
Wend
rc = shell("ebrun D:\session_killer.ebm")
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top