AutoHotkey Community

It is currently May 27th, 2012, 12:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: January 9th, 2011, 4:11 pm 
Offline

Joined: December 28th, 2005, 10:46 am
Posts: 99
Hi all of you,
I use, at work, an IBM 3270 mainframe emulator : myExtra! from Attachmate.
I want to use AHK_L to manage it. There is a COM interface in myExtra! that I (want to) use to get informations and to send commands. Before I used WS4AHK and (sorry erictheturtle) I want to go to AHK_L.

When I want to get information, it seems to work (even if the call need parameters).
But when I want to set informations and, for example, to send commands/keystrokes to the emulator, it fails.
I use what I done under WS4AHK (that works) and I try to translate it to make it work under AHK_L. I took :

Code:
WS_CursSend(WS_SC_Line, WS_SC_Col, WS_SC_TypeOfSend = 0, WS_SC_ToTransf = "", WS_SC_Ent = 0, WS_SC_Home = 0, WS_SC_Tab = 0)
  Put the cursor at WS_SC_Line, WS_SC_Col in the screen.
  Eventually send a string with SendKeys or Paste.
  Eventually send enter at the end.
*/
WS_CursSend(WS_SC_Line, WS_SC_Col, WS_SC_TypeOfSend = 0, WS_SC_ToTransf = "", WS_SC_Ent = 0)
{
   Tabul := "<Tab>"
   Enter := "<Enter>"
   Start := "<Home>"
   Global FEN_P_XT         ; Name of the window
   If !WinExist(FEN_P_XT)
      Return -4
   Else
      {
   ScrPos := VBStr(WS_SC_Line) . ", " . VBStr(WS_SC_Col)

   WS_Initialize()
   WS_Exec("Set Sys = CreateObject(""EXTRA.System"")")
   WS_Exec("Set Sess = Sys.ActiveSession")
   WS_Exec("Set MyScreen = Sess.Screen")

   If (WS_SC_Line and WS_SC_Col)
          WS_Exec("MyScreen.MoveTo" . ScrPos)

   If (WS_SC_TypeOfSend = 1 and WS_SC_ToTransf <> "")
      WS_Exec("MyScreen.SendKeys" . VBStr(WS_SC_ToTransf))

   If (WS_SC_TypeOfSend = 2 and WS_SC_ToTransf <> "")
      WS_Exec("MyScreen.Paste")

   If WS_SC_Ent
      WS_Exec("MyScreen.SendKeys" . VBStr(Enter))

    WS_Exec("Set Sys = Nothing")
    WS_Exec("Set Sess = Nothing")
    WS_Exec("Set MyScreen = Nothing")
    WS_Uninitialize()
    Return True
    }
}


But to send something to MyExtra! with AHK_L, I can't succeed, I get errors (they are commented) :

Code:
^F6::
a := AhkLCOM_mE_CursSend(23, 16, 1, "ctrep david", 1 )

AhkLCOM_mE_CursSend(AhkLCOM_mE_SC_Line, AhkLCOM_mE_SC_Col, AhkLCOM_mE_SC_TypeOfSend = 0, AhkLCOM_mE_SC_ToTransf = "", AhkLCOM_mE_SC_Ent = 0)
{
   Tabul := "<Tab>"
   Enter := "<Enter>"
   Start := "<Home>"
   Global FEN_P_XT

   If !omE := ComObjCreate("EXTRA.System")
       Return -4
   omE := omE.ActiveSession
   omE := omE.Screen

   ScrPos := AhkLCOM_mE_SC_Line . ", " . AhkLCOM_mE_SC_Col

   If (AhkLCOM_mE_SC_Line and AhkLCOM_mE_SC_Col)

; Here are the try I did with the MoveTo Method :
;      omE.MoveTo[ScrPos]                  ; Error : Non optionnal parameter
;      omE.MoveTo(ScrPos)                  ; Error : Non optionnal parameter
;      omE.MoveTo[AhkLCOM_mE_SC_Line, AhkLCOM_mE_SC_Col]      ; Error : Type isn't corresponding
;      omE.MoveTo(AhkLCOM_mE_SC_Line, AhkLCOM_mE_SC_Col)      ; Error : Type isn't corresponding
;      omE.MoveTo[ScrPos] := Result               ; Error : Type isn't corresponding
;      result := omE.MoveTo[ScrPos]               ; Error : Type isn't corresponding
;      result := omE.MoveTo(ScrPos)               ; Error : Type isn't corresponding



   If (AhkLCOM_mE_SC_TypeOfSend = 1 and AhkLCOM_mE_SC_ToTransf <> "")
      omE.SendKeys := AhkLCOM_mE_SC_ToTransf

   If (AhkLCOM_mE_SC_TypeOfSend = 2 and AhkLCOM_mE_SC_ToTransf <> "")
      omE.Paste

   If AhkLCOM_mE_SC_Ent
      omE.SendKeys := Enter
;      omE.SendKeys[Enter]
;      omE.SendKeys(Enter)

   omE := ""
   
   Return True
}


myExtra! help wrote:
MoveTo Method

Applies To Objects
Screen

Description
Moves the cursor to the specified location.
Certain VT hosts do not allow arbitrary cursor positioning, in which case this method will have no effect.

Syntax
object.MoveTo Row, Col [, Page]

Element Description
object The Screen object.
Row The row location.
Col The column location.
Page (optional) The page location.

Comments
To move the cursor to a position relative to its current one, use the MoveRelative method.


MoveTo Method Example

The example moves the cursor to a random row, column and page on the screen.

Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object

Set Sys = CreateObject("EXTRA.System")
' Assumes an open session
Set Sess = Sys.ActiveSession
Set MyScreen = Sess.Screen

For i = 1 to 10
Randomize
NewRow = Int(MyScreen.Rows*Rnd())+1
NewCol = Int(MyScreen.Cols*Rnd())+1
NewPage = Int(MyScreen.Pages*Rnd())+1
MsgBox "Move to " + Str$(NewRow) + "," + Str$(NewCol) + "."
MyScreen.MoveTo NewRow,NewCol,NewPage
Next
End Sub

Copyright 1996 - 2001, Attachmate Corporation. All rights reserved.


The errors are "Non optionnal parameter" or "The type isn't corresponding".
I don't know what does they means. I don't know how to send commands to the emulator. May be my syntax to set with AHK_L is not the good one.
Any ideas ?
I thank you in advance and sorry for the length of the message, but I suppose that note all of you knows the myExtra! VB...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2011, 9:48 pm 
Offline

Joined: December 28th, 2005, 10:46 am
Posts: 99
Is there anyone who can answer ? I think it's probably more an Object/COM notation under AHKL problem. Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 10th, 2011, 1:24 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
As i can see it and i automate Attatchmate your flaw is setting a value with sendkeys instead of passing it a string. It is after all a function not a property
omE.SendKeys( AhkLCOM_mE_SC_ToTransf )

For curser position i find it favorable when necesary to use
the row and col property of the screen object

related
http://www.autohotkey.com/forum/viewtop ... 373#363373

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, Google Feedfetcher, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group