Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/11/2022 in all areas

  1. ... so RunWait doesn't seem right for your purpose why not use "run" instead, so you can read the streams of your "core.exe" program and continue with the next file when the execution of a "run" is finished .... something like this ... (obviously not tested) For $i = 0 To UBound($ArrSource) - 1 $run = Run($core & ' -m="' & $modules & '" -i="' & $ArrSource[$i] & '" -p="' & $Preset & '" -x="' & $configxml & '" -o="' & $output & '"', @ScriptDir, @SW_HIDE, $STDIO_INHERIT_PARENT) While ProcessExists($run) ConsoleWrite(StdoutRead($run)) WEnd Next
    1 point
  2. 64 is the value of the flag-parameter of the MsgBox function. Meaning and possible values are very well explained in the manual.
    1 point
  3. After examining both approaches, I ended up going with a modified version of KaFu's method. @pixelsearch Your method was quite interesting, but in the end it seemed that since GDIPlus was needed for some of the process, it would be better to use it all the way through. But thanks for posting your sample! There are some useful tidbits in there for another project some day. @KaFu I worked my way through your GDIPlus calls and read the docs on them and definitely learned something in the process. So thanks for that! I extracted the code for building the thumbnail bitmap and put it into a function. The function lets you specify the filename to read, the size of the thumbnail, and the colors desired for the image background as well as the overflow area background. Here's what I ended up with: #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <File.au3> #include <GDIPlus.au3> ; Create GUI with a ListView control Global $hGUI = GUICreate("ListView", 700, 420, -1, -1, $WS_OVERLAPPEDWINDOW) Global $hListView = _GUICtrlListView_Create($hGUI, "", 70, 0, 630, 420, BitOR($LVS_ICON, $LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_SORTASCENDING)) GUISetState(@SW_SHOW, $hGUI) ; Create and load ImageList control with thumbnails _GDIPlus_Startup() Global $sPath = StringReplace(@AutoItExe, "autoit3.exe", "Examples\GUI") ;Global $sPath = StringReplace(@AutoItExe, "autoit3.exe", "Examples\Helpfile\Extras") Local $aFile = _FileListToArray($sPath, Default, $FLTA_FILES) If @error = 0 Then     ; found some files     Global $SizeX = 160 ; width of each thumbnail     Global $SizeY = 100 ; height of each thumbnail     Global $hImgLst = _GUIImageList_Create($SizeX, $SizeY) ; create an imagelist control     Global $aImgFiles[1] ; create an array to hold the names of images we load     For $i = 1 To $aFile[0]         $sFile = $sPath & "\" & $aFile[$i]         Local $hBmp = _MakeThumbnailBitmapFromFile($sFile, $SizeX, $SizeY)         If $hBmp <> 0 Then             Local $iIndex = _GUIImageList_Add($hImgLst, $hBmp) ; add the bitmap to the ImageList and note the index number             _WinAPI_DeleteObject($hBmp) ; clean up             If $iIndex <> -1 Then                 ReDim $aImgFiles[$iIndex + 1] ; make room in the array for the file name of the image just loaded                 $aImgFiles[$iIndex] = $aFile[$i] ; store the file name of the image just loaded             EndIf         EndIf     Next     _GUICtrlListView_SetImageList($hListView, $hImgLst, 0) ; assign the ImageList to the ListView     ; Add the thumbnails as items to the ListView, and use the file names as captions     For $i = 0 To UBound($aImgFiles) - 1         _GUICtrlListView_AddItem($hListView, $aImgFiles[$i], $i)     Next EndIf Do     Local $Msg = GUIGetMsg() Until $Msg = $GUI_EVENT_CLOSE _GDIPlus_Shutdown() GUIDelete() Exit Func _MakeThumbnailBitmapFromFile($sFile, $iThumbWidth = 160, $iThumbHeight = 100, $iARGB_Transparent = 0xFFFFFFFF, $iARGB_Background = 0xFF000000)     ; Parameters:     ;    $sFile - name of image file (including path) to load     ;    $iThumbWidth - width of thumbnail (optional, default = 160)     ;    $iThumbHeight - height of thumbnail (optional, default = 100)     ;    $iARGB_Transparent - color for transparent areas of image files (PNG, GIF, ICO) (optional, default = 0xFFFFFFFF = white)     ;    $iARGB_Background - color of background areas not covered by image (optional, default = 0xFF000000 = black)     ; If successful, returns handle to a bitmap that can be assigned to the thumbnail image     ; If not successful, returns 0     ; Sample Use:     ;     ;  #include <GDIPlus.au3>     ;  _GDIPlus_Startup() ; needed before any _GDIPlus functions are used     ;  ...     ;  $hBmp = _MakeThumbnailBitmapFromFile("path/filename") ; using default size and colors     ;  If $hBmp <> 0 Then     ;      $iIndex = _GUIImageList_Add($hImageList, $hBmp) ; assign bitmap to imagelist     ;      _WinAPI_DeleteObject($hBmp) ; <-- be sure to remember to do this cleanup!     ;  EndIf     ;  ...     ;  _GDIPlus_Shutdown() ; at end of script when finished with all _GDIPlus functions     Local $hImage, $hGraphics, $hImageScaled, $hBmp     Local $_dHash_hBitmap_SmallScale, $_dHash_hBitmap_SmallScale_Graphics     Local $hBrush_Back, $hBrush_Trans     Local $fRatioImage, $fRatioThumb     Local $iImage_Width, $iImage_Height, $iImage_Resized_Height, $iImage_Resized_Width     Local $iImage_Offset_X, $iImage_Offset_Y     ; Try to load the image from the file     $hImage = _GDIPlus_ImageLoadFromFile($sFile)     If $hImage <> 0 Then    ; Successfully read the image file, process it         ; Resize the image to fit within the thumbnail while maintaining its aspect ratio         $iImage_Width = _GDIPlus_ImageGetWidth($hImage)         $iImage_Height = _GDIPlus_ImageGetHeight($hImage)         $fRatioImage = $iImage_Width / $iImage_Height         $fRatioThumb = $iThumbWidth / $iThumbHeight         Switch True             Case $fRatioThumb > $fRatioImage                 $iImage_Resized_Height = $iThumbHeight                 $iImage_Resized_Width = Round($iImage_Resized_Height * $fRatioImage)                 $iImage_Offset_X = Floor(($iThumbWidth - $iImage_Resized_Width) / 2)                 $iImage_Offset_Y = 0             Case $fRatioThumb < $fRatioImage                 $iImage_Resized_Width = $iThumbWidth                 $iImage_Resized_Height = Round($iImage_Resized_Width / $fRatioImage)                 $iImage_Offset_X = 0                 $iImage_Offset_Y = Floor(($iThumbHeight - $iImage_Resized_Height) / 2)             Case Else                 $iImage_Resized_Width = $iThumbWidth                 $iImage_Resized_Height = $iThumbHeight                 $iImage_Offset_X = 0                 $iImage_Offset_Y = 0         EndSwitch         Local $sDrive, $sDir, $sFileName, $sExtension         _PathSplit($sFile, $sDrive, $sDir, $sFileName, $sExtension)         ConsoleWrite($sFileName & $sExtension & @TAB & _             "Orig " & $iImage_Width & " x " & $iImage_Height & @TAB & _             "New " & $iImage_Resized_Width & " x " & $iImage_Resized_Height & @TAB & _             "Offsets = " & $iImage_Offset_X & " X , " & $iImage_Offset_Y & " Y" & @CRLF)         $hGraphics = _GDIPlus_ImageGetGraphicsContext($hImage)         _GDIPlus_GraphicsSetInterpolationMode($hGraphics, $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC)         $hImageScaled = _GDIPlus_ImageResize($hImage, $iImage_Resized_Width, $iImage_Resized_Height)         _GDIPlus_GraphicsDispose($hGraphics) ; clean up         _GDIPlus_ImageDispose($hImage) ; clean up         ; Create a buffer to build the thumbnail image in         $_dHash_hBitmap_SmallScale = _GDIPlus_BitmapCreateFromScan0($iThumbWidth, $iThumbHeight)         $_dHash_hBitmap_SmallScale_Graphics = _GDIPlus_ImageGetGraphicsContext($_dHash_hBitmap_SmallScale)         ; Add the background and transparent area colors to the appropriate areas of the buffer         $hBrush_Back = _GDIPlus_BrushCreateSolid($iARGB_Background)         $hBrush_Trans = _GDIPlus_BrushCreateSolid($iARGB_Transparent)         _GDIPlus_GraphicsFillRect($_dHash_hBitmap_SmallScale_Graphics, 0, 0, $iThumbWidth, $iThumbHeight, $hBrush_Back) ; background outside of image         _GDIPlus_GraphicsFillRect($_dHash_hBitmap_SmallScale_Graphics, $iImage_Offset_X, $iImage_Offset_Y, $iImage_Resized_Width, $iImage_Resized_Height, $hBrush_Trans) ; area where the resized image will be         ; Add the resized image to the buffer and then create a handle to the bitmap object         _GDIPlus_GraphicsDrawImageRect($_dHash_hBitmap_SmallScale_Graphics, $hImageScaled, $iImage_Offset_X, $iImage_Offset_Y, $iImage_Resized_Width, $iImage_Resized_Height)         $hBmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($_dHash_hBitmap_SmallScale)         _GDIPlus_BrushDispose($hBrush_Back) ; clean up         _GDIPlus_BrushDispose($hBrush_Trans) ; clean up         _GDIPlus_ImageDispose($hImageScaled) ; clean up         _GDIPlus_BitmapDispose($_dHash_hBitmap_SmallScale) ; clean up         _GDIPlus_GraphicsDispose($_dHash_hBitmap_SmallScale_Graphics) ; clean up         ; Return the bitmap handle (be sure to delete it with _WinAPI_DeleteObject after using it)         Return $hBmp     Else         Return 0 ; failed     EndIf EndFunc I modified a few things from KaFu's sample: For one, I eliminated checking for only certain file extensions. Instead I try to load every file in the folder. For files that aren't compatible image files, the _GDIPlus_ImageLoadFromFile function just returns a 0 and I skip that file and move on. Another change was in determining the size of the resized image. The posted sample wasn't quite getting the aspect ratio right, especially for images that are wider than they are tall. I also simplified the drawing of the backgrounds by first painting the entire buffer with the black background, then dropping the white background over it where the image goes, and then dropping on the image. That was easier than painting the black bars one at a time, and takes care of any rounding discrepancies better. There's another set of sample images in the C:\Program Files (x86)\AutoIt3\Examples\Helpfile\Extras folder that you can view by uncommenting the $sPath assignment line in the code and it shows how the routine also handles .bmp, .ico, and .emf files nicely, besides the the .gif, .png, and .jpg files.
    1 point
  4. I have added your functions into your Curl library and successfully cooked up some examples for Telegram: There is enough in that Telegram UDF to steal for your own examples.
    1 point
  5. This function is based on _WinAPI_UniqueHardwareID() in WinAPIDiag.au3. The flags which can be used in this function are exactly the same flags as in _WinAPI_UniqueHardwareID(). Any problems please post below. Thanks. Function: ; #FUNCTION# ==================================================================================================================== ; Name ..........: _GetHardwareID ; Description ...: Generates a unique hardware identifier (ID) for the local computer. ; Syntax ........: _GetHardwareID([$iFlags = Default]) ; Parameters ....: $iFlags - [optional] The flags that specifies what information would be used to generate ID. ; This parameter can be one or more of the following values. ; ; $UHID_MB (0) ; Uses information about your motherboard. This flag is used by default regardless of whether specified or not. ; ; $UHID_BIOS (1) ; Uses information about the BIOS. ; ; $UHID_CPU (2) ; Uses information about the processor(s). ; ; $UHID_HDD (4) ; Uses information about the installed hard drives. Any change in the configuration disks will change ID ; returned by this function. Taken into account only non-removable disks. ; ; $UHID_All (7) ; The sum of all the previous flags. Default is $UHID_MB (0). ; ; $bIs64Bit - [optional] Search the 64-bit section of the registry. Default is dependant on AutoIt bit version. ; Note: 64-bit can't be searched when running the 32-bit version of AutoIt. ; Return values..: Success - The string representation of the ID. @extended returns the value that contains a combination of flags ; specified in the $iFlags parameter. If flag is set, appropriate information is received successfully, ; otherwise fails. The function checks only flags that were specified in the $iFlags parameter. ; Failure - Null and sets @error to non-zero. ; Author.........: guinness with the idea by Yashied (_WinAPI_UniqueHardwareID() - WinAPIDiag.au3) ; Modified ......: Additional suggestions by SmOke_N. ; Remarks .......: The constants above can be found in APIDiagConstant.au3. It also requires StringConstants.au3 and Crypt.au3 to be included. ; Example........: Yes ; =============================================================================================================================== Func _GetHardwareID($iFlags = Default, $bIs64Bit = Default) Local $sBit = @AutoItX64 ? '64' : '' If IsBool($bIs64Bit) Then ; Use 64-bit if $bIs64Bit is true and AutoIt is a 64-bit process; otherwise 32-bit $sBit = $bIs64Bit And @AutoItX64 ? '64' : '' EndIf If $iFlags == Default Then $iFlags = $UHID_MB EndIf Local $aSystem = ['Identifier', 'VideoBiosDate', 'VideoBiosVersion'], _ $iResult = 0, _ $sHKLM = 'HKEY_LOCAL_MACHINE' & $sBit, $sOutput = '', $sText = '' For $i = 0 To UBound($aSystem) - 1 $sOutput &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\', $aSystem[$i]) Next $sOutput &= @CPUArch $sOutput = StringStripWS($sOutput, $STR_STRIPALL) If BitAND($iFlags, $UHID_BIOS) Then Local $aBIOS = ['BaseBoardManufacturer', 'BaseBoardProduct', 'BaseBoardVersion', 'BIOSVendor', 'BIOSReleaseDate'] $sText = '' For $i = 0 To UBound($aBIOS) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\BIOS\', $aBIOS[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_BIOS $sOutput &= $sText EndIf EndIf If BitAND($iFlags, $UHID_CPU) Then Local $aProcessor = ['ProcessorNameString', '~MHz', 'Identifier', 'VendorIdentifier'] $sText = '' For $i = 0 To UBound($aProcessor) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\CentralProcessor\0\', $aProcessor[$i]) Next For $i = 0 To UBound($aProcessor) - 1 $sText &= RegRead($sHKLM & '\HARDWARE\DESCRIPTION\System\CentralProcessor\1\', $aProcessor[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_CPU $sOutput &= $sText EndIf EndIf If BitAND($iFlags, $UHID_HDD) Then Local $aDrives = DriveGetDrive('FIXED') $sText = '' For $i = 1 To UBound($aDrives) - 1 $sText &= DriveGetSerial($aDrives[$i]) Next $sText = StringStripWS($sText, $STR_STRIPALL) If $sText Then $iResult += $UHID_HDD $sOutput &= $sText EndIf EndIf Local $sHash = StringTrimLeft(_Crypt_HashData($sOutput, $CALG_MD5), StringLen('0x')) If Not $sHash Then Return SetError(1, 0, Null) EndIf Return SetExtended($iResult, StringRegExpReplace($sHash, '([[:xdigit:]]{8})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{4})([[:xdigit:]]{12})', '{\1-\2-\3-\4-\5}')) EndFunc ;==>_GetHardwareID Example use of Function: #include <APIDiagConstants.au3> #include <Crypt.au3> #include <StringConstants.au3> Local $sUniqueID = _GetHardwareID($UHID_All) ConsoleWrite('UniqueID: ' & $sUniqueID & @CRLF & _ 'Flags used: ' & @extended & @CRLF)
    1 point
×
×
  • Create New...