×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close