Leaderboard
Popular Content
Showing content with the highest reputation on 11/13/2016 in all areas
-
trof, Really? And how do you think you are going to manage that? M231 point
-
1 point
-
Insert Values to Array Column
antonioj84 reacted to l3ill for a topic
I assume you were going for something like this? #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <Array.au3> $hello= "123" ; 3 column load [row][column] Local $aItems1 [4] =["IP","SUB","Gateawy","DNS"] _ArrayDisplay($aItems1) Local $aItems[4][4] ;_ArrayDisplay($aItems) For $i = 0 To UBound($aItems) - 1 For $j = 0 To UBound($aItems1) - 1 ;~ $aItems[$iI][$iJ] = $iI &"-"& $ij $aItems[$j][$i] = $aItems1[$j] & $hello _ArrayDisplay($aItems) Next Next _ArrayDisplay($aItems)1 point -
Should be something like: Global $wdNumberGallery = 2 $oRange.ListFormat.ApplyListTemplateWithLevel($oWord.ListGalleries($wdNumberGallery).ListTemplates(1), True) Listformat is described here: https://msdn.microsoft.com/en-us/library/ff195913.aspx I still need to check how to retrieve ListGalleries/Templates (xx above)1 point
-
This script ends right after the MsgBox is closed so am unsure what you are trying to say here. In case you mean that the letter e doesn't close the MsgBox then: MsgBox() is a blocking function and indeed can't be interupted by a HotKeySet(). Workaround is to build your own MsgBox() func with a GUI. In your case it would have never worked anyways since the HotKey isn't set yet when the MsgBox() is displayed. Jos1 point
-
About themes ...
JLogan3o13 reacted to BrewManNH for a topic
It's not easy, but it's a better way to learn to build a GUI in my opinion. I can visualize, very roughly, where the controls will end up on the GUI, and then I just tweak the settings if they're off. The problem I have with all of the form creators out there for AutoIt is that your stuck with the authors coding style rather than your own and you then still have to rewrite what code they spit out, so I don't see much in the way of a time savings. For me, they're good for aligning a bunch of controls quickly and easily, but not much else. I've only briefly used some of them, so I don't know their full potential, so I can only go by what I have seen and how I write code.1 point -
SaeidN, Is this the behaviour you wish to see - any previous selections of the same app or order are cleared: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> #include <Array.au3> Global $iCount = 5 Global $sCombo_Data = "|Notepad|Paint|Calc|IE|AutoIt" ; Note use of leading "|" so that previous loads are cleared Global $sCombo_Order = "|1|2|3|4|5|6|7|8|9" Global $aCombo_App[$iCount], $aCombo_Place[$iCount] Global $iStyle = BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL) $Form1 = GUICreate("RunProgs", 373, 283, 192, 124) For $i = 0 To $iCount - 1 $aCombo_App[$i] = GUICtrlCreateCombo("", 24, 40 + (32 * $i), 145, 25, $iStyle) GUICtrlSetData(-1, $sCombo_Data) $aCombo_Place[$i] = GUICtrlCreateCombo("", 200, 40 + (32 * $i), 145, 25, $iStyle) GUICtrlSetData(-1, $sCombo_Order) Next $RunBtn = GUICtrlCreateButton("Run selected in order", 112, 216, 131, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RunBtn Case Else For $i = 0 To $iCount -1 ; Check if App combo If $nMsg = $aCombo_App[$i] Then ; Recent app selection $sChosen = GUICtrlRead($nMsg) ; Now check all other combos and clear them if the same thing selected For $j = 0 To $iCount - 1 If $j = $i Then ; Do nothing Else ; Same content as recent selection If GUICtrlRead($aCombo_App[$j]) = $sChosen Then ; Clear the current combo selection GUICtrlSetData($aCombo_App[$j], $sCombo_Data) EndIf EndIf Next ElseIf $nMsg = $aCombo_Place[$i] Then ; Recent order selection $sChosen = GUICtrlRead($nMsg) ; Now check all other combos and clear them if the same thing selected For $j = 0 To $iCount - 1 If $j = $i Then ; Do nothing Else ; Same content as recent selection If GUICtrlRead($aCombo_Place[$j]) = $sChosen Then ; Clear the current combo selection GUICtrlSetData($aCombo_Place[$j], $sCombo_Order) EndIf EndIf Next EndIf Next EndSwitch WEnd Or do you mean that once an option is chosen it is removed from the other combos options? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ComboConstants.au3> Global $iCount = 5 Global $sCombo_Data = "|Notepad|Paint|Calc|IE|AutoIt" ; Note use of leading "|" so that previous loads are cleared Global $sCombo_Order = "|1|2|3|4|5|6|7|8|9" Global $aCombo_App[$iCount], $aCombo_Place[$iCount], $aCombo_App_Data[$iCount], $aCombo_Place_Data[$iCount] Global $iStyle = BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL) For $i = 0 To $iCount - 1 $aCombo_App_Data[$i] = $sCombo_Data $aCombo_Place_Data[$i] = $sCombo_Order Next $Form1 = GUICreate("RunProgs", 373, 283, 192, 124) ; Initial fill For $i = 0 To $iCount - 1 $aCombo_App[$i] = GUICtrlCreateCombo("", 24, 40 + (32 * $i), 145, 25, $iStyle) GUICtrlSetData(-1, $sCombo_Data) $aCombo_Place[$i] = GUICtrlCreateCombo("", 200, 40 + (32 * $i), 145, 25, $iStyle) GUICtrlSetData(-1, $sCombo_Order) Next $RunBtn = GUICtrlCreateButton("Run selected in order", 112, 216, 131, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $RunBtn Case Else For $i = 0 To $iCount -1 ; Check if App combo If $nMsg = $aCombo_App[$i] Then ; Recent app selection $sChosen = GUICtrlRead($nMsg) ; Now remove from all other combos For $j = 0 To $iCount - 1 If $j = $i Then ; Do nothing Else ; Read current content of combo and add a trailing "|" $sContent = $aCombo_App_Data[$j] & "|" ; Remove chosen item and trim trailing "|" $aCombo_App_Data[$j] = StringTrimRight(StringReplace($sContent, "|" & $sChosen & "|", "|"), 1) ; Read current setting $sCurrent = GUICtrlRead($aCombo_App[$j]) ; And reload combo GUICtrlSetData($aCombo_App[$j], $aCombo_App_Data[$j], $sCurrent) EndIf Next ElseIf $nMsg = $aCombo_Place[$i] Then ; Recent order selection $sChosen = GUICtrlRead($nMsg) ; Now remove from all other combos For $j = 0 To $iCount - 1 If $j = $i Then ; Do nothing Else ; Read current content of combo and add a trailing "|" $sContent = $aCombo_Place_Data[$j] & "|" ; Remove chosen item and trim trailing "|" $aCombo_Place_Data[$j] = StringTrimRight(StringReplace($sContent, "|" & $sChosen & "|", "|"), 1) ; Read current setting $sCurrent = GUICtrlRead($aCombo_Place[$j]) ; And reload combo GUICtrlSetData($aCombo_Place[$j], $aCombo_Place_Data[$j], $sCurrent) EndIf Next EndIf Next EndSwitch WEnd M231 point
-
Dear mLipok Many Thanks, Just to share an example based on your _QPDF_Example_Lite_1_HelloWorld, In this version i'm trying to stamp some pdf documents using AddImageFromFile and DrawImage functions. For this example we need a .png image with transparent background in the same folder The image (a scan signature or stamp) can be arranged for example with Gimp: right click over the image > layers > transparency > Color to Alpha > right click over the color label > select blank > save the file as image.png > uncheck 'save the value of transparent pixels'. #include "QuickPDF.au3" Local $sFileName = @ScriptDir & "\Example_HelloWorld.pdf" Local $sFileName2 = @ScriptDir & "\Example_HelloWorld_Stamped.pdf" Local $oQP _QPDF_UseErrorHandler() _QPDF_NewLibraryPath_Lite("C:\Program Files (x86)\Debenu\PDF Library\Lite\DebenuPDFLibraryLite1114.dll") _QPDF_LoadFromFile_Lite($oQP, $sFileName) $oQP.SetOrigin($__eQPDF_SORIGIN_TopLeft); $oQP.SetMeasurementUnits($__eQPDF_MUNITS_Milimeters) $oQP.SetTextSize(10); $oQP.DrawText(30, 180, "Hello world from AutoIt (Line 4)") $oQP.SetTextSize(10) $oQP.DrawTextBox(100, 190, 100, 300, "This text was drawn using the DrawTextBox function. Similar to the DrawText function except that the alignment can be specified and line wrapping occurs.", 1) $oQP.SetTextColor(0.9, 0.2, 0.5) $oQP.SetTextSize(30) $oQP.DrawText(10, 200, "Big and Colorful.") Local $InFileName = "image.png" $oQP.AddImageFromFile($InFileName, 2) Local $lWidth Local $lHeight ;Get the width and height of the image $lWidth = $oQP.ImageWidth() $lHeight = $oQP.ImageHeight() ;Draw the image onto the page using the specified width/height $oQP.DrawImage(100, 180, $lWidth/10, $lHeight/10) If FileExists($sFileName2) Then FileDelete($sFileName2) If $oQP.SaveToFile($sFileName2) = 1 Then While _WinAPI_FileInUse($sFileName2) Sleep(10) WEnd ShellExecuteWait($sFileName2) Else MsgBox($MB_SYSTEMMODAL, "Error", "File " & $sFileName2 & " could not be saved.") EndIf $oQP = 0 ; CleanUp - destroy object In the example below Word documents are exported to pdf, and then a stamp image is applied to all the pdf files in the folder: #include <MsgBoxConstants.au3> #include <Word.au3> #include "QuickPDF.au3" Local $sFolder = "C:\Users\robertocm\Desktop\TEST\" Local $InFileName = "E:\templates\images\stamp.png" Local $oQP _QPDF_UseErrorHandler() _QPDF_NewLibraryPath_Lite("C:\Program Files (x86)\Debenu\PDF Library\Lite\DebenuPDFLibraryLite1114.dll") ; ***************************************************************************** ; Export Word documents to pdfs ; Assign a Local variable the search handle of all files in the directory. Local $hSearch = FileFindFirstFile($sFolder & "*.doc") ; Check if the search was successful, if not display a message and exit If $hSearch = -1 Then MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.") Exit EndIf ; Assign a Local variable the empty string which will contain the files names found. Local $sFileName = "", $iResult = 0 ;Create application object Local $oWord = _Word_Create() If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocOpen Example", _ "Error creating a new Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $sDocument, $oDoc, $OutFile, $sFileNamePDF While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ;Display the file name. ;$iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName) ;If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button. ;Open the document $sDocument = $sFolder & $sFileName $oDoc = _Word_DocOpen($oWord, $sDocument, Default, Default, True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocPrint Example", _ "Error opening " & $sDocument & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;Export the complete document with default values $OutFile = StringSplit($sFileName, ".") $sFileNamePDF = $sFolder & $OutFile[1] & ".pdf" _Word_DocExport($oDoc, $sFileNamePDF) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocExport Example", _ "Error exporting the document." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ;ShellExecute($sFileNamePDF) ; Close a Word document _Word_DocClose($oDoc) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_DocClose Example", _ "Error closing document '.\Extras\Test.doc'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) WEnd ; Close the search handle. FileClose($hSearch) ; If Word was running when this script is started only the reference to the ; object will be removed. ; If Word was started by this example all documents and Word will be closed. Local $bWordClose = @extended Local $iResult2 If $bWordClose Then $iResult2 = MsgBox(BitOR($MB_OKCANCEL, $MB_SYSTEMMODAL), "Word UDF: _Word_Quit Example", _ "If you click OK ALL unsaved changes in ALL open documents of this Word instance will be lost and the instance will be closed.") Else #cs $iResult2 = MsgBox(BitOR($MB_OKCANCEL, $MB_SYSTEMMODAL), "Word UDF: _Word_Quit Example", _ "Word was already running when function _Word_Create was called. Hence only the reference to the object will be removed.") #ce EndIf If $iResult2 = 2 Then Exit _Word_Quit($oWord) If @error Then MsgBox($MB_SYSTEMMODAL, "Word UDF: _Word_Quit Example", _ "Error closing the Word application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Stamp the PDF files ; Assign a Local variable the search handle of all files in the directory. $hSearch = FileFindFirstFile($sFolder & "*.pdf") ; Check if the search was successful, if not display a message and exit If $hSearch = -1 Then MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.") Exit EndIf $sFileName = "" $iResult = 0 Local $lWidth, $lHeight While 1 $sFileName = FileFindNextFile($hSearch) ; If there is no more file matching the search. If @error Then ExitLoop ;Display the file name. ;$iResult = MsgBox(BitOR($MB_SYSTEMMODAL, $MB_OKCANCEL), "", "File: " & $sFileName) ;If $iResult <> $IDOK Then ExitLoop ; If the user clicks on the cancel/close button. $sDocument = $sFolder & $sFileName _QPDF_LoadFromFile_Lite($oQP, $sDocument) $oQP.SetOrigin($__eQPDF_SORIGIN_TopLeft); $oQP.SetMeasurementUnits($__eQPDF_MUNITS_Milimeters) $oQP.AddImageFromFile($InFileName, 2) ;Get the width and height of the image $lWidth = $oQP.ImageWidth() $lHeight = $oQP.ImageHeight() ;Draw the image onto the page using the specified width/height $oQP.DrawImage(100, 235, $lWidth/11.8, $lHeight/11.8) If FileExists($sDocument) Then FileDelete($sDocument) If $oQP.SaveToFile($sDocument) = 1 Then #cs While _WinAPI_FileInUse($sDocument) Sleep(10) WEnd ShellExecuteWait($sFileName) #ce Else MsgBox($MB_SYSTEMMODAL, "Error", "File " & $sFileName & " could not be saved.") EndIf WEnd ; Close the search handle. FileClose($hSearch) $oQP = 0 ; CleanUp - destroy object Another useful example would be to apply a Watermark to all pages of the selected pdf file.1 point
-
i found a workaround, that works for me: #include <IE.au3> Global $oIE = _IECreate("about:blank") Global $eval = 0 $oIE.Document.parentWindow.execScript("document.body.oAutoIt = eval;") $eval = Execute("$oIE.Document.body.oAutoIt") If IsObj($eval) Then MsgBox(0, "eval", $eval('typeof "str"'));execute js and get return $eval("alert('test');") EndIf hope it's useful to someone1 point
-
If you want to make it COM accessible, then >look here. If you want to make a standard DLL, then continue reading: Have you ever heard of a "Unmanaged Exports" library for .NET? Add it to your .NET project, and form the function something like: class Class1 { [DllExport("add", CallingConvention = CallingConvention.StdCall)] public int AddNumbers(int a, int b) { return a + b; } [DllExport("sub", CallingConvention = CallingConvention.StdCall)] public int SubtractNumbers(int a, int b) { return a - b; } [DllExport("multistring", CallingConvention = CallingConvention.StdCall)] public string MultiString(string str1, string spc = ",", int b = 1) { if (str1.Length < 1 || b < 1) return ""; string retVal = ""; for (int i = 1; i <= b; i++) { retVal += str1 + spc; } if (spc.Length <= 0) return retVal; else return retVal.Remove(retVal.Length - spc.Length, spc.Length); } } And you would have to add references: using System.Runtime.InteropServices; using RGiesecke.DllExport; And then compile as DLL for x86 OR x64 platform (If you leave the "Any CPU" platform, the functions will not be exported), and use it from your autoit as: $myDLL = @ScriptDir & '\myNETdll.dll' if NOT FileExists($myDLL) Then Exit $dllCall1 = DllCall($myDLL, 'int', 'add', 'int', 5, 'int', 7) if @error Then MsgBox(0, 'Error', 'Error code: ' & @error) Else MsgBox(0, 'ADD Result', $dllCall1[0]) EndIf $dllCall2 = DllCall($myDLL, 'int', 'sub', 'int', 20, 'int', 14) if @error Then MsgBox(0, 'Error', 'Error code: ' & @error) Else MsgBox(0, 'SUB Result', $dllCall2[0]) EndIf $dllCall3 = DllCall($myDLL, 'str', 'multistring', 'str', 'SOME_TEXT', 'str', ',', 'int', 3) if @error Then MsgBox(0, 'Error', 'Error code: ' & @error) Else MsgBox(0, 'MULTISTRING Result', $dllCall3[0]) EndIf p.s. none of the examples were tested, but it should work as I've done this before.1 point