Hello community,

everbody knows GuiXT – the comfortable library to individualize the SAP screens. It is standard part of the SAP GUI for Windows and you can use it without any problems. You can find more information about GuiXT here.

GuiXT offers the possibility to use function calls from DLLs inside a GuiXT script, with the command Call. Here an GuiXT script example how to use the Windows API function ShellExecute. On this way you can execute any file you like.



  //-With InputAssistant------------------------------------------------


        Set V[SW_HIDE] "0"
        Set V[SW_SHOWNORMAL] "1"
        Set V[SW_NORMAL] "1"
        Set V[SW_SHOWMINIMIZED] "2"
        Set V[SW_SHOWMAXIMIZED] "3"
        Set V[SW_MAXIMIZE] "3"
        Set V[SW_SHOWNOACTIVATE] "4"
        Set V[SW_SHOW] "5"
        Set V[SW_MINIMIZE] "6"
        Set V[SW_SHOWNA] "8"
        Set V[SW_RESTORE] "9"
        Set V[SW_SHOWDEFAULT] "10"
        Set V[SW_FORCEMINIMIZE] "11"
        Set V[SW_MAX] "11"

      Set V[hWnd] "0"
      Set V[Operation] "open"
      Set V[File] "Test.vbs"
      Set V[Parameters] ""
      Set V[Directory] "C:\Dummy"
      Set V[ShowCmd] V[SW_SHOWNORMAL]

      Call "ShellExecuteA" dll="shell32.dll" In="&V[hWnd]" In="&V[Operation]" In="&V[File]" In="&V[Parameters]" In="&V[Directory]" In="&V[ShowCmd]" Out="rc"

  //-Without InputAssistant---------------------------------------------

      Call "ShellExecuteA" dll="shell32.dll" In="0" In="open" In="Test.vbs" In="" In="C:\Dummy" In="1" Out="rc"

To report this post you need to login first.


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

    1. Stefan Schnell Post author

      Hello James,

      sure, try this:

      Call "ShellExecuteA" dll="shell32.dll" In="0" In="open" In="cmd.exe" In="/C START /WAIT Test.vbs" In="C:\Dummy" In="1" Out="rc"

      Use instead the script your executable program.



      1. James Wilkins

        Thanks, but that doesn’t work.  The “Call …” exits immediately. It’s the call I want to block until the executed program completes.  I don’t see the point of the call command to be asynchronous in a synchronous script…!?

        1. Stefan Schnell Post author

          Hello James,

          thanks for your reply. You are right, ShellExecute returns immediately, independently if the started programs runs or not. Sorry for my failure.

          Here a possible solution with a DLL:

          ; Begin-----------------------------------------------------------------
          ; PureBasic Dynamic Link Library (DLL) for GuiXT
          ; Author: Stefan Schnell
          ; ----------------------------------------------------------------------
            ; Function expShell---------------------------------------------------
              ProcedureDLL.i expShell(inFile.s, inParam.s, inDir.s)
                ; Variables-------------------------------------------------------
                  Protected resShell.i
                resShell = RunProgram(inFile, inParam, inDir, #PB_Program_Wait)
                ProcedureReturn resShell
          ; End-------------------------------------------------------------------

          This function can call via GuiXT

            Call "expShell" dll="LibShell.dll" In="cmd.exe" In="/K" In="C:\Dummy"

          And in this case the execution of the script waits until the cmd.exe is terminated.




Leave a Reply