Skip to Content

Hello community,

I posted here about a new version of AutoIt Scripting Language and here an example how to use AutoItX, a COM library with a subset of AutoIt script language. I generated an ABAP wrapper class for the AutoItX library, so it is easily to use the AutoItX commands inside ABAP, e.g. you can use the code completion of the ADT or SE80. You can download the wrapper class here.

Here a simple example which opens Notepad editor, writes some text and closes it:

“-Begin—————————————————————–

  Program Z_TEST.

    “-Variables———————————————————

      Data AutoItX Type Ref To zAutoItX3.

      Data ShowFlag Type i.

      Data Version Type String.

      Data Result Type i.

      Data OutText Type String.

    “-Main————————————————————–

      Create Object AutoItX.

      If AutoItX->LoadLib( ) = 1.

        AutoItX->Version( Importing Result = Version ).

        AutoItX->SW_RESTORE( Importing Result = ShowFlag ).

        AutoItX->Run( Exporting strRun = ‘notepad.exe’ strDir = ”

          nShowFlag = ShowFlag ).

        AutoItX->WinWait( Exporting strTitle = ‘Unbenannt – Editor’

          strText = ” nTimeOut = 5 Importing Result = Result ).

        AutoItX->WinActivate( strTitle = ‘Unbenannt – Editor’

          strText = ” ).

        OutText = `Hello World from ` && sy-sysid &&

          ` with AutoItX version ` && Version.

        AutoItX->Send( Exporting strSendText = OutText nMode = 0 ).

        AutoItX->Sleep( Exporting nMilliSeconds = 2500  ).

        AutoItX->WinKill( Exporting strTitle = ‘Unbenannt – Editor’

          strText = ” Importing Result = Result ).

        AutoItX->FreeLib( ).

      EndIf.

“-End——————————————————————-

/wp-content/uploads/2015/07/001_752157.jpg

Enjoy it.

Cheers

Stefan

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply