Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/03/2025 in all areas

  1. I need from from time to time to run small processes to perform task that would otherwise clog the main process. Yes, there is a number of other UDF that could have done it very well, but I felt they were an over-kill for what I wanted. Don't throw me stones, I know it's not really multi-threading, but it is as close as I could get with simple AutoIt. If someone wonders why I called it PMT, the P stands for Pretending. And I'm also not pretending it is an elaborate UDF. Just small and simple to use... Version 2025-01-03 * changed how temporary files are deleted * changed location of temporary files to use standard folder * added support to unusual location of AutoIt Version 2025-01-02 * corrected bug when temporary files has space within their name. Version 2024-03-24 * corrected bug when 8 parameters (max) is passed to the function Example : #AutoIt3Wrapper_Res_SaveSource=y #include "PMT-UDF.AU3" #include <Constants.au3> _PMT_Init() Local $hProc1 = _PMT_Start("Test1", Default, "Test 1") _PMT_Start("Test2") _PMT_Start("Test3", 5) Local $sResponse While Sleep(50) $sResponse = _PMT_GetResponse($hProc1) If @error Then Exit MsgBox($MB_OK, "Error", "Process has dropped") If $sResponse <> "" Then MsgBox($MB_OK, "Success", $sResponse & @CRLF) ExitLoop EndIf WEnd Func Test1($sTitle, $sMessage) Local $iResp = MsgBox($MB_OK, $sTitle, $sMessage) Return "Done with value " & $iResp EndFunc Func Test2() MsgBox($MB_OK, "2", "Test 2") EndFunc Func Test3($iTimeout) MsgBox($MB_OK, "3", "Test 3", $iTimeout) EndFunc You can pass up to 8 parameters to _PMT_Start. It is up to you to manage the right number. You cannot pass structures, maps or arrays as parameter (only bool, ptr, hWnd, int, float, string, and the keyword Default). You could use my WCD-IPC if need be to exchange large amount of data. If you want to run it compiled, you need to have add #AutoIt3Wrapper_Res_SaveSource=y at the start of your script. In the case you decide to compile your script, _PMT_Init allows you to identity where AutoIt3 is located (in the situation where AutoIt is not installed in the usual directory) to get the right includes in your "threads". Let me know if you have any question, or suggestion, I will be glad to hear them. Enjoy. PMT-UDF.au3
    2 points
  2. After digging into my script I found a small bug or improvement in the code of @UEZ in the UDF of GDI+ _GDIPlus_ImageScale() : I added Floor($iNewWidth), Floor($iNewHeight) Here is my script working nicely 😄 #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> Local $idPic, $idPic1 GUICreate('Test', 200, 500, 1050, 50) ;Create a GUI GUISetBkColor(0xFFFFFF) $idPic = _GUICtrlCreatePngScale(@ScriptDir & "\big-green.png", 5, 5, .035) $idPic1 = _GUICtrlCreatePngScale(@ScriptDir & "\big-green.png", 5, 200, 1) $idPic2 = GUICtrlCreatePic(@ScriptDir & "\green.bmp", 5, 300, 100, 100) GUICtrlSetPos($idPic1, 5, 150, 100, 100) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idPic MsgBox($MB_TOPMOST, "Information", "PNG 1 image was clicked") Case $idPic1 MsgBox($MB_TOPMOST, "Information", "PNG 2 image was clicked") Case $idPic2 MsgBox($MB_TOPMOST, "Information", "PNG 3 image was clicked") EndSwitch WEnd Func _GUICtrlCreatePngScale($_sName, $_left, $_top, $_iScale = 1) _GDIPlus_Startup() Local $_hImage = _GDIPlus_ImageLoadFromFile($_sName) ;The PNG image that you want to display Local $B_Scaled = _GDIPlus_ImageScaleNew($_hImage, $_iScale, $_iScale) Local $_idPic = GUICtrlCreatePic("", $_left, $_top, 20, 20) GUICtrlSendMsg($_idPic, 0x0172, 0, _GDIPlus_BitmapCreateHBITMAPFromBitmap($B_Scaled)) _WinAPI_DeleteObject($_hImage) ;some clean up _GDIPlus_ImageDispose($B_Scaled) _GDIPlus_Shutdown() Return $_idPic EndFunc ;==>_GUICtrlCreatePngScale Func _GDIPlus_ImageScaleNew($hImage, $iScaleW, $iScaleH, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) If @error Then Return SetError(1, 0, 0) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) If @error Then Return SetError(2, 0, 0) Local $iNewWidth = $iWidth * $iScaleW Local $iNewHeight = $iHeight * $iScaleH Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iNewWidth, $iNewHeight) If @error Then Return SetError(3, 0, 0) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) _GDIPlus_GraphicsSetInterpolationMode($hBmpCtxt, $iInterpolationMode) _GDIPlus_GraphicsSetPixelOffsetMode($hBmpCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $hIA = _GDIPlus_ImageAttributesCreate() __GDIPlus_ImageAttributesSetImageWrapMode($hIA) If @error Then _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_GraphicsDrawImageRectRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight, 0, 0, Floor($iNewWidth), Floor($iNewHeight), $hIA) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc ;==>_GDIPlus_ImageScale
    2 points
  3. I added this UDF to the wiki
    2 points
  4. water

    Fork UDF (ish)

    I added this UDF to the wiki
    2 points
  5. I wasn't asking for the AutoIt3Wrapper output but rather the stripped version of the script! So when you are sure the generated script is correct, you can force the use of it as long as you don't come crying to me! Just use directive: #AutoIt3Wrapper_Au3stripper_OnError= ;(C/S/ForceUse) Continue/Stop on Errors/Continue using stripped source in Exe (Default=C) The default behavior is to use the original when the au3stripper process isn't sure about being correct. (got sick and tired of people complaining the script wouldn't run properly after they simply ignored all these warnings/errors. )
    1 point
  6. Ah, you're right, I was using version: 3.3.14.5, but have now installed the new version: 3.3.16.1 and the example code posted above works now. The 2nd example code above is what I was looking for, I'm going to try using that. Thanks argumentum for the example code.
    1 point
  7. @argumentum You cannot use stripper with this UDF. You must understand that each function is separated from the rest of the code. So defining a global variable outside of the function will not work.
    1 point
  8. Not sure if this helps - I was looking for an out by 1 error re the cropping, but the scaling function looks to be correct as far as I can tell. 🤷‍♂️ Below is the same scaling routine, but I've added a 1px box around the image to help find the edge. Then I've saved the bitmap using _GDIPlus_ImageSaveToFile to inspect it and verify the new dimensions etc. So with this you can play with adding +1s with the widths and heights etc (just in case it helps) Func _GDIPlus_ImageScale2($hImage, $iScaleW, $iScaleH, $iInterpolationMode = $GDIP_INTERPOLATIONMODE_HIGHQUALITYBICUBIC) Local $iWidth = _GDIPlus_ImageGetWidth($hImage) If @error Then Return SetError(1, 0, 0) Local $iHeight = _GDIPlus_ImageGetHeight($hImage) If @error Then Return SetError(2, 0, 0) Local $iNewWidth = $iWidth * $iScaleW Local $iNewHeight = $iHeight * $iScaleH Local $hBitmap = _GDIPlus_BitmapCreateFromScan0($iNewWidth, $iNewHeight) If @error Then Return SetError(3, 0, 0) Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) Local $hPen = _GDIPlus_PenCreate(0xFFAA00AA) _GDIPlus_GraphicsDrawRect($hBmpCtxt, 0, 0, $iNewWidth-1, $iNewHeight-1, $hPen) _GDIPlus_GraphicsSetInterpolationMode($hBmpCtxt, $iInterpolationMode) _GDIPlus_GraphicsSetPixelOffsetMode($hBmpCtxt, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local $hIA = _GDIPlus_ImageAttributesCreate() __GDIPlus_ImageAttributesSetImageWrapMode($hIA) If @error Then _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) _GDIPlus_BitmapDispose($hBitmap) Return SetError(4, 0, 0) EndIf _GDIPlus_GraphicsDrawImageRectRect($hBmpCtxt, $hImage, 0, 0, $iWidth, $iHeight, 0, 0, $iNewWidth, $iNewHeight, $hIA) _GDIPlus_ImageAttributesDispose($hIA) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc
    1 point
  9. DutchCoder

    WinActiveBorder()

    Windows 11 also has a similar feature built-in (Settings -> Personalization -> Colors -> Show accent color on title bars and windows borders)
    1 point
×
×
  • Create New...