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

How to copy from one session, paste in another

Status
Not open for further replies.

sjim2004

Technical User
Oct 1, 2010
3
0
0
US
I've been using a macro (below) to copy and paste within the same session window, but I was wondering if it is possible to copy text from one session, and paste it into another session.

This is for Extra version 7.0 also, not the newest version if that makes a difference.

Here is what I use to copy and paste in the same session window:

' Selects the text, row column to row column
Sess0.Screen.Select 7, 59, 7, 67
' Copy the text
Sess0.Screen.Copy
Sess0.Screen.WaitHostQuiet(10)
' Selects the place to paste, row column to row column
Sess0.Screen.Select 18, 23, 18, 31
'Paste the text
Sess0.Screen.Paste
Sess0.Screen.WaitHostQuiet(10)

Thanks!
 
you have to define your sessions

eg: Sess0 vs Sess1

if you record the macro, you will see how that works
 
Ahhh, that gives me something to go on, and I see where they're defined.

Here's what the recorder used in the macro:

' 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

So I would add in the sess1 as an object, and the 'set sess# =' would be the name of the session window? For example, if I had 'Session One', 'Session Two', etc... I'd use 'Set Sess1 = "Session One"' or...

Well, I'll experiment and give that a shot.

Thanks
 
Still can't figure it out...

How do i set up Sess1, Sess2, etc... in order to jump from one session to another?

I'm a newbie to this, so any help would be appreciated!
 



You have a Sessions collection...
Code:
    Dim Sess0 As Object, Sess1 as object, oSess as object
    Set Sess0 = System.ActiveSession

    for each oSess in System.Sessions
      if oSess.name <> Sess0.name then set Sess1 = oSess
    next
....

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
the way i learned this was by recording from one session. type something into session 1
then click on session 2.
type something into session 2.
click back on session 1.
stop macro.
then review the macro...

 
Here is an example


' 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 = 000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Objects
Dim Sess0 As Object
SessName0$ = "SESSION1.EDP"

Set Sess0 = Sessions.Item(SessName0$)
If Sess0 is Nothing Then
Err = MsgBox(SessName0 + " is not currently open. Open it?",1)
If 1 = Err Then
Err = 0
Set Sess0 = Sessions.Open(SessName0)
If Err Then
MsgBox("Failed to open " + SessName0 + ". Stopping playback")
Stop
End If
ElseIf 2 = Err Then
Stop
Else
MsgBox("Failed to open " + SessName0 + ". Stopping playback")
Stop
End If
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

Dim Sess1 As Object
SessName1$ = "C:\Program Files\Attachmate\EXTRA!\Sessions\ENU\SESSION2.EDP"

Set Sess1 = Sessions.Item(SessName1$)
If Sess1 is Nothing Then
Err = MsgBox(SessName1 + " is not currently open. Open it?",1)
If 1 = Err Then
Err = 0
Set Sess1 = Sessions.Open(SessName1)
If Err Then
MsgBox("Failed to open " + SessName1 + ". Stopping playback")
Stop
End If
ElseIf 2 = Err Then
Stop
Else
MsgBox("Failed to open " + SessName1 + ". Stopping playback")
Stop
End If
End If
If Not Sess1.Visible Then Sess1.Visible = TRUE
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events

Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen
Set MyArea = MyScreen.Area(5, 8, 5, 41)
MyArea.Select
Sess0.Screen.Copy
Sess1.Screen.MoveTo 3,23
Sess1.Screen.Paste
Sess1.Screen.WaitHostQuiet(g_HostSettleTime)
Sess1.Screen.Sendkeys("<Enter>")

AppActivate "SESSION2 - EXTRA! X-treme"

Do While sess0.Screen.OIA.Xstatus <> 0
DoEvents
Loop


System.TimeoutValue = OldSystemTimeout
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top