Jump to content

Rainer2

Members
  • Posts

    5
  • Joined

  • Last visited

Everything posted by Rainer2

  1. Hello trancexx, sorry for the delay, but I was really busy with other projects. I just tried out your piece of code: The console says: $iTypeInfoCount = 1 Since this worked, you are probably right about the cause of the crashes. Anyway, I consider the problem solved for now, since I was able to access OneNote with Windows PowerShell. If you have any ideas how to do the same thing with AutoIt, here is my code (Warning: PowerShell syntax, not AutoIt! Uses a .NET assembly and a reference parameter!) Add-Type -AssemblyName Microsoft.Office.Interop.OneNote $global:OneNote = New-Object -type "Microsoft.Office.Interop.OneNote.ApplicationClass" $PowerShellFlashCardPage = "{MyGUID}" $myXml = "" $OneNote.GetHierarchy($PowerShellFlashCardPage, [int][Microsoft.Office.Interop.OneNote.HierarchyScope]::hsChildren, [ref] $myXml) $myXml now contains precisely the Xml data I am after. If you have any idea how to do this with AutoIt, don't hesitate to let me know. (But that's very low priority, since my problem is solved now.) Thank you for your help with this, I sure learned a lot in the process!
  2. Thank you for your help, Trancexx. I tried out your code. With the commented part, the object gets created - at least the message box doesn't complain. Unfortunately, the script doesn't write anything on the console. After a while, the console says: !>12:46:44 AutoIT3.exe ended.rc:-1073741819 >Exit code: -1073741819 Time: 23.192 Also, "CloseNotebook" is not working anymore. I experimented with the code you gave me and changed it like this: ; Work with object now ;... ;Close a notebook (no out-parameters necessary, used to work without using "AutoItObject") msgbox(0, "CloseNotebook", "before CloseNotebook") $oOneNote.CloseNotebook("{MyGuid}") msgbox(0, "CloseNotebook", "after CloseNotebook") $aCall = $oOneNote.GetHierarchy("", 4, "") MsgBox(0, "GetHierarchy", "after GetHierarchy") $sHierarchy = $aCall[3] ConsoleWrite("Hierarchy = " & $sHierarchy & @CRLF) ;... This piece of code shows the message boxes before and after the call to "CloseNotebook" - but doesn't actually close the notebook. I also don't get an error message that something went wrong; the messagebox "after CloseNotebook" shows up immediately. The message box "after GetHierarchy" never gets shown. Instead, the aforementioned return code -1073741819 shows up on the console after a few seconds. Any ideas what I'm doing wrong?
  3. I know, since it's tomorrow now: Happy new year! I have taken a first look at AutoItObject. Looks like a great tool to create and access objects with AutoIt. I have been working with object-oriented languages on and off since the late 1980s when Smalltalk was the "hot" OO language and C++ was still a C preprocessor named "C with classes"; I'm more than willing to work with AutoItObject, but unfortunately I can't see how this is going to solve my problem from above, as I am trying to manipulate an existing COM object called "OneNote.Application". I want to get XML content from a call to GetHierarchy(). Could you point me in the right direction? Which AutoItObject function(s) should I give a closer look in order to retrieve the out-parameters from GetHierarchy()? This is my only problem, as AutoIt cannot access out-parameters via COM. (As I said before, I am not very proficient with COM, so forgive me if the question is dumb.) Thanks in advance for any hints, and "Happy new year" again! Rainer
  4. Hello trancexx, thank you for the hint. I will check AutoItObject out right now. Kind regards, Rainer P.S.: I must confess that I'm a bit surprised that my problem is not within the reach of "normal" AutoIt; does that mean that everybody who wants to do out-parameters with a COM-dll needs to work with AutoItObject?
  5. Hello everybody, I am stuck at my futile attempts to access Microsoft OneNote 2010 with the COM interface. I need the help of you AutoIt COM experts out there. :-) Here is the situation: I want to retrieve content from OneNote in XML format. However, all of the OneNote methods that provide XML data use out-parameters, which means that I have to use DllCall() instead of ObjCreate(). This is how far I got on my own: First, I can access OneNote from AutoIt with ObjCreate(), using this (obvious) line of code: Local $objOneNote = ObjCreate("Onenote.Application") This works fine; I used this line of code _Assert(IsObj($objOneNote)) to check that $objOneNote actually points to a COM object. Furthermore, I was able to close an open notebook with this call to CloseNotebook, a method of the OneNote API: $objOneNote.CloseNotebook("{MY_GUID}") Basically, it seems that I can access OneNote via COM. However, when I want to retrieve OneNote content as XML data, I need to use a method like GetHierarchy(), which uses an out-parameter to pass the content as an XML string. The GetHierarchy method has the following signature: HRESULT GetHierarchy( [in]BSTR bstrStartNodeID, [in]HierarchyScope hsScope, [out]BSTR * pbstrHierarchyXmlOut); (source: http://msdn.microsoft.com/en-us/library/ms788684(office.12).aspx) Since out-parameters don't work with ObjCreate, I have to use DllCall. I am trying to do something like this (Warning: The following line of code is wrong): Local $intRetVal = DllCall("Onenote.Application", "long", "GetHierarchy", "str", "", "int", 4, "str *", $sXml) $sXml - the out-parameter - comes back empty. I have two questions about this: First, I am fully aware that "Onenote.Application" has to be replaced with the correct name of the dll. How can I find the name of a dll, when I only know that "Onenote.Application" is the correct string to work with ObjCreate()? Second, are there any other problems or errors with my attempt to translate the signature of GetHierarchy() into a DllCall()? I apologize if my questions are stupid; I am not really a COM expert. (In other words: Please be gentle, it's my first time with DllCall :-) Any help will be greatly appreciated.
×
×
  • Create New...