Sign in to follow this  
Followers 0
Chromwell

Problem with newest Autoit 3.3.8.1 - COM / SAP

12 posts in this topic

With older Autoit Versions my script was working fine and i don´t know how i should change my script to work again...

Basically my problem section does nothing more then selecting some menus in SAP then pressing 2 buttons in following popup-windows and the 3rd popup is a file save dialog...

My script always stops executing after the 2nd button press (it is pressed, but it won´t get any further....)

Connection to SAP is initiated with _SAPSessAttach("") from the SAP UDF but the commands are sent directly via the COM interface to SAP.

_SAPSessAttach("")
ConsoleWrite("Setze $AnalyseBlatt ..." & @CRLF)
$AnalyseBlatt = @ScriptDir & "\test.xls"
ConsoleWrite("Lösche $AnalyseBlatt ..." & @CRLF)
If FileExists($AnalyseBlatt) Then
  FileDelete($AnalyseBlatt)
EndIf
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).expandNode("1000")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).selectItem("4000", "COL01")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).ensureVisibleHorizontalItem("4000", "COL01")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).topNode = ("0001")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).doubleClickItem("4000", "COL01")
ConsoleWrite("Btn0 Press..." & @CRLF)
$SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press
ConsoleWrite("Btn5 Press..." & @CRLF)
$SAP_Session.findById("wnd[1]/tbar[0]/btn[5]").press
;--------- SCRIPT STOPS HERE, without any error, it just hangs....
ConsoleWrite("Warte auf Speichern unter Dialog..." & @CRLF)
WinWait("Speichern unter")
ConsoleWrite("Setze Edit auf Analyseblatt..." & @CRLF)
ControlSetText("Speichern unter", "", "[CLASS:Edit; INSTANCE:1]", $AnalyseBlatt)
Sleep(2000)
ControlClick("Speichern unter", "", "[CLASS:Button; INSTANCE:2]")

Share this post


Link to post
Share on other sites



The script breaking changes section here describes that methods require paranthesis.

So maybe you have to change

$SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press
to
$SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press()

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Even with this change the script halts after the btn5 press without any error ... when i cancel the file dialog that appears after the script pressed the button, the script goes on.

The same script runs smooth with autoit-v3.3.6.1. :)

Share this post


Link to post
Share on other sites

As you are working with objects to need to implement a COM error handler. Please check function ObjEvent. There you'll find an example.

After btn5 is pressed I would at least check the error code returned in @error and @extended.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

There´s no COM error, that´s the problem... the script just hangs after btn5 is pressed without an error... :)

I can´t even exit the script from the task-tray when it hangs after btn5 press ... it exits when i cancel the dialog in SAP that comes after it pressed the btn5...

#include <../include/SAP.au3>
#include <IE.au3>
_IEErrorHandlerRegister ("MyErrFunc")

_test()
func _test()
_SAPSessAttach("")
ConsoleWrite("Setze $AnalyseBlatt ..." & @CRLF)
$AnalyseBlatt = @ScriptDir & "test.xls"
ConsoleWrite("Lösche $AnalyseBlatt ..." & @CRLF)

If FileExists($AnalyseBlatt) Then
FileDelete($AnalyseBlatt)
EndIf

$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).expandNode("1000")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).selectItem("4000", "COL01")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).ensureVisibleHorizontalItem("4000", "COL01")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).topNode = ("0001")
$SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell" ).doubleClickItem("4000", "COL01")

ConsoleWrite("Btn0 Press..." & @CRLF)
$SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press()
ConsoleWrite("Btn5 Press..." & @CRLF)
$SAP_Session.findById("wnd[1]/tbar[0]/btn[5]").press()

;--------- SCRIPT STOPS HERE, without any error, it just hangs....

ConsoleWrite("Warte auf Speichern unter Dialog..." & @CRLF)
WinWait("Speichern unter")
ConsoleWrite("Setze Edit auf Analyseblatt..." & @CRLF)
ControlSetText("Speichern unter", "", "[CLASS:Edit; INSTANCE:1]", $AnalyseBlatt)
Sleep(2000)
ControlClick("Speichern unter", "", "[CLASS:Button; INSTANCE:2]")

EndFunc

