Jump to content

Leveraging existing autoit script to open AS400 PCOM


 Share

Recommended Posts

Here is an existing AS400 PCOM script that I have: 

#include-once

#cs ----------------------------------------------------------------------------
 UDF Header Title: _PCOMM
 UDF Header Version: 0.1.0
 AutoIt Version: 3.3.8.1
 Author:         Jason S. - Jewelry Supply, Inc.
 Script Function: PCOMM UDF Header
                    For use with IBM AS/400 - IBM OS/400 - IBM System i - IBM i application system.
                    This PCOMM UDF Header targets ASW - an ERP application suite written in IBM's RPG language (yuck!),
                    although it will work for any AS/400 system and is not ASW specific.
                    PCOMM allows injection of keystrokes into the datastream of
                    a running terminal/console application ("Green Screen" Console Emulator).
                        - Assumes Session 'A' but can be overriden using the aswConnect() function.
                    PCOMM allows observing of characters in the datastream of a running
                    terminal/console application ("Green Screen" Console Emulator).
                        - Assumes Session 'A' but can be overriden using the aswConnect() function.
#ce ----------------------------------------------------------------------------

Global $Session = "A"

Global $Ps
Global $Oia

; Specify session to connect to
Func aswSetSession($nSession)

    $Session = $nSession

EndFunc

; Connect to ASW
; @param $nSession - Specify session to connect to. Ex: "A"
Func aswConnect($nSession = $Session)

    $Obj_ConnMgr = ObjCreate("PCOMM.autECLConnMgr")
    $OBJ_EmulSession = ObjCreate("PCOMM.autECLSession")
    $OBJ_EmulSession.SetConnectionByName($nSession)
    $Ps = $OBJ_EmulSession.autECLPS
    $Oia = $OBJ_EmulSession.autECLOIA

EndFunc

; Send Data to ASW
; if $rownum and $colnum are not specified, defaults to the cmd line
Func aswSend($keys, $rownum = 20, $colnum = 7, $inhibit = 1)

    $Ps.SendKeys($keys, $rownum, $colnum)
    if $inhibit = 1 Then
        While $Oia.InputInhibited <> 0
        WEnd
    EndIf
    $Oia.WaitForInputReady()

EndFunc

; Get Data from ASW
Func aswGet($row, $col, $length)

    $info = $Ps.GetText($row,$col,$length)
    return $info

Endfunc

; Check which page we are on
; @param $page - Page to see if we are on. Ex: "DMR30101" == Sales Order Maintenance page
Func checkScreen($page, $rownum = 1, $colnum = 72, $length = 8)

    If StringInStr(aswGet($rownum, $colnum, $length), $page) Then
        Return 1
    Else
        Return 0
    EndIf

EndFunc

I would like to use it launch a connection to the AS400. I have an executable that I run with an hod file. Do I just need to run the exe and hod file then run the session connect function and send keys function to pass credentials?

 

Link to comment
Share on other sites

The issue I am trying to resolve is where the IBM Phoenix app opens a second tab for a second session. This breaks it for my client using the AutoIT wrapper they are using. I am trying to use the above script in addition with the following:


Global $username = "test"
Global $password = "test"

Run("C:\Users\Public\IBM\ClientSolutions\Start_Programs\Windows_x86-64\acslaunch_win-64.exe c:\users\Public\IBM\ClientSolutions\dvphxapp.hod")
;aswConnect() - testing this bit
;Step One
;WinWaitActive("Signon to IBM i")- tried using Windows forms

;ControlSetText("Signon to IBM i","","[CLASSNN:Edit1]",$username)- tried using WIndows forms for text entry

Send($username)
Send("{TAB}")
Send($password)
Send("{TAB}")
;Send("{ENTER}")


;Step 2 - logging into Green screen console
aswSend(ENTER)
aswSend($username)
aswSend(TAB)
aswSend($password)
aswSend($ENTER)
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...