Jump to content

StSchnell

Active Members
  • Posts

    31
  • Joined

  • Last visited

About StSchnell

  • Birthday 06/16/1964

Profile Information

  • Location
    Oberirsen - Germany
  • WWW
    http://www.stschnell.de
  • Interests
    SAP GUI Scripting

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

StSchnell's Achievements

Seeker

Seeker (1/7)

2

Reputation

  1. Hello community, the error is still present at the actual version of AutoIt 3.3.10.2. I check it in a 64-bit Windows 7 environment and it chrashes. The version 3.3.6.1 works without any failures. Cheers Stefan
  2. Hello community, here is my script integration library ScriptX. With this library is it very easy possible to integrate AutoIt inside SAPs programming language ABAP. Here an ABAP example: "-Begin----------------------------------------------------------------- Program ZSCRIPTX. "-Constants--------------------------------------------------------- Constants CrLf(2) Type c Value %_CR_LF. Constants SW_SHOWNORMAL Type i Value 1. "-Variables--------------------------------------------------------- Data oScriptX Type OLE2_OBJECT. Data Buffer Type String Value ''. Data WorkDir Type String Value ''. Data FileName Type String Value ''. Data rc Type i Value 0. "-Macros------------------------------------------------------------ Define _. Concatenate Buffer &1 CrLf Into Buffer. End-Of-Definition. Define Flush. Call Function 'AC_SYSTEM_FLUSH' Exceptions Others = 1. End-Of-Definition. "-Main-------------------------------------------------------------- Create Object oScriptX 'ScriptX'. If sy-subrc <> 0 Or oScriptX-Handle = 0 Or oScriptX-Type <> 'OLE2'. Call Function 'ZSCRIPTXDLL'. Create Object oScriptX 'ScriptX'. EndIf. If sy-subrc = 0 And oScriptX-Handle > 0 And oScriptX-Type = 'OLE2'. Call Method Of oScriptX 'About'. Flush. Call Function 'ZAUTOIT3EXE'. "-AutoIt Script begin--------------------------------------------------- _ 'MsgBox(0, "AutoIt", "Version " & @AutoItVersion)'. "-AutoIt Script end----------------------------------------------------- Call Method cl_gui_frontend_services=>get_sapgui_workdir Changing SAPWORKDIR = WorkDir Exceptions Others = 1. Concatenate WorkDir '\Version.au3' Into FileName. Flush. Call Method Of oScriptX 'WriteFile' Exporting #1 = FileName #2 = Buffer. Flush. Call Method Of oScriptX 'Shell' = rc Exporting #1 = 'AutoIt3.exe' #2 = 'Version.au3' #3 = SW_SHOWNORMAL #4 = 1. Flush. Free Object oScriptX. EndIf. "-End------------------------------------------------------------------- Good integration. Cheers Stefan
  3. Hello community, SAP offers different connectors to develop ABAP compatible components and applications. JCo for Java environments, NCo for dotNET languages and the NetWeaver RFC SDK for C++. But what's up if you work neither with Java or dotNET environments nor with C++? Here is another alternative, CCo - the COM Connector for SAP. CCo is a COM library and offers wrappers around all functions of the SAP NetWeaver RFC library. So it is possible to use all functionalities of the SAP NetWeaver RFC library inside any language which is COM-enabled, like AutoIt. With CCo it is easily possible to use the SAP NetWeaver RFC functions inside AutoIt. Hint: CCo has at the moment experimental character. Don't use it in production environments. Hint: CCo needs SAP RFC SDK, you find it here, SAP passport required. You find CCo here: cco.stschnell.de You find a few examples how to use CCo here, in particular three examples in AutoIt Script how to call BAPI functions - here BAPI_USER_ * functions. Cheers Stefan
  4. Hello community, here is an example code of a server application for an SAP system in AutoIt language. My problem is, that this AutoIt example crashs after the first function call of ABAPCall from an ABAP report. I try two methods: Use DllCallbackGetPtrUse CreateThread and get the address of the thread.But both methods crashs at the same code position, look at the example below. Is there any other way to use this kind of multithreading? Thanks for hints. Cheers Stefan ;-Begin----------------------------------------------------------------- ;-Directives---------------------------------------------------------- AutoItSetOption("MustDeclareVars", 1) ;-Constants----------------------------------------------------------- Const $RFC_OK = 0 Const $RFC_RETRY = 14 ;-Variables----------------------------------------------------------- Dim $SAP, $ABAPCall, $ptrABAPCall, $hDesc, $conPar[3] Dim $ptrConPar[3], $ConParPtr, $i, $rc, $hCon ; Dim $hThread ;-Function CreateThread----------------------------------------------- Func CreateThread($Handle) Local $Ret $Ret = DllCall("kernel32.dll", "handle", "CreateThread", "ptr", 0, _ "dword", 0, "long", DllCallbackGetPtr($Handle), "ptr", 0, _ "long", 0, "int*", 0) Return $Ret[0] EndFunc ;-Function GetThreadAddr---------------------------------------------- Func GetThreadAddr($hThread) Local $ThreadAddr = DllStructCreate("ptr") DllCall("NTDLL.dll", "long", "NtQueryInformationThread", _ "handle", $hThread, "long", 9, "ptr", _ DllStructGetPtr($ThreadAddr), "ulong", 4, "ulong*", 0) Return Number(DllStructGetData($ThreadAddr, 1)) EndFunc ;-Function OutputDebugString------------------------------------------ Func OutputDebugString($OutputString) Local $strOut = String($OutputString) DllCall("kernel32.dll", "none", "OutputDebugStringW", "wstr", _ $strOut) EndFunc ;-Function ABAPCall--------------------------------------------------- Func ABAPCall() MsgBox(0, "", "Ja") Return $RFC_OK ;-Important hint-------------------------------------------------- ;- ;- Program crashs here, because AutoIt is not able to use multi ;- threading with SAP NetWeaver RFC library ;- ;----------------------------------------------------------------- EndFunc ;-Main---------------------------------------------------------------- $SAP = ObjCreate("COMNWRFC") If IsObj($SAP) Then $ABAPCall = DllCallbackRegister("ABAPCall", "long", "") $hDesc = $SAP.RfcCreateFunctionDesc("ABAPCall") If $hDesc And $ABAPCall Then ;-Define RFC_CONNECTION_PARAMETER structures-------------------- For $i = 0 To 2 $conPar[$i] = DllStructCreate("wchar name[16];wchar value[16]") Next ;-Set RFC_CONNECTION_PARAMETER---------------------------------- DllStructSetData($conPar[0], "name", "program_id") DllStructSetData($conPar[0], "value", "AUTOITSERVER") DllStructSetData($conPar[1], "name", "gwhost") DllStructSetData($conPar[1], "value", "ABAP") DllStructSetData($conPar[2], "name", "gwserv") DllStructSetData($conPar[2], "value", "sapgw00") ;-Switch RFC_CONNECTION_PARAMETER strings to pointers----------- $ptrConPar = DllStructCreate("ptr;ptr;ptr;ptr;ptr;ptr") DllStructSetData($ptrConPar, 1, DllStructGetPtr($conPar[0], "name")) DllStructSetData($ptrConPar, 2, DllStructGetPtr($conPar[0], "value")) DllStructSetData($ptrConPar, 3, DllStructGetPtr($conPar[1], "name")) DllStructSetData($ptrConPar, 4, DllStructGetPtr($conPar[1], "value")) DllStructSetData($ptrConPar, 5, DllStructGetPtr($conPar[2], "name")) DllStructSetData($ptrConPar, 6, DllStructGetPtr($conPar[2], "value")) $ptrABAPCall = Number(DllCallbackGetPtr($ABAPCall)) ;-Alternative----------------------------------------------------------- ; ; $hThread = CreateThread($ABAPCall) ; If $hThread Then ; $ptrABAPCall = GetThreadAddr($hThread) ; If $ptrABAPCall Then ; ;----------------------------------------------------------------------- $rc = $SAP.RfcInstallServerFunction("", $hDesc, $ptrABAPCall) If $rc = $RFC_OK Then $ConParPtr = Number(DllStructGetPtr($ptrConPar)) $hCon = $SAP.RfcRegisterServer($ConParPtr, 3) If $hCon Then While $rc = $RFC_OK Or $rc = $RFC_RETRY $rc = $SAP.RfcListenAndDispatch($hCon, 1) Select Case $rc = $RFC_OK OutputDebugString("RFC_OK") Case $rc = $RFC_RETRY OutputDebugString("RFC_RETRY") EndSelect Sleep(256) Wend EndIf EndIf $SAP.RfcDestroyFunctionDesc($hDesc) DllCallbackFree($ABAPCall) ; DllCall("kernel32.dll", "boolean", "CloseHandle", _ ; "handle", $hThread) ; EndIf ; EndIf EndIf $SAP = 0 EndIf ;-End-------------------------------------------------------------------
  5. Hello Márcio, sorry for my late answer. With SAP GUI Scripting you can automatically manipulate nearly all objects of SAP GUI for Windows, also field values. Here an example how to use the ok-field: ;-Begin----------------------------------------------------------------- ;-Variables----------------------------------------------------------- Dim $SAPROT, $SapGuiAuto, $application, $connection, $session $SAPROT = ObjCreate("SapROTWr.SAPROTWrapper") If Not IsObj($SAPROT) Then Exit EndIf $SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI") If Not IsObj($SapGuiAuto) Then Exit EndIf $application = $SapGuiAuto.GetScriptingEngine() If Not IsObj($application) Then Exit EndIf $connection = $application.Children(0) If Not IsObj($connection) Then Exit EndIf $session = $connection.Children(0) If Not IsObj($session) Then Exit EndIf $session.findById("wnd[0]/tbar[0]/okcd").text = "/nse16" $session.findById("wnd[0]").sendVKey(0) ;-End------------------------------------------------------------------- To analyze SAP GUI and to find out the IDs and names of the objects look here http://scn.sap.com/docs/DOC-32728 and here http://scn.sap.com/docs/DOC-40265 > cool AutoIt analyzer. Hope it helps a little bit. Cheers Stefan
  6. Hello Bennet, cool solution. What is the content of the variable $RFCExec? If you like you can try this: http://scn.sap.com/docs/DOC-40480 CCo is a COM-Wrapper around SAP NetWeaver RFC library. At the moment I try to create an example with AutoIt as SAP server application, hope it will work. Cheers Stefan
  7. Hello community, the SAP GUI Scripting offers excellent possibilities to automate your activities on the SAP presentation server. It is possible to record, replay and emulate the user input on an SAP GUI for Windows. It is very interesting for tests or only for recurring activities. To simplify the creation of SAP GUI scripts, there is the Scripting Tracker. It consists of two components. On one side of an Analyzer and on the other side of a Recorder. The Analyzer replaces the SAP GUI development tools and provides additional functionalities. The Analyzer component is fully available in the Lite version, which can be downloaded here: bebo.stschnell.de. The Recorder replaces the SAP GUI Scripting recorder and offers also extended functionalities. E.g. beside VBScript, it supports AutoIt and other scripting languages. With Scripting Tracker it is very easy possible to record your SAP GUI for Windows activities as AutoIt script. So it offers new horizons of integration between an SAP system and your presentation server. To get an impression look this video: http://youtu.be/jZQP6vwedsc Cheers Stefan
  8. Hello community, the SAP GUI for Windows offers an SAP GUI Scripting recorder to record manual activities. Press Alt+F12 to open the Local Layout menu and choose Script recording and playback item to open the recorder. The activities are stored in VBScript language, but it is very easy to use the recording results with AutoIt. It is only necessary to set a $ sign before the session variable and to set a stub in front of the recording results. Here an example for a login: ;-Begin----------------------------------------------------------------- ;-Variables----------------------------------------------------------- Dim $SAPROT, $SapGuiAuto, $application, $connection, $session $SAPROT = ObjCreate("SapROTWr.SAPROTWrapper") If Not IsObj($SAPROT) Then Exit EndIf $SapGuiAuto = $SAPROT.GetROTEntry("SAPGUI") If Not IsObj($SapGuiAuto) Then Exit EndIf $application = $SapGuiAuto.GetScriptingEngine() If Not IsObj($application) Then Exit EndIf $connection = $application.Children(0) If Not IsObj($connection) Then Exit EndIf $session = $connection.Children(0) If Not IsObj($session) Then Exit EndIf ;-SAP GUI Scripting from recorder starts here--------------------------- $session.findById("wnd[0]/usr/txtRSYST-MANDT").text = "099" $session.findById("wnd[0]/usr/txtRSYST-BNAME").text = "Hugo" $session.findById("wnd[0]/usr/pwdRSYST-BCODE").text = "Bambi" $session.findById("wnd[0]/usr/txtRSYST-LANGU").text = "DE" $session.findById("wnd[0]/tbar[0]/btn[0]").press() ;-End------------------------------------------------------------------- The $session.findById code is direct from the SAP GUI Scripting recorder. With a search and replace it is very easy to set a $ in front of session. You find the equivalent posting in the SAP Community Network here. Cheers Stefan
  9. Hello Aber and Water, there are a few ways to communicate with an SAP system. SAP GUI Scripting is only one to automate your user input. My suggestion is the same as Waters: Talk with your admin to enable SAP GUI Scripting on the application server you need. With the TAC RZ11 he must set the value from the parameter sapgui/user_scripting to TRUE. And activate the option Scripting in your local SAP GUI Logon. If it is also not possible, talk with your admin too. There is no way around this security options. You can use SAP GUI without enabled SAP GUI Scripting, you find a few (older) examples in my knowledge collection - Tips for AutoIt. But it is not comfortable and if there are some changes in the UI, it could be problematically. With AutoIt you can also use the SAP GUI ActiveX components or the SAP NetWeaver RFC SDK, if you know the RFC function modules or BAPI interfaces. Cheers Stefan
  10. Hello water, Chromwell is right, it seems to be a problem with the new AutoIt version. Check with the following program ;-Begin----------------------------------------------------------------- $oDia = ObjCreate("COMDialog") If IsObj($oDia) Then $Result = 0 While $Result <> 1 $Result = $oDia.WindowEvent() Select Case $Result = 1 MsgBox(0, "Dialog", "Ende") Case $Result = 2 MsgBox(0, "Dialog", "Test1 Button betätigt") Case $Result = 3 MsgBox(0, "Dialog", "Test2 Button betätigt") EndSelect Wend EndIf ;-End------------------------------------------------------------------- with this ActiveX DLL http://www.stschnell.de/temp/COMDialog.zip, it is one of my test libraries. It shows only a dialog with two buttons and the event loop of the AutoIt program catches the message. It works perfect with 3.3.6.1 but it crashes with the actual version. Cheers Stefan
  11. Hello community, it is very easy to control a client system from SAP© ABAP© with AutoItX. Use the transaction code SOLE to register AutoItX on the SAP© system and type in the fields the following content: OLE Application: AutoItX3.ControlCLSID: {1A671297-FA74-4422-80FA-6C5D8CE4DE04}CLSID Type Lib: {F8937E53-D444-4E71-9275-35B64210CC3B}OLE-Objectname: AutoItX3.ControlLanguage: DEText: Scripting language designed for automating the Windows GUIDo not forget to register AutoItX on the client system via regsvr32.exe AutoItX.dll. Now you can use AutoIt from ABAP©, look at the simple example, it call notepad and type a text in it: INCLUDE OLE2INCL. DATA AutoIt TYPE OLE2_OBJECT. DATA pid TYPE i. CREATE OBJECT AutoIt 'AutoItX3.Control'. CALL METHOD OF AutoIt 'Run' = pid EXPORTING #1 = 'notepad.exe'. CALL METHOD OF AutoIt 'WinWaitActive' EXPORTING #1 = 'Unbenannt - Editor'. CALL METHOD OF AutoIt 'Send' EXPORTING #1 = 'Hallo von ABAP'. FREE OBJECT AutoIt. You see how easy it is. Cheers Stefan
  12. Hello AlexII, I do not check your code, but I mean you forgot the condition and your loop works for ever: Do While|Until Condition ... Loop or Do ... Loop While|Until Condition Look at the example in the help file. Cheers Stefan P.S. Is not necessary to say sorry for your english knowledge, it is good.
  13. Hello iROKA, try this: ;-Begin----------------------------------------------------------------- #Include "..\Include\IE.au3" #Include "..\Include\WindowsConstants.au3" #Include "..\Include\GUIConstantsEx.au3" Dim $INVITESTAB, $AnotherTab, $HEADERS, $GAME, $oIE, $GUI _IEErrorHandlerRegister() $GUI = GUICreate("MobMySpace Chat", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + _ $WS_EX_MDICHILD) GUISetFont(8, 400) GUICtrlCreateTab(10, 10, 620, 560) ;-FirstTab---------------------------------------------------------- $AnotherTab = GUICtrlCreateTabItem("Another") ;-SecondTab--------------------------------------------------------- $INVITESTAB = GUICtrlCreateTabItem("Help") $HEADERS = GUICtrlCreateLabel("Bug reports go to " & _ "admin@mobmyspace.com Please Put " & $GAME & _ " 'BUG REPORT' in your title.", 25, 40, 600) $oIE = _IECreateEmbedded() $GUIActiveX = GUICtrlCreateObj($oIE, 25, 60, 590, 495) _IENavigate($oIE, "www.mobmyspace.com/chat/flashchat.php") ;-EndOfTab------------------------------------------------------------ GUICtrlCreateTabItem("") GUISetState();Show GUI ;-MainLoop------------------------------------------------------------ While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop EndIf Sleep(25) Wend ;-End------------------------------------------------------------------- Solve this your problem? Cheers Stefan
  14. Hello community, the following code work perfect: ;-Begin----------------------------------------------------------------- Dim $rc Dim $Title = "AutoItX3Lib Object Library" Dim $Class = "HH Parent" Dim $WinTitle = "[TITLE:" & $Title & "; CLASS:" & $Class & "]" Dim $TVClass = "SysTreeView32" Dim $TVClassNN = "SysTreeView321" Dim $TV = "[CLASS:" & $TVClass & "; CLASSNN:" & $TVClassNN & "]" $rc = ControlTreeView($WinTitle, "", $TV, "GetSelected") MsgBox(0, "ReturnCode", $rc) ;-End------------------------------------------------------------------- But nearly the same code with AutoItX does not work: Const TVClass = "SysTreeView32" Const TVClassNN = "SysTreeView321" Dim TV TV = "[CLASS:" & TVClass & "; CLASSNN:" & TVClassNN & "]" Dim RC RC = oAutoIt.ControlTreeView(Title, "", TV, "GetSelected") MsgBox RC I get an error: Wrong number of arguments or invalid assignment. Is there something wrong with the code or is it a bug in the library, in ControlTreeView command? Thanks for tips. Cheers Stefan
  15. Hello Leopardfist, try the Help Kit COM Assistant to analyze and create a documentation about any COM-DLL you want. With this tool it is very easy to get detailed information about a COM-DLL. Hope it helps. Cheers Stefan
×
×
  • Create New...