Func MyErrFunc()
    ; Important: the error object variable MUST be named $oIEErrorHandler
    $ErrorScriptline = $oIEErrorHandler.scriptline
    $ErrorNumber = $oIEErrorHandler.number
    $ErrorNumberHex = Hex($oIEErrorHandler.number, 8)
    $ErrorDescription = StringStripWS($oIEErrorHandler.description, 2)
    $ErrorWinDescription = StringStripWS($oIEErrorHandler.WinDescription, 2)
    $ErrorSource = $oIEErrorHandler.Source
    $ErrorHelpFile = $oIEErrorHandler.HelpFile
    $ErrorHelpContext = $oIEErrorHandler.HelpContext
    $ErrorLastDllError = $oIEErrorHandler.LastDllError
    $ErrorOutput = ""
    $ErrorOutput &= "--> COM Error Encountered in " & @ScriptName & @CR
    $ErrorOutput &= "----> $ErrorScriptline = " & $ErrorScriptline & @CR
    $ErrorOutput &= "----> $ErrorNumberHex = " & $ErrorNumberHex & @CR
    $ErrorOutput &= "----> $ErrorNumber = " & $ErrorNumber & @CR
    $ErrorOutput &= "----> $ErrorWinDescription = " & $ErrorWinDescription & @CR
    $ErrorOutput &= "----> $ErrorDescription = " & $ErrorDescription & @CR
    $ErrorOutput &= "----> $ErrorSource = " & $ErrorSource & @CR
    $ErrorOutput &= "----> $ErrorHelpFile = " & $ErrorHelpFile & @CR
    $ErrorOutput &= "----> $ErrorHelpContext = " & $ErrorHelpContext & @CR
    $ErrorOutput &= "----> $ErrorLastDllError = " & $ErrorLastDllError
    MsgBox(0,"COM Error", $ErrorOutput)
    SetError(1)
    Return
EndFunc  ;==>MyErrFunc
Edited by Chromwell

Share this post


Link to post
Share on other sites

I inserted some more error checking an simplified the COM error handler. Could you please give it a try?

Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")

_test()

Func _test()
    _SAPSessAttach("")
    ConsoleWrite("Setze $AnalyseBlatt ..." & @CRLF)
    $AnalyseBlatt = @ScriptDir & "test.xls"
    ConsoleWrite("Lösche $AnalyseBlatt ..." & @CRLF)

    If FileExists($AnalyseBlatt) Then
        FileDelete($AnalyseBlatt)
    EndIf

    $SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell").expandNode("1000")
    ConsoleWrite("Result of 1st findByID...: " & @error & "-" & @extended & @CRLF)
    $SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell").selectItem("4000", "COL01")
    ConsoleWrite("Result of 2nd findByID...: " & @error & "-" & @extended & @CRLF)
    $SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell").ensureVisibleHorizontalItem("4000", "COL01")
    ConsoleWrite("Result of 3rd findByID...: " & @error & "-" & @extended & @CRLF)
    $SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell").topNode = ("0001")
    ConsoleWrite("Result of 4th findByID...: " & @error & "-" & @extended & @CRLF)
    $SAP_Session.findById("wnd[0]/shellcont[0]/shell/shellcont[2]/shell").doubleClickItem("4000", "COL01")
    ConsoleWrite("Result of 5th findByID...: " & @error & "-" & @extended & @CRLF)

    ConsoleWrite("Btn0 Press..." & @CRLF)
    $SAP_Session.findById("wnd[1]/tbar[0]/btn[0]").press()
    ConsoleWrite("Result of Btn0 Press...: " & @error & "-" & @extended & @CRLF)
    ConsoleWrite("Btn5 Press..." & @CRLF)
    $SAP_Session.findById("wnd[1]/tbar[0]/btn[5]").press()
    ConsoleWrite("Result of Btn5 Press...: " & @error & "-" & @extended & @CRLF)

    ;--------- SCRIPT STOPS HERE, without any error, it just hangs....

    ConsoleWrite("Warte auf Speichern unter Dialog..." & @CRLF)
    WinWait("Speichern unter")
    ConsoleWrite("Setze Edit auf Analyseblatt..." & @CRLF)
    ControlSetText("Speichern unter", "", "[CLASS:Edit; INSTANCE:1]", $AnalyseBlatt)
    Sleep(2000)
    ControlClick("Speichern unter", "", "[CLASS:Button; INSTANCE:2]")

EndFunc   ;==>_test

; User's COM error function. Will be called if COM error occurs
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Here are the outputs from scite... script hangs on new autoit... :)

Old Autoit:

>Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "H:\AutoIT\Projects\CQTS EACDX\crap.au3"  
Setze $AnalyseBlatt ...
Lösche $AnalyseBlatt ...
Result of 1st findByID...: 0-0
Result of 2nd findByID...: 0-0
Result of 3rd findByID...: 0-0
Result of 4th findByID...: 0-0
Result of 5th findByID...: 0-0
Btn0 Press...
Result of Btn0 Press...: 0-0
Btn5 Press...
Result of Btn5 Press...: 0-0
Warte auf Speichern unter Dialog...
Setze Edit auf Analyseblatt...
+>11:57:41 AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 7.160

New Autoit:

