Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/17/2016 in all areas

  1. BBs19

    MetroGUI UDF

    Version 5.1

    8,853 downloads

    Features: Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support for aerosnap etc. Many color schemes/themes included. See MetroThemes.au3 for more details. 2 type of Windows 8/10 style buttons. Modern checkboxes, radios, toggles and progressbar. All buttons, checkboxes etc. have hover effects! Windows 10 style modern MsgBox. Windows 10/Android style menu that slides in from left.
    3 points
  2. Features: Create modern looking borderless and resizable GUIs with control buttons (Close,Maximize/Restore,Minimize, Fullscreen, Menu) True borderless, resizeable GUI with full support for aerosnap etc. Many color schemes/themes included. See MetroThemes.au3 for more details. 3 type of Windows 8/10 style buttons. Modern checkboxes, radios, toggles and progressbar. All buttons, checkboxes etc. have hover effects! Windows 10 style modern MsgBox. Windows 10/Android style menu that slides in from left. Windows 10 style right click menu Credits: @UEZ, for the function to create buttons with text using GDIPlus. @binhnx for his SSCtrlHover UDF Changelog: Download UDF with example:
    1 point
  3. Jon

    Using AutoItX from C# / .Net

    The following files are provided to allow .NET use: AutoItX3.Assembly.dll - The .NET Assembly for using AutoItX.AutoItX3.Assembly.xml - The Visual Studio Intellisense help file for the .NET Assembly.AutoItX3.dll - The main AutoItX DLL (x86)AutoItX3_x64.dll - The main AutoItX DLL (x64)Using the Assembly from VB/C# within in Visual Studio is very easy: Add a reference to AutoItX3.Assembly.dll to your projectAdd a using AutoIt; statement in the files you want to use AutoIt functionsWrite code like this C# example:using AutoIt; ... // Wow, this is C#! AutoItX.Run("notepad.exe"); AutoItX.WinWaitActive("Untitled"); AutoItX.Send("I'm in notepad"); IntPtr winHandle = AutoItX.WinGetHandle("Untitled"); AutoItX.WinKill(winHandle);Distribute your final executable with the files AutoItX3.Assembly.dll, AutoItX3.dll, AutoItX3_x64.dll.
    1 point
  4. [New Release] - 06 April 2019 Added: Error-checking for sensible column numbers in the $aSortData array, with an additional error status. ------------------------------------------------------------------------------------------------------------------------ While answering a recent question about sorting a ListView on several columns, I developed this function to sort a 2D array on several columns and I though I might give it a wider audience. Here is the function: #include-once ;#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; #INCLUDES# ========================================================================================================= #include <Array.au3> ; =============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Title .........: ArrayMultiColSort ; AutoIt Version : v3.3.8.1 or higher ; Language ......: English ; Description ...: Sorts 2D arrays on several columns ; Note ..........: ; Author(s) .....: Melba23 ; Remarks .......: ; =============================================================================================================================== ; #CURRENT# ===================================================================================================================== ; _ArrayMultiColSort : Sort 2D arrays on several columns ; =============================================================================================================================== ; #INTERNAL_USE_ONLY#================================================================================================= ; __AMCS_SortChunk : Sorts array section ; =============================================================================================================================== ; #FUNCTION# ==================================================================================================================== ; Name...........: _ArrayMultiColSort ; Description ...: Sort 2D arrays on several columns ; Syntax.........: _ArrayMultiColSort(ByRef $aArray, $aSortData[, $iStart = 0[, $iEnd = 0]]) ; Parameters ....: $aArray - The 2D array to be sorted ; $aSortData - 2D array holding details of the sort format ; Format: [Column to be sorted, Sort order] ; Sort order can be either numeric (0/1 = ascending/descending) or a ordered string of items ; Any elements not matched in string are left unsorted after all sorted elements ; $iStart - Element of array at which sort starts (default = 0) ; $iEnd - Element of array at which sort endd (default = 0 - converted to end of array) ; Requirement(s).: v3.3.8.1 or higher ; Return values .: Success: No error ; Failure: @error set as follows ; @error = 1 with @extended set as follows (all refer to $sIn_Date): ; 1 = Array to be sorted not 2D ; 2 = Sort data array not 2D ; 3 = More data rows in $aSortData than columns in $aArray ; 4 = Start beyond end of array ; 5 = Start beyond End ; @error = 2 with @extended set as follows: ; 1 = Invalid string parameter in $aSortData ; 2 = Invalid sort direction parameter in $aSortData ; 3 = Invalid column index in $aSortData ; Author ........: Melba23 ; Remarks .......: Columns can be sorted in any order ; Example .......; Yes ; =============================================================================================================================== Func _ArrayMultiColSort(ByRef $aArray, $aSortData, $iStart = 0, $iEnd = 0) ; Errorchecking ; 2D array to be sorted If UBound($aArray, 2) = 0 Then Return SetError(1, 1, "") EndIf ; 2D sort data If UBound($aSortData, 2) <> 2 Then Return SetError(1, 2, "") EndIf If UBound($aSortData) > UBound($aArray) Then Return SetError(1, 3) EndIf For $i = 0 To UBound($aSortData) - 1 If $aSortData[$i][0] < 0 Or $aSortData[$i][0] > UBound($aArray, 2) -1 Then Return SetError(2, 3, "") EndIf Next ; Start element If $iStart < 0 Then $iStart = 0 EndIf If $iStart >= UBound($aArray) - 1 Then Return SetError(1, 4, "") EndIf ; End element If $iEnd <= 0 Or $iEnd >= UBound($aArray) - 1 Then $iEnd = UBound($aArray) - 1 EndIf ; Sanity check If $iEnd <= $iStart Then Return SetError(1, 5, "") EndIf Local $iCurrCol, $iChunk_Start, $iMatchCol ; Sort first column __AMCS_SortChunk($aArray, $aSortData, 0, $aSortData[0][0], $iStart, $iEnd) If @error Then Return SetError(2, @extended, "") EndIf ; Now sort within other columns For $iSortData_Row = 1 To UBound($aSortData) - 1 ; Determine column to sort $iCurrCol = $aSortData[$iSortData_Row][0] ; Create arrays to hold data from previous columns Local $aBaseValue[$iSortData_Row] ; Set base values For $i = 0 To $iSortData_Row - 1 $aBaseValue[$i] = $aArray[$iStart][$aSortData[$i][0]] Next ; Set start of this chunk $iChunk_Start = $iStart ; Now work down through array For $iRow = $iStart + 1 To $iEnd ; Match each column For $k = 0 To $iSortData_Row - 1 $iMatchCol = $aSortData[$k][0] ; See if value in each has changed If $aArray[$iRow][$iMatchCol] <> $aBaseValue[$k] Then ; If so and row has advanced If $iChunk_Start < $iRow - 1 Then ; Sort this chunk __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf ; Set new base value $aBaseValue[$k] = $aArray[$iRow][$iMatchCol] ; Set new chunk start $iChunk_Start = $iRow EndIf Next Next ; Sort final section If $iChunk_Start < $iRow - 1 Then __AMCS_SortChunk($aArray, $aSortData, $iSortData_Row, $iCurrCol, $iChunk_Start, $iRow - 1) If @error Then Return SetError(2, @extended, "") EndIf EndIf Next EndFunc ;==>_ArrayMultiColSort ; #INTERNAL_USE_ONLY# =========================================================================================================== ; Name...........: __AMCS_SortChunk ; Description ...: Sorts array section ; Author ........: Melba23 ; Remarks .......: ; =============================================================================================================================== Func __AMCS_SortChunk(ByRef $aArray, $aSortData, $iRow, $iColumn, $iChunkStart, $iChunkEnd) Local $aSortOrder ; Set default sort direction Local $iSortDirn = 1 ; Need to prefix elements? If IsString($aSortData[$iRow][1]) Then ; Split elements $aSortOrder = StringSplit($aSortData[$iRow][1], ",") If @error Then Return SetError(1, 1, "") EndIf ; Add prefix to each element For $i = $iChunkStart To $iChunkEnd For $j = 1 To $aSortOrder[0] If $aArray[$i][$iColumn] = $aSortOrder[$j] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] ExitLoop EndIf Next ; Deal with anything that does not match If $j > $aSortOrder[0] Then $aArray[$i][$iColumn] = StringFormat("%02i-", $j) & $aArray[$i][$iColumn] EndIf Next Else Switch $aSortData[$iRow][1] Case 0, 1 ; Set required sort direction if no list If $aSortData[$iRow][1] Then $iSortDirn = -1 Else $iSortDirn = 1 EndIf Case Else Return SetError(1, 2, "") EndSwitch EndIf ; Sort the chunk Local $iSubMax = UBound($aArray, 2) - 1 __ArrayQuickSort2D($aArray, $iSortDirn, $iChunkStart, $iChunkEnd, $iColumn, $iSubMax) ; Remove any prefixes If IsString($aSortData[$iRow][1]) Then For $i = $iChunkStart To $iChunkEnd $aArray[$i][$iColumn] = StringTrimLeft($aArray[$i][$iColumn], 3) Next EndIf EndFunc ;==>__AMCS_SortChunk And here is an example to show it working: #include "ArrayMultiColSort.au3" #include <String.au3> ; Only used to fill array ; Create and display array Global $aArray[100][4] For $i = 0 To 99 $aArray[$i][0] = _StringRepeat(Chr(Random(65, 68, 1)), 5) $aArray[$i][1] = _StringRepeat(Chr(Random(74, 77, 1)), 5) $aArray[$i][2] = _StringRepeat(Chr(Random(80, 83, 1)), 5) $aArray[$i][3] = _StringRepeat(Chr(Random(87, 90, 1)), 5) Next _ArrayDisplay($aArray, "Unsorted") ; Copy arrays for separate examples below $aArray_1 = $aArray $aArray_2 = $aArray ; This sorts columns in ascending order - probably the most common requirement ; Sort requirement: ; Col 0 = Decending ; Col 1 = Ascending ; Col 2 = Required order of elements (note not alphabetic PQRS nor reverse SRQP) ; Col 3 = Ascending Global $aSortData[][] = [ _ [0, 1], _ [1, 0], _ [2, "SSSSS,QQQQQ,PPPPP,RRRRR"], _ [3, 0]] ; Sort and display array _ArrayMultiColSort($aArray_1, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_1, "Sorted in order 0-1-2-3") ; But the UDF can sort columns in any order ; Sort requirement: ; Col 2 = Decending ; Col 0 = Ascending Global $aSortData[][] = [ _ [2, 1], _ [0, 0]] ; Sort and display array _ArrayMultiColSort($aArray_2, $aSortData) ; Display any errors encountered If @error Then ConsoleWrite("Oops: " & @error & " - " & @extended & @CRLF) _ArrayDisplay($aArray_2, "Sorted in order 2-0") And here are both in zip form: ArrayMultiColSort.zip As usual all comments welcome. M23
    1 point
  5. In the forums you can find several questions about how to edit the text in a ListView cell with a standard control eg. an Edit control or a ComboBox. The zip below contains three examples with an Edit control, a ComboBox and a DateTimePicker. How? A description from MicroSoft of how to edit a ListView cell with a ComboBox can be found here. When you click a cell the position and size is calculated, and the ComboBox is created on top of the cell. The text is shown in the Edit box. You can edit the text or select a value in the Listbox. Press Enter to save the text in the ListView cell and close the ComboBox. The ComboBox exists only while the text is edited. Code issues Especially because the control to edit the ListView cell is created on top of the ListView and is not part of the ListView, there are some issues you should be aware of. To get everything to look as good as possible most actions should be carried out when a mouse button is pressed and not when it's released. You should also be aware that the new code you add, does not conflict with existing functionality for example multiple selections. The examples consists of small but fairly many pieces of code to respond to events and messages. Keyboard support To edit a text value you are more or less forced to use the keyboard to type in the text. It would be nice if you could also select the current cell in the ListView with the keyboard. Cell selection with the keyboard is not too hard to implement with custom draw code. The current cell is drawn with a specific background color. It looks like this. You can select the current cell with the arrow keys. Open the control There must be a way to initiate the creation of the control. This is typically done with a single or double click in the ListView. Or with Enter or Space key in the examples with keyboard support. Default in the examples is double click and Enter key. You can change this in global variables in top of the scripts. A WM_NOTIFY message handler created with GUIRegisterMsg is used to watch for single and double click in the ListView. This message handler is also used to handle custom draw messages for keyboard support. Because the control is created on top of the ListView cell, it's very important that the ListView is set as the parent window. This ensures that mouse clicks and key presses are captured by the control and not by the ListView. Events in the control In a ComboBox and a DateTimePicker an additional control (Listbox and MonthCal, respectively) is opened if you click the Dropdown arrow (or press <Alt+Down arrow> on the keyboard). Click the Dropdown arrow again to close the control (or press <Alt+Up arrow> on the keyboard). The interesting messages (DROPDOWN, SELECTION, CLOSEUP) from such an additional control are usually contained in WM_COMMAND or WM_NOTIFY messages which are sent to the parent window. The parent window is the ListView. To catch the messages the ListView must be subclassed. Messages from the Edit control, the Edit box of the ComboBox, or the client area of the DateTimePicker are catched by subclassing the controls (Edit control, Edit box and DateTimePicker) directly. The interesting information here is dialog codes to accept (Enter) or cancel (Esc) the value and close the control. Dialog codes are sent as $WM_GETDLGCODE messages. In all examples the value in the control can also be accepted and saved with a double click. Close the control A mouse click in the ListView outside the control should close the control and cancel editing of the current cell. Because the control is not part of the ListView in particular mouse clicks on the Scrollbars should close the control immediately. The control will not be repainted properly on scrolling. Mouse clicks in the ListView and on Scrollbars can be identified by WM_LBUTTONDOWN and WM_NCLBUTTONDOWN messages. The area which is filled by Scrollbars in a ListView is non-client area. Mouse clicks in non-client area generates WM_NCLBUTTONDOWN messages. To catch the messages you have to subclass the ListView. A mouse click in the GUI outside the ListView and in non-client GUI area (eg. the Titlebar) should also close the control. Mouse clicks in GUI are catched through GUI_EVENT_PRIMARYDOWN messages. Mouse clicks in non-client GUI area are catched through WM_NCLBUTTONDOWN messages by subclassing the GUI. Finish the code A great part of the code is running in message handlers created with GUIRegisterMsg or created by subclassing a window. Lengthy code to open or close the control should not be executed in these message handlers. Instead of a message is sent to the AutoIt main loop where the control is opened or closed. Some of the message handlers are only needed while the control is open. They are created and deleted as part of the control open and close code. In the context of the updates May 26 the $LVS_EX_HEADERDRAGDROP extended style (rearranging columns by dragging Header items with the mouse) is added to all ListViews. See post 20 and 21. A few lines of code are added to better support usage of the keyboard. See image above. The code provides for horizontal scrolling of the ListView to make sure that a subitem (or column) is fully visible when it's selected with left or right arrow. Among other things, the code takes into account rearranging and resizing of columns as well as resizing of the GUI and ListView. A new example EditControlKeyboardTenCols.au3 demonstrates the features. See post 22. A few lines of code is added to handle multiple selections. Multiple selections is enabled in all examples. Pressing the Tab key in the control closes the control. The image shows a DateTimePicker control. Zip file The zip contains three examples with an Edit control, a ComboBox and a DateTimePicker. For each control there are two scripts with and without keyboard support. In the script with keyboard support you can select the current cell in the ListView with the arrow keys and open the control with the Enter (default) or the Space key. You need AutoIt 3.3.10 or later. Tested on Windows 7 32/64 bit and Windows XP 32 bit. Comments are welcome. Let me know if there are any issues. (Set tab width = 2 in SciTE to line up comments by column.) ListViewEditingCells.7z
    1 point
  6. View the Project at GitHub: https://github.com/BetaLeaf/False-Positive-Reporter Download False Positive Reporter: https://github.com/BetaLeaf/False-Positive-Reporter/releases Wiki: https://github.com/BetaLeaf/False-Positive-Reporter/wiki Thanks Jos for your Example Script involving Emailing attachments. Thanks JohnOne for helping me figure out the Run as Non-Admin Issue. Thanks Chiron at http://www.techsupportalert.com/content/how-report-malware-or-false-positives-multiple-antivirus-vendors.htm for your wonderful post. Disclaimer: This script is meant for submitting false positives to AntiVirus Vendors so you can deploy your scripts faster. I am not responsible for your misuse of this script.
    1 point
  7. Reizvoller's solution should work. Unless special characters are isolated or confined as demonstrated in Reiz's post, they often have a secondary function that the script does not know how to interpret. That usually results in a crash or a hang.
    1 point
  8. Heya! I believe if you confine the ! within { } so that it's {!} , it should work! https://www.autoitscript.com/autoit3/docs/functions/Send.htm I am basing my answer off of that. Hope this helps! -Reiz
    1 point
  9. The backend seems to work well enough but the Gui leaves something to be desired especially while dragging the window maybe you could make the border show up when you mouse over the windows? Edit: It also has issues when closing, sometimes hangs
    1 point
  10. You're probably using GUIGetMsg, that function has a built in sleep when nothing is going on with the GUI, when you're moving the mouse over it or actioning a control the delay is bypassed.
    1 point
  11. Changelog v4: Note: There are many changes in this version and it will not work with the syntax used in the old v3.5 UDF. New features: Full High-DPI support for 4k screens. - Automated scaling of the gui and all buttons, checkboxes etc. created with the metro UDF style. (See example and comments on how to use) Using the UDF is now easier than ever, many things have been simplified! It is also no longer required to use a HOVER_REG variable when creating buttons etc. 2 new modern checkbox styles 2 new modern toggle styles Fullscreen GUI toggle button like in Windows 10 apps Easy to use menu that slides in from left (like menus in Android and Windows 10 calculator app) Added button enable/disable functions to give a button a grayed out look when it is disabled. Control buttons now indicate that the window is inactive by their color Improved: Creating control buttons is now seperated from the main gui create function, this allows selecting which control buttons to create and which to hide completley. Hovering over control buttons while window is inactive now also works Many other small changes that I don't remember anymore Many bug fixes. Download:
    1 point
  12. I have made my own solution for image searching. I would like to share here. Im from spain (if someone of you can notice a bad grammar, etc): My idea is to make an aproximation to the problem, its not perfect but its usefull if you take 1 or 2 tips while using my system: a] You should try to detect images with the upper left corner in a pixel that not has the same color in the background or in big areas (this is for speed reasons). b] Sometimes, in order to set a] tip properly, a trick is to detect an image, lets name it "AUX", that "AUX" verify a] tip, and then, when you get the coordinates of that image with my image detection system, the only thing you need is to apply an offset to that point, exactly the offset to transform that point into the right one, this is, the coordinates of original "TARGET" image. Obviusly this is only valid when the relatives positions between AUX and TARGET are fixed and both of them exists always togheter in the screen. Anyway, the advantages of my system are the following: - You dont need any DLL file or library. - You dont need to deal with extrange problems or bugs mentioned here around the imageSearch posted in this thread. - Your dont need to put a copy of the image file you are trying to detect, neather distribute this file with the script .au3 file. - It doesnt matter the size/resolution of the image, because my algorithm is O(1) efficient in this aspect, i mean, the image size not affect to the speed detection. Even with this advantages... as i said, its not at all a perfect system, because it has the limitation mentioned above, in a] point. I should say that i have make my efforts in every part of the algorithm, i mean, even if you dont take a] point seriously, the system should be as fast as is possible. All i use from AutoIt library is PixelGetColor and PixelSearch (as you can imagine, specially this one). If someone of you are interested in this idea, i can attach here the files, so you can freely dowload, and i will put here also some examples of using this idea, all you wiil need to use the system are these 3 things: -1 Your script file with the image file you want to detect (you will be able to delete the image when all is set up) -2 My image_search.au3 to import in your script (so you can use my func image_search(), that returns the center point of the image). -3 A little Java app that i provide also and i have made specially to make it easy the use of the system. The idea behind this Java app is simple: it takes any image file and generates an .au3 script with only one function, named "func get_<image_name>_<widthxheight>_sign()". This new function, makes a simple signature from the image, a kind of "footprint". This signature has always the same size, thats why the image size doesnt matter. And that signature is what my search in the screen. Then, the scan itself is "optimized" by using PixelSearch in a certain way (not the best way, but i have tried). Anyway, i will put the codes and samples here if there are people with the desire. Cheers. PD: Or maybe i could make a youtube video and share here as a little tutorial or something, but i cant garantee this.
    1 point
  13. water

    Expect with AutoIt?

    Set the opt_flag of the Run function to $STDOUT_CHILD. Then use StdoutRead to process the displayed lines.
    1 point
  14. Gianni

    Print photo using Autoit

    you could do this way: Create a pdf file containing all the pictures you want to print and use SumatraPDF.exe to print the pdf file silently on a printer of your choice or on the default printer. in short do like this: download SumatraPDF.exe (portable version) from here: http://www.sumatrapdfreader.org/download-free-pdf-viewer.html and save the exe to your script dir. This is a very nice tool that allows also to print pdf files silently. (moer command line arguments here: https://github.com/sumatrapdfreader/sumatrapdf/wiki/Command-line-arguments) Download this very nice UDF from here: and save it to your script dir (this is used to create the pdf that contains the images to be printed) use this draft script posted here as an example to see how to print silently one ore more pictures of your choice. #include "MPDF_UDF.au3" _SelectImages() ; select images and create a temporary pdf file containing all the selected images ; now print selected images silently using sumatraPDF.exe Run(@ScriptDir & '\SumatraPDF.exe -silent -print-to-default ' & @ScriptDir & "\Image2PDF.pdf", "", @SW_HIDE) ; use -print-to "printername" to select another printer ; delete temporary file ; FileDelete (@ScriptDir & "\Image2PDF.pdf" ) Func _SelectImages() Local $var = FileOpenDialog("Select images", @ScriptDir & "\", "Images (*.jpg;*.bmp;*gif;*png;*tif;*ico)", 4) If @error Then MsgBox(4096, "", "No File(s) chosen") Exit Else If not StringInStr($var, '|') Then ; only one file selected $var = StringReplace($var, '\', '|', -1) EndIf EndIf Local $aImgs = StringSplit($var, "|", 3) Local $aIMG_Params ;set the properties for the pdf _SetTitle("Image2PDF") _SetSubject("Convert image(s) to pdf") _SetKeywords("pdf, AutoIt") _OpenAfter(True);open after generation _SetUnit($PDF_UNIT_PT) ; 1 _SetPaperSize("a4") _SetZoomMode($PDF_ZOOM_CUSTOM, 100) _SetOrientation($PDF_ORIENTATION_PORTRAIT) _SetLayoutMode($PDF_LAYOUT_CONTINOUS) ;initialize the pdf FileDelete(@ScriptDir & "\Image2PDF.pdf") _InitPDF(@ScriptDir & "\Image2PDF.pdf") ;=== load resources (images) used in pdf === For $i = 1 To UBound($aImgs) - 1 $aIMG_Params = _LoadResImage_MOD("img" & $i, $aImgs[0] & "\" & $aImgs[$i]) _BeginPage() ; load each image on it's own page ;scale factors $iScaleFactorX = _GetPageWidth() / $aIMG_Params[1] $iScaleFactorY = _GetPageHeight() / $aIMG_Params[2] if $iScaleFactorX >= 1 And $iScaleFactorY >= 1 Then ; The image is smaller than the sheet, no need to rescale _InsertImage("img" & $i, ( _GetPageWidth() - $aIMG_Params[1]) / 2, (_GetPageHeight() - $aIMG_Params[2]) / 2) ; center image in the page Else ; the image is bigger than the sheet, it needs to be reduced to fit (maintaining proportions) If $iScaleFactorX < $iScaleFactorY Then $iScale = $iScaleFactorX Else $iScale = $iScaleFactorY EndIf _InsertImage("img" & $i, ( _GetPageWidth() - $aIMG_Params[1] * $iScale) / 2, (_GetPageHeight() - $aIMG_Params[2] * $iScale) / 2, $aIMG_Params[1] * $iScale, $aIMG_Params[2] * $iScale) ; Rescale and center image in the page EndIf _EndPage() Next ; finally, write the buffer to disk _ClosePDFFile() EndFunc ;==>_SelectImages ; #FUNCTION# ==================================================================================================================== ; Name ..........: _LoadResImage ; Description ...: Load a image in the pdf (if you use it multiple times it decreases the size of the pdf) ; Syntax ........: _LoadResImage( $sImgAlias , $sImage ) ; Parameters ....: $sImgAlias - an alias to identify the image in the pdf (e.g. "Cheese"). ; $sImage - image path. ; Return values .: Success - True ; Failure - False ; Author(s) .....: Mihai Iancu (taietel at yahoo dot com) ; Modified ......: By Cimp (returns an 3 element array where: [0]$_Image , [1] $_iImageW , [2] $_iImageH instead of just $_Image ; Remarks .......: Image types accepted: BMP, GIF, TIF, TIFF, PNG, JPG, JPEG (those are tested) ; Related .......: ; Link ..........: http://www.autoitscript.com/forum/topic/118827-create-pdf-from-your-application/ ; Example .......: No ; =============================================================================================================================== Func _LoadResImage_MOD($sImgAlias, $sImage) Local $iW, $iH, $ImgBuf, $hImage, $hImageExt, $newImg, $hClone, $hGraphics, $iObj, $aReturn[3] If $sImgAlias = "" Then __Error("You don't have an alias for the image", @ScriptLineNumber) If $sImage = "" Then __Error("You don't have any images to insert or the path is invalid", @ScriptLineNumber) Else $hImageExt = StringUpper(StringRight($sImage, 3)) $newImg = _TempFile(@ScriptDir, "~", ".jpg") Switch $hImageExt Case "BMP", "GIF", "TIF", "TIFF", "PNG", "JPG", "JPEG", "ICO" _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hClone = _GDIPlus_BitmapCloneArea($hImage, 0, 0, $iW, $iH, $GDIP_PXF24RGB) $hGraphics = _GDIPlus_ImageGetGraphicsContext($hClone) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) _GDIPlus_GraphicsClear($hGraphics, 0xFFFFFFFF) _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0) _GDIPlus_ImageSaveToFile($hClone, $newImg) $ImgBuf = __ToBinary($newImg) $_iImageW = $iW $_iImageH = $iH $iObj = __InitObj() __ToBuffer("<</Type /XObject /Subtype /Image /Name /" & $sImgAlias & " /Width " & $_iImageW & " /Height " & $_iImageH & " /Filter /DCTDecode /ColorSpace /DeviceRGB /BitsPerComponent 8" & Chr(10) & "/Length " & StringLen($ImgBuf) & ">>stream") __ToBuffer($ImgBuf) __ToBuffer("endstream") __EndObj() $_Image &= "/" & $sImgAlias & " " & $iObj & " 0 R " & Chr(10) __InitObj() __ToBuffer(StringLen($ImgBuf)) __EndObj() _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_BitmapDispose($hClone) _GDIPlus_Shutdown() FileDelete($newImg) Case Else __Error("The image is invalid", @ScriptLineNumber) Exit EndSwitch EndIf ; Return $_Image $aReturn[0] = $_Image $aReturn[1] = $_iImageW $aReturn[2] = $_iImageH Return $aReturn EndFunc ;==>_LoadResImage_MOD Func _Iif($vExpression, $vTrue, $vFalse) Return $vExpression ? $vTrue : $vFalse EndFunc ;==>_Iif This script uses a little modified version of the function _LoadResImage() from the MPDF_UDF.au3. if you use an old version of AutoIt and get an error about the _Iif() function then just rename or delete the _Iif() function located at the end of this script.
    1 point
  15. dmob

    Print photo using Autoit

    Try Irfanview. It has a nice command line interface that will let you do what you want. Link
    1 point
  16. Another way: #include <GuiConstants.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <Array.au3> $GUI = GUICreate("Test Script", 230, 300) $TreeView = GUICtrlCreateTreeView(15, 20, 200, 230, -1, $WS_EX_CLIENTEDGE) Global $aItems[11] $aItems[0] = 10 For $i = 1 To 10 If Mod($i, 2) <> 0 Then $aItems[$i] = GUICtrlCreateTreeViewItem("Item" & $i, $TreeView) Else $aItems[$i] = GUICtrlCreateTreeViewItem("Item" & $i, -1) EndIf GUICtrlSetState($i+2, $GUI_EXPAND) Next $GetIndex_Button = GUICtrlCreateButton("Get Index", 20, 270, 60, 20) GUISetState(@SW_SHOW, $GUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $GetIndex_Button $hSelected_Item = _GUICtrlTreeView_GetSelection($TreeView) For $i = 1 To $aItems[0] If $hSelected_Item = _GUICtrlTreeView_GetItemHandle($TreeView, $aItems[$i]) Then $iIndex = $i ExitLoop EndIf Next ConsoleWrite("Selected Index = " & $iIndex & @LF) EndSwitch WEnd
    1 point
×
×
  • Create New...