Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/12/2017 in all areas

  1. No, of course not. Preferable way is to use function calls over assigning the result to variable. However, it really depends what the function returns. In your case the returned value is dllstruct. That struct (if not assigned to variable) exists only while that segment of code is executed. It's really not complicated, and very much logical.
    2 points
  2. Yes you are. First one is wrong because the structure you create inside _GetTokenPSid gets destroyed before used. Then you use pointer to it in _GetTokenUser1. Pointer to lost space. You're lucky if it don't crash.
    2 points
  3. [BUGFIX VERSION] - 6 Apr 24 Fixed: UDF failed if header colours were initialised but not specifically set. New UDF in the zip below. -------------------------------------------------------------------------------------- Note: This is a new recoded and expanded version of my earlier UDF of the same name. If you move to this new version there might well be several script-breaking changes, particularly when setting which columns are to be editable. Please read the "Beginner's Guide" and look at the included example scripts to see where things have changed. -------------------------------------------------------------------------------------- This UDF allows you to do much more with ListView controls (either native or UDF created): Edit the content with plain text, combos or date-time pickers - and edit the headers too Move rows within the ListView Drag rows both within the ListView and to other ListViews in the same GUI (or not as required) Insert and delete columns and rows Sort columns by simply clicking the header Colour individual ListView items and headers Only select a single cell rather then the entire row Save and load entire ListViews For the advanced user: If you use certain Windows message handlers (In particular WM_NOTIFY) in your script, please read the function headers for the equivalent handlers within the UDF. Here is the UDF, with 6 examples and the guide, in zip format: GUIListViewEx.zip Credit to: martin (basic drag code), Array.au3 authors (array functions), KaFu and ProgAndy (font function), LarsJ (colouring code) Happy to take compliments or criticism - preferably the former! M23
    1 point
  4. Jefrey

    multi threading

    Hi all! I've made this small UDF to emulate multithreading for AutoIt3. As we know, AU3 is singlethread and multithreading is only possible through direct ASM. This UDF provides a multithreading emulation through running multiple instances of your script. It also provides an easy way for sending and receiving messages between threads (temporary files are used). Example: Example 2: Docs: Download: Github ZIP Fork me on Github
    1 point
  5. Glad that it worked for you, we found that since Office 2013 we needed to include the key otherwise our signatures with our company logo and custom email stationary displayed as attachments rather than embedded within the email.
    1 point
  6. Great that you have a working solution now! I'm looking forward for your future questions
    1 point
  7. Bei genauer Betrachtung schließen sich OFT template und inline Bild aus, denn zuerst muss das Bild als Attachment (2) an die Mail (1) gehängt werden bevor sich der MailBody (3) auf das Bild beziehen kann. Leider werden die Schritte (1) und (3) eausgeführt, wenn die Mail mit dem OFT template erstellt wird. Derzeit habe ich also leider keine Lösung für Dein Problem.
    1 point
  8. Same result for me, I wonder if its because I have the following key set, can you test? Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\15.0\Outlook\options\mail] "Send Pictures With Document"=dword:00000001
    1 point
  9. You still can use a mail template as long as you set the same CID to the attachment. Details can be found here:
    1 point
  10. Weird because mine is showing with the image embedded and Einladung_Test.pdf as an attachment in gmail. Can you post the script you are using?
    1 point
  11. If you replace: _OL_ItemSave($oOutlook, $oItem, Default, $oftfilepath, $olTemplate, 3) with _OL_ItemSend($oOutlook, $oItem) _OL_Close($oOutlook) and comment out _pmailoutlooksendmail($oftfilepath), whats your result, I can confirm that both Outlook and Gmail display the inline image and the PDF as an attachment correctly named.
    1 point
  12. Sure! Please check example 4 in _OL_ItemCreate.au3 how to use CID.
    1 point
  13. $sString = '("usr/subSUB0:SAPLMEGUI:0015/subSUB3:SAPLMEVIEWS:1100/subSUB2:SAPLMEVIEWS:1200/subSUB1:SAPLMEGUI:1301/subSUB2:SAPLMEGUI:1303/tabsITEM_DETAIL/tabpTABIDT3")' msgbox(0, '' , number(StringMid($sString, StringInStr($sString, "SAPLMEGUI")+10, 4)) )
    1 point
  14. Just use "GetVersionString hresult(wstr;dword*);" And then Local $sVer $oRunInfo.GetVersionString($sVer, 65536) ConsoleWrite($sVer & @CRLF) Also dich the use of structs for guids when there you have "clsid" type available "GetInterface hresult(clsid;clsid;ptr*);" Local $pRuntimeHost $oRunInfo.GetInterface($sCLSID_CLRRuntimeHost, $sIID_ICLRRuntimeHost, $pRuntimeHost) Btw, it would be better to enumerate available runtimes and choose from there. Good job Danyfirex. :kiss:
    1 point
  15. Neither with Graphic functions nor with GDI you can smooth the drawn graphics - you have to use GDI+ and set the smoothing for the graphic context. There should plenty of examples either in the help file or here in the forum.
    1 point
  16. Pablos544, Welcome to the AutoIt forums. Use GUISwitch to select the GUI in which you want to create the controls. M23
    1 point
  17. LarsJ

    Accessing AutoIt Variables

    Array variables SafeArrayDisplay.au3 When the number of array elements exceeds one million the conversions between native AutoIt arrays and safearrays starts taking longer time. In some situations you may use a safearray throughout the code without the need to convert to a native AutoIt array at all. This means that you can skip the conversions completely. Or maybe you need more array elements than are supported by native AutoIt arrays. There is a limit around 16 million elements. There isn't such a limit for safearrays. In these situations you create the safearray with SafeArrayCreate function and fills out and manipulates the safearray directly. With recent updates in _ArrayDisplayEx based on virtual ListView it's easy to create a SafeArrayDisplay UDF to display the contents of a safearray in a virtual listview. In this very early version only safearrays of integers are supported. Safearrays of integers Examples\Demo examples\6) Safearrays of integers\ in the zip file in bottom of first post (goto top of second post and scroll up a little bit) contains five examples. Example 1 is about a native AutoIt array. Examples 2 - 5 is all about safearrays. Example1.au3 is a copy of the example in the code box in top of first post. A few timers are added to measure the execution time for different parts of the code. On my PC the 1D safearray of 16 million integers is filled out in about 25 milli seconds. Conversion to a native AutoIt array takes about 765 milli seconds (pretty fast because a safearray of integers is a very simpel array). The listview (_ArrayDisplayEx) shows up in less than 800 milli seconds. In Example2.au3 a 1D safearray of 100 million integers shows up in the listview (SafeArrayDisplay) in about 200 milli seconds. Assembler code is the same as in example 1. No conversions. In Example3.au3 a 2D safearray of 10 million rows and 10 columns (100 million elements) shows up in about 200 milli seconds. Assembler code in Example3-x86/x64.asm. Example4.au3: 50 million rows, 10 columns = 500 million elements. About 1 second. Example5.au3 must be run as 64 bit code and you need at least 8 GB RAM: 100 million rows, 10 columns = 1,000 million (one billion) elements. About 2 seconds.
    1 point
  18. This might be helpful: https://developer.github.com/v3/repos/releases/#get-the-latest-release
    1 point
  19. Can you try the following: Note you will need to fix the variable names in Word doc as the doc you uploaded is different to the Excel spreadsheet and Oft file Variables i.e. %$%VORNAME%$% %$%NACHNAME$%$ For testing I've commented out the _pmailoutlooksendmail, so this will create all the emails in your Drafts folder, this now correctly replaces the Oft body and subject text, and the Word text. #include <Excel.au3> #include <File.au3> #include <Array.au3> #include <IE.au3> #include <MsgBoxConstants.au3> #include <Word.au3> #include <AutoItConstants.au3> #include "sources\OutlookEX.au3" Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") Global $sTMP_FilePath = @TempDir&"\PMail" If FileExists($sTMP_FilePath) Then DirRemove($sTMP_FilePath & "\") Global $sSRC_XLS_FilePath = @ScriptDir&"\liste.xlsx" Global $sSRC_DOC_FilePath = @ScriptDir&"\Einladung_Test.docx" Global $sTMP_PDF_FilePath = $sTMP_FilePath & "\Einladung_Test.pdf" Global $sSRC_OFT_FilePath = @ScriptDir&"\Einladung_Test.oft" Global $sTMP_OFT_FilePath = $sTMP_FilePath & "\Einladung_Test.oft" Global $aUserInfo = _pmailexcelreadfile($sSRC_XLS_FilePath) For $i = 1 To UBound($aUserInfo) - 1 FileCopy($sSRC_OFT_FilePath, $sTMP_OFT_FilePath, 9) _pmailwordreplacetext($sSRC_DOC_FilePath, $sTMP_PDF_FilePath, $i) Sleep(2000) Local $aAttachments[1]=[$sTMP_PDF_FilePath] _pmailoutlookpreparemail($aUserInfo[$i][0], "Exklusive Einladung zum Meet'n Greet für %$%Vorname%$% %$%NACHNAME%$%", $sTMP_OFT_FilePath, $aAttachments, "some-mailadress@googlemail.com", $i) Sleep(2000) ; _pmailoutlooksendmail(@TempDir&"\PMail\Einladung_Test.oft") Sleep(2000) DirRemove($sTMP_FilePath, $DIR_REMOVE) Next Func _pmailexcelreadfile($sWorkbook, $vRange = Default) Local $oExcel =_Excel_Open(False) Local $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, True) Local $aWorkbook = _Excel_RangeRead($oWorkbook, Default, $vRange) _Excel_BookClose($oWorkbook) _Excel_Close($oExcel, False, True) If Not IsArray($aWorkbook) Then Exit MsgBox(16,"Error!","Excelfile could not be read to an array. Please check your excelfile and your range!") Return $aWorkbook EndFunc Func _pmailwordreplacetext($sDoc, $sPDFDoc, $iUserInfo = 1) Local $oWord = _Word_Create(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _pmailwordreplacetext", "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oDoc = _Word_DocOpen($oWord, $sDoc, False, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _pmailwordreplacetext", "Error opening '"& $sDoc & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) For $oStoryRange In $oDoc.StoryRanges _Word_DocFindReplace($oDoc, $aUserInfo[0][1], $aUserInfo[$iUserInfo][1], Default, $oStoryRange) _Word_DocFindReplace($oDoc, $aUserInfo[0][2], $aUserInfo[$iUserInfo][2], Default, $oStoryRange) While 1 If IsObj($oStoryRange.NextStoryRange) Then $oStoryRange = $oStoryRange.NextStoryRange _Word_DocFindReplace($oDoc, $aUserInfo[0][1], $aUserInfo[$iUserInfo][1], Default, $oStoryRange) _Word_DocFindReplace($oDoc, $aUserInfo[0][2], $aUserInfo[$iUserInfo][2], Default, $oStoryRange) Else ExitLoop EndIf WEnd Next _Word_DocSaveAs($oDoc, $sPDFDoc, $wdFormatPDF) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _pmailwordreplacetext", "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Word_DocClose($oDoc) _Word_Quit($oWord) EndFunc Func _pmailoutlookpreparemail($recipientadress, $subject, $oftfilepath, $attachmentsarray, $bcc="", $iUserInfo = 1) Local $oOutlook = _OL_Open() Local $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", $oftfilepath) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating the mail in folder. @error = " & @error & ", @extended = " & @extended) $oItem.HTMLBody = StringReplace($oItem.HTMLBody, $aUserInfo[0][1], $aUserInfo[$iUserInfo][1]) Local $aItem = _OL_ItemGet($oOutlook, $oItem, Default, "Subject") If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemGet", "Error accessing current item. @error = " & @error & ", @extended = " & @extended) $aItem[1][1] = StringReplace(StringReplace($aItem[1][1], $aUserInfo[0][1], $aUserInfo[$iUserInfo][1]), $aUserInfo[0][2], $aUserInfo[$iUserInfo][2]) _OL_ItemModify($oOutlook, $oItem, Default, "Subject=" & $aItem[1][1]) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemModify", "Error accessing current item. @error = " & @error & ", @extended = " & @extended) $oItem1 = _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olTo, $recipientadress) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemRecipientAdd", "Error adding recipient. @error = " & @error & ", @extended = " & @extended) If $bcc <> "" Then $oItem2 = _OL_ItemRecipientAdd($oOutlook, $oItem, Default, $olBCC, $bcc) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemRecipientAdd", "Error adding bbc recipient. @error = " & @error & ", @extended = " & @extended) EndIf If(UBound($attachmentsarray)>0) Then _OL_ItemAttachmentAdd($oOutlook, $oItem, Default, $attachmentsarray) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemAttachmentAdd ", "Error adding attachment'. @error = " & @error & ", @extended = " & @extended) EndIf _OL_ItemSave($oOutlook, $oItem, Default, $oftfilepath, $olTemplate, 3) EndFunc Func _pmailoutlooksendmail($oftfilepath) $oOutlook = _OL_Open() $oItem = _OL_ItemCreate($oOutlook, $olMailItem, Default, $oftfilepath) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended) _OL_ItemSend($oOutlook, $oItem) _OL_Close($oOutlook) EndFunc Func _ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
    1 point
  20. I mean all lines reported by the COM error handler (e.g. logic.au3 (65) : ==> COM Error intercepted !) should show a line where COM objects are being processed. So error messages and source code lines do not fit together.
    1 point
  21. Strange Line 53 is where you call _pmailwordsaveaspdf(@TempDir&"\PMail\Einladung_Test.docx", @TempDir&"\PMail\Einladung_Test.pdf") and the rest of the lines reported by the COM error handler are comment lines. Do you have an idea what happens here?
    1 point
  22. Can you please post the current version of your script? Adding the COM error handler changed the line numbers.
    1 point
  23. You need to add a COM error handler to grab the error. The following code will tell us exactly what goes wrong. ; Error monitoring. This will trap all COM errors while alive. Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc") ... Your script goes here ; User's COM error function. Will be called if COM error occurs Func _ErrFunc($oError) ; Do anything here. ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>_ErrFunc
    1 point
  24. If there is no active Inspector then the next operation fails. Try this one: $oInspector = $oOL.ActiveInspector If @error Then MsgBox(0, "Error", "ActiveInspector returned @error = " & @error) Exit EndIf $oItem0 = $oInspector.CurrentItem
    1 point
  25. I assume you do not use the latest version of the OutlookEX UDF which does not support Default as parameter. Use $oItem = _OL_ItemCreate($oOL, $olMailItem, "", $oftfilepath)
    1 point
  26. You should fix _OL_ItemCreate in function _pmailoutlooksendmail as well.
    1 point
  27. You're syntax is wrong for _OL_ItemCreate _OL_ItemCreate($oOL, $olMailItem, $oftfilepath) It should be: _OL_ItemCreate($oOL, $olMailItem, Default, $oftfilepath)
    1 point
  28. You can replace all strings within a document including Text Boxes using the following. Func _pmailwordreplacetext($wordfilepath, $snrarray) ; Create application object Local $oWord = _Word_Create(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open document Local $oDoc = _Word_DocOpen($oWord, $wordfilepath) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error opening '"&$wordfilepath&"'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Replace operation ; ***************************************************************************** ;DEBUG!!! ;_ArrayDisplay($snrarray) For $i = 0 To UBound($snrarray) - 1 For $oStoryRange In $oDoc.StoryRanges _Word_DocFindReplace($oDoc, $snrarray[$i][0], $snrarray[$i][1], Default, $oStoryRange) While 1 If IsObj($oStoryRange.NextStoryRange) Then $oStoryRange = $oStoryRange.NextStoryRange _Word_DocFindReplace($oDoc, $snrarray[$i][0], $snrarray[$i][1], Default, $oStoryRange) Else ExitLoop EndIf WEnd Next Next ;MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Paragraph control character successfully replaced.") ; Save document _Word_DocSave($oDoc) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", _ "Error saving the Word document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocSave Example", "Document successfully saved as '" & _ ; $oDoc.FullName & "'") _Word_DocClose($oDoc) _Word_Quit($oWord) EndFunc
    1 point
  29. At the moment I do not have spare time to look for a solution for the text box problem. Maybe next weekend Can you please post the full _OL_ItemCreate statement you use?
    1 point
  30. OP = original post, actually it should have been post #3? Its just that mailer.au3 doesn't have reference to Word replace?
    1 point
  31. Is the script for replacing the word document separate? Or are you just using the function in the OP?
    1 point
  32. I can't test at the moment but IIRC the function only works on the "main text" of the document including tables. Header/Footer do not get processed. So this could be true for textboxes as well. Will need to check tomorrow.
    1 point
  33. Can you give us an example Doc and names you want to replace?
    1 point
  34. It just means that either the "Word to be replaced" is the same as the "Word replacement" or that it couldn't find the word to replace. For example if you look at the example below, it would fail on "Thursday" and also the last array item as Monday has already been replaced by Sunday. Hope that makes sense #include <Word.au3> Local $aWeekDays[7][2] = [["Monday", "Sunday"],["Tuesday", "Saturday"],["Wednesday","Friday"],["Thusday","Thusday"],["Friday","Wednesday"],["Saturday","Tuesday"],["Monday","Sunday"]] _pmailwordreplacetext(@ScriptDir & "\WordReplace.docx", $aWeekDays) Func _pmailwordreplacetext($wordfilepath, $snrarray) ; Create application object Local $oWord = _Word_Create(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; Open document Local $oDoc = _Word_DocOpen($oWord, $wordfilepath) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", _ "Error opening '"&$wordfilepath&"'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;~ ***************************************************************************** ;~ Replace operation ;~ ***************************************************************************** ;~ DEBUG!!! For $i = 0 To UBound($snrarray) - 1 _Word_DocFindReplace($oDoc, $snrarray[$i][0], $snrarray[$i][1]) If @error Then ConsoleWrite("Replace " & $snrarray[$i][0] & " with " & $snrarray[$i][1] & " - @error = " & @error & ", @extended = " & @extended & @CRLF) Next MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocFindReplace Example", "Paragraph control character successfully replaced.") _Word_DocClose($oDoc) _Word_Quit($oWord) EndFunc WordReplace.docx content Monday Tuesday Wednesday Thursday Friday Saturday Sunday
    1 point
  35. The @error codes are described in the AutoIt help file.
    1 point
  36. Can you please post the line where you call _Wird_DocFindReplace?
    1 point
×
×
  • Create New...