Jump to content
chrweav86

Leveraging existing autoit script to open AS400 PCOM

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?

 

Share this post


Link to post
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)
 

Share this post


Link to post
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

  • Similar Content

    • By nooneclose
      Hello everyone, I am wondering if and how it is possible to connect my AutoIt script to a different email in my outlook. I have two different accounts when I open outlook. The first which my script always connects to is my own email while the second is a group email account. How or can I make the script connect to the second one and access its inbox instead of mine? This is all work related so no funny business here. 
      Global $oOutlook = _OL_Open() ; Store all the Unread emails into an array Global $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, _ "[UnRead]=True", "Subject", "Maintenance Request from Eagle's Nest", "EntryID,Subject", "", 1) ; Display the array of unRead emails If IsArray($aItems) Then ;_ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Unread mails") Else MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", _ "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended) EndIf ; Get the number of unread emails Global $numberOfUnRead = UBound($aItems, $UBOUND_ROWS) - 1 ;MsgBox("", "Number of Unread emails", $numberOfUnRead) ConsoleWrite("Number of unread emails: " & $numberOfUnRead & @CRLF) I might be missing some code in the post but my code works It's just so long I don't want to post all 2300+ lines. 
      Thank you for the help I greatly appreciate this community. 
    • By TheDcoder
      Hello everyone, it has been a while since I have been involved in a serious AutoIt-related project discussion in the forums here, so it feels good to be back at it
      First a little backstory, a few months back (or a year ago) I made the switch to Linux from Windows... there were several reasons as to why I was motivated to do it, but the main things was Windows 10 was getting out of hand, it didn't offer enough freedom out of the box (restrictive settings, greedy defaults etc.) and had several issues with all kinds of software, many of them mysteriously hard to fix.
      I did have Linux installed as my secondary operating system for few years at that point and I began to see me regularly use it more than Windows, so one day I went ahead and said "fork it", I have stuck to Linux from that point on as my primary operating system.
      Windows is still installed in my computer and I also have a virtual machine with the latest version of Windows 10 on it, primarily because I still use Windows to write software using AutoIt as part of my job (freelance).
      I was pretty sad about the fact that I could no longer use AutoIt to make stuff for myself (since it doesn't run on Linux), I missed sharing code with the community here, this was a great hobby for me as AutoIt is what got me start with programming (even though I had tried several times to get into other languages before, those attempts were never as successful as what I have done in AutoIt).
      In Linux there is no language which is similar to AutoIt unfortunately, there are a few things which come close but are not on par with AutoIt's ease of use. As some of you may know, I have recently started working on other projects using the C language, it is a great step I have taken and I am learning a lot... but it is still not easy to create quick scripts or programs in C, due to the amount of configuration and dedication it takes to make a C program, also it is not ideal for sharing as multiple source files are involved. And on top of that you still have to deal with platform-specific APIs since C is a low-level language.
      (Getting back to core of this topic's subject)
      To solve this issue and to sharpen my programming skills, I could start working on an alternate cross-platform implementation of the AutoIt language which should be backwards compatible with the current AutoIt v3 on C
      The primary aim in the beginning is to implement all the basic functions (File, String, Numbers etc.)  in AutoIt so that it is possible to make basic and fundamental scripts which would work in both Windows and Linux
      The main features would be:
      Cross-platform (Linux and Windows with the possibility supporting of Mac) Backward compatible with AutoIt 3 Byte-code based interpreter instead of source interpreter Easy to use (just like the current AutoIt) The advantage of having a byte-code based interpreter is that it makes the interpreter lighter and faster since it doesn't have to deal with parsing the source code, this would also open the door for some compile time optimizations... another bonus thing for those who don't like their source code present inside the compiler binaries is that it should be impossible to get hands on the original source code, this of course does not mean that decompilation can be stopped... it merely means that anyone decompiling would have to reconstruct the code from the byte-code.
       
      We can later on implement GUI related functions and maybe even automation related functions if the project gets enough traction
      I am adding a poll to keep track of people who are willing to invest in this project or would like to see it come into existence. Welcome any comments, suggestions etc.
      Obviously I will have a lot to learn and my work might interfere with this at times, but with enough interest I can see myself working on this to deliver a very basic prototype which could be used with basic scripts.
       
    • By FordsFinest
      I have a macro that works well on 95% of computers. However, I am running into an issue on a couple computers where the _GUICtrlTreeView_ClickItem clicks the wrong item (an item or two below the correct one). Both the ExpandItem and SelectItem command work fine, just the click item is off on these computers (and only their user names). I'm not sure if some temp file somewhere is causing an issue or what. Note, using ONLY selectitem results in inconsistent focusing (item appears focused but the next command won't always work correctly). Hence my need to use the clickitem command.
      Any help would be appreciated.
      _GUICtrlTreeView_Expand($hWnd, $Array2[$i]) ;Expand $model Sleep(250) _GUICtrlTreeView_SelectItem($hWnd, $Array2[$i]) ;Select $model Sleep(150) _GUICtrlTreeView_ClickItem($hWnd, $Array2[$i]) ;Click $model Sleep(150) EndIf  
    • By nacerbaaziz
      hello all, and welcome to this tool
      the NB-Password_generator is a small tool which allow you to create a strong passwords
      with this tool you can create a random passwords using :
      1. capital letters
      2. small letters
      3. numbers
      4. symbols
      be sure that you can check any option that  you want and uncheck what you don't want to use
      this tool allow you to create a password from 6 letters to 150 lettersNB-Password_generator.zip
      at the end please accept my greetings
      am waiting for your commants
    • By Codenameglassy
      Hello so i need help, so i have a while(1) Loop but i want to restart the loop form the begining if a specific event occurs or what i want on screen is occured.. i want  to restart the loop from beginning , leaving the rest of the script.
      But if the event didnt occur it follows the rest of the script and goes on while loop..
×
×
  • Create New...