>Running:(3.3.8.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "H:\AutoIT\Projects\CQTS EACDX\crap.au3"
Setze $AnalyseBlatt ...
Lösche $AnalyseBlatt ...
Result of 1st findByID...: 0-0
Result of 2nd findByID...: 0-0
Result of 3rd findByID...: 0-0
Result of 4th findByID...: 0-0
Result of 5th findByID...: 0-0
Btn0 Press...
Result of Btn0 Press...: 0-0
Btn5 Press...

Share this post


Link to post
Share on other sites

Looks like a bug. Problem is that the Devs need a skript to reproduce the problem. Unfortunately not every of them has SAP available.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Ok, thanks for your effort water!

Perhaps i can reproduce it in an other application and i can submit a bug report or so... :)

Share this post


Link to post
Share on other sites

I checked Trac #2056 and maybe there was a similar problem with Excel.

I don't know when the first Beata will be released but a the moment I would stick with 3.3.6.1 in your case.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

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

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
Sign in to follow this  
Followers 0

  • Similar Content

    • PauloRodrigues
      By PauloRodrigues
      I need to select an item from a SAP combobox, could anyone help me or did something like that? I tried to use some AutoIt functions but without success.
      When i try to identify the combobox with au3Info, this is the return:


      Could anyone help me with this challange?
    • WiorDi37
      By WiorDi37
      Hello, Everyone!
      I want when clicking the exit button the window will close. If content changes upon exit the program will automatically choose not save.
      Look forward to the help, thanks.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> $GUI = GUICreate("Form1", 220, 119, 192, 124, $WS_SYSMENU) GUISetFont(10, 400, 0, "Tahoma") GUICtrlCreateGroup("Chuẩn bị trình chiếu", 16, 16, 185, 65) $ok_Button = GUICtrlCreateButton("Ok", 32, 48, 75, 25) $exit_Button = GUICtrlCreateButton("Exit", 112, 48, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ok_Button ShellExecute(@MyDocumentsDir&'\Dich-thuat\Short-Document.pdf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Data and Computer Communications (Eighth Edition) - Google Chrome") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Document.rtf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Document.rtf [Compatibility Mode] - Word") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Presentation1.pptx', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Presentation1.pptx - PowerPoint") MouseClick("left", 1381, 886, 1) Sleep(2000) MsgBox(64, "Thông báo", "Đã chuẩn bị xong") Case $exit_Button WinClose("Presentation1.pptx - PowerPoint") ;I need help handling this place Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd  

    • badcoder123
      By badcoder123
      Hey everyone,
      I've been messing around with some new things and adlibs look extremely useful/interesting, however, I can't seem to get it to work.. Here's what I have
      HotKeySet("{F1}", "_Exit") $qCount = 1 Global $_Timer AdlibRegister($_Timer, 1000) AdlibUnRegister($_Timer) While 1 SoundPlay(@WindowsDir & "\media\tada.wav", 1) $qCount += 1 ToolTip('"Tada" has been played ' & $qCount & " times",200,200) WEnd Func _Timer() Local Static $iCount += 1 ConsoleWrite($iCount) If $iCount = 20 Then ConsoleWrite("iCount is at " & $iCount) EndFunc Func _Exit() Exit EndFunc Basically I want it to call the _Timer function but it doesn't seem to work :/ any ideas?
    • DagSa
      By DagSa
      Try to find a solution for help files to my autoit executable.
      Its installed from simple XP-POS cash computers to desktop with windows 7, 8, 10.
      The compiled AutoIt program itself work everywhere, but the help file??
      I need a help file called from from the program and I don't really know what working best in all OS platforms.
      1. A wordfile is helpful enough, but word is not installed everywhere.
      2. RTF is very big files with pictures.
      3. I could save it as pdf, but not all have it either.
      4. Tried  .MHT file, but downside is browser could cover hole screen if browser closed this way. I have not found any way to resize it to specific size when open up.
      5. Use of IE.au3 lib. Well it could open mht files ,but always got question about use it as default browser or not. Think this also make IE browser lose control so I could not resize.
      6. Look at making a  .CHM file, but I don't think its the future do use that format. (.hlp is no no and old)

      Any tips of do it in autoit or make a call to open up in some nice format working everywhere.
       
    • au3leecher
      By au3leecher
      Hellow everybody,
      I tryed to manipulate a game called "Assault Cube" which is a easy beginning in coding. I run the code but the wished value doesn't change, i don't understand why.
      The Pointers are fine, I checked that the pointers don't change every time while restart the game.
      My Code:
      <snip>
      _____________________________________________________________________________________________________________________________________________________________________________________________
      Checklist:
      The Offsets are 18C & 4
      In Cheat Engine: ("ac_client.exe"+0010F418) <- Pointer
      4 Bytes = 'dword'