
DHL
Active Members-
Posts
26 -
Joined
-
Last visited
Profile Information
-
Location
Norway
DHL's Achievements

Seeker (1/7)
1
Reputation
-
Are my AutoIt exes really infected?
DHL replied to JSThePatriot's topic in AutoIt General Help and Support
Hi, We've been using AutoIt v.3.3.6.1 to compile our .au3 scripts because the online virus scanner "virustotal.com", that scans the uploaded file using different scanners and gives you a report showing the results, have seemed to report fewer false positives on executables when using the old 3.3.6.1 compiler instead of more recent, higher versions of AutoIt. We compile using AutoIt2Exe without UDF compression and sign them using our code-signing certificate from a trusted vendor. It has been a while since we compared scanning the same .au3 script compiled with different versions, and I was just wondering if version 3.3.6.1 still is the "safest" version or if people here have another preference for which AutoIt version / compiler that causes the least number of false positives? -
UEZ reacted to a post in a topic: _WinAPI_MarkScreenRegionAndCapture 0.92 build 2017-01-22
-
DHL reacted to a post in a topic: _WinAPI_MarkScreenRegionAndCapture 0.92 build 2017-01-22
-
_WinAPI_MarkScreenRegionAndCapture 0.92 build 2017-01-22
DHL replied to UEZ's topic in AutoIt Example Scripts
Thank you so much, @UEZ. I've tested the updated function, with manual capturing activated, and everything works as expected. Awesome stuff. Did my testing on Windows 10 Pro with two monitors having native resolutions of 2880x1800 (200% font scaling) and 2560x1440 (100% font scaling). -
_WinAPI_MarkScreenRegionAndCapture 0.92 build 2017-01-22
DHL replied to UEZ's topic in AutoIt Example Scripts
Excellent work, @UEZ. This has helped me a lot. You don't by any chance know of a function that does the same thing as this function (returns a GDI bitmap handle) but takes coordinates as input parameters? More specifically; I'm trying to find a function like _WinAPI_MarkScreenRegionAndCapture, except that I can call it programmatically like _ScreenCapture_Capture (x,y,width,height) and have it return a bitmap that includes layered windows, and letting me capture the areas of different monitors with different font scaling, without problems. Btw, this is the first example that I've found where screen capturing different applications, across multiple screens with different font scaling/DPI ratio, worked without errors. -
DHL reacted to a post in a topic: _WinAPI_MarkScreenRegionAndCapture 0.92 build 2017-01-22
-
Problems comparing two (in memory) bitmaps using memcmp
DHL replied to DHL's topic in AutoIt General Help and Support
Thanks for pointing out that one returns a bitmap object and the other an image object, @junkew. I'm not really sure what the difference between those two are, but I guess they are different GDI+ objects. I tried replacing the compare function in my code with @UEZ's _GDIPlus_ImageCompare and it just worked. I didn't have to do any "bitmap-object to image-object"-juggling. Amazing stuff and lightning fast. Thank you so much. -
DHL reacted to a post in a topic: Problems comparing two (in memory) bitmaps using memcmp
-
DHL reacted to a post in a topic: Problems comparing two (in memory) bitmaps using memcmp
-
Problems comparing two (in memory) bitmaps using memcmp
DHL replied to DHL's topic in AutoIt General Help and Support
Yeah, I agree it must be crashing because of some type mismatch. However, shouldn't _GDIPlus_BitmapCreateFromHBITMAP($memBmp) and _GDIPlus_ImageLoadFromFile($fname1) both return a handle to a bitmap object ? It seems so by the docs. What am I missing? https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_BitmapCreateFromHBITMAP.htm https://www.autoitscript.com/autoit3/docs/libfunctions/_GDIPlus_ImageLoadFromFile.htm -
Problems comparing two (in memory) bitmaps using memcmp
DHL replied to DHL's topic in AutoIt General Help and Support
Trying a little bump. I still haven't figured out why the second script works fine and the first doesn't. They both call DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest) The main difference is that the second script get the bitmap-handles from $bm1 = _GDIPlus_ImageLoadFromFile($fname1) while the first (which crashes) acquires the bitmap-handles using BitBlt and these lines: Local $hDC = _WinAPI_GetDC($hDesktop) Local $memDC = _WinAPI_CreateCompatibleDC($hDC) Local $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject ($memDC, $memBmp) _WinAPI_BitBlt($memDC, 0, 0, $Width, $Height, $hDC, 0,0, $__SCREENCAPTURECONSTANT_SRCCOPY) _WinAPI_DeleteDC($memDC) _WinAPI_ReleaseDC($hDesktop, $hDC) Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($memBmp) Anyone who can point me in the right direction on how to solve this problem? -
Hi, I'm trying to compare two bitmaps (screenshots of the desktop) that I create using BitBlt. The bitmaps can be successfully saved to disk, but when I run the two bitmaps through a CompareBitmaps()-function I found in this thread, which calls memcmp, the script crashes with "Exit code: -1073741819". This crash only happens when I try to compare bitmaps that I got by using BitBlt. If I use the CompareBitmaps()-function on bitmaps created by _GDIPlus_ImageLoadFromFile, everything works fine. (I'm using AutoIT 3.3.6.1) I'll attach my script that crashes, and the CompareBitmaps() example script that works (which I got from the thread previosly mentioned) My script, that for some reason crashes : #include <ScreenCapture.au3> #include <GDIPlus.au3> #include <WinAPI.au3> _GDIPlus_Startup() Local $hDesktop = _WinAPI_GetDesktopWindow() $clientS = WinGetClientSize($hDesktop) Local $Width = $clientS[0] Local $Height = $clientS[1] Local $hDC = _WinAPI_GetDC($hDesktop) Local $memDC = _WinAPI_CreateCompatibleDC($hDC) Local $memBmp = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject ($memDC, $memBmp) _WinAPI_BitBlt($memDC, 0, 0, $Width, $Height, $hDC, 0,0, $__SCREENCAPTURECONSTANT_SRCCOPY) _WinAPI_DeleteDC($memDC) _WinAPI_ReleaseDC($hDesktop, $hDC) Local $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($memBmp) _WinAPI_DeleteObject($memBmp) _GDIPlus_ImageSaveToFile($hImage1, @ScriptDir & "\GDIPlus_Image1.jpg") MsgBox(0, "Debug", "Screenshot taken & saved to disk. Ready to take new screenshot" ) Local $hDC2 = _WinAPI_GetDC($hDesktop) Local $memDC2 = _WinAPI_CreateCompatibleDC($hDC2) Local $memBmp2 = _WinAPI_CreateCompatibleBitmap($hDC2, $Width, $Height) _WinAPI_SelectObject ($memDC2, $memBmp2) _WinAPI_BitBlt($memDC2, 0, 0, $Width, $Height, $hDC2, 0,0, $__SCREENCAPTURECONSTANT_SRCCOPY) _WinAPI_DeleteDC($memDC2) _WinAPI_ReleaseDC($hDesktop, $hDC2) Local $hImage2 =_GDIPlus_BitmapCreateFromHBITMAP($memBmp2) _WinAPI_DeleteObject($memBmp2) _GDIPlus_ImageSaveToFile($hImage2, @ScriptDir & "\GDIPlus_Image2.jpg") MsgBox(0, "Debug", "Screenshot2 taken & saved to disk. Ready to compare images (from memory)" ) MsgBox(0, "bm1==bm2", CompareBitmaps($hImage1, $hImage2) ) ; Clean up resources _GDIPlus_ImageDispose($hImage1) _GDIPlus_ImageDispose($hImage2) ; Shut down GDI+ library _GDIPlus_ShutDown () Func CompareBitmaps($bm1, $bm2) $Bm1W = _GDIPlus_ImageGetWidth($bm1) $Bm1H = _GDIPlus_ImageGetHeight($bm1) $BitmapData1 = _GDIPlus_BitmapLockBits($bm1, 0, 0, $Bm1W, $Bm1H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData1, "Stride") $Scan0 = DllStructGetData($BitmapData1, "Scan0") $ptr1 = $Scan0 $size1 = ($Bm1H - 1) * $Stride + ($Bm1W - 1) * 4 $Bm2W = _GDIPlus_ImageGetWidth($bm2) $Bm2H = _GDIPlus_ImageGetHeight($bm2) $BitmapData2 = _GDIPlus_BitmapLockBits($bm2, 0, 0, $Bm2W, $Bm2H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData2, "Stride") $Scan0 = DllStructGetData($BitmapData2, "Scan0") $ptr2 = $Scan0 $size2 = ($Bm2H - 1) * $Stride + ($Bm2W - 1) * 4 $smallest = $size1 If $size2 < $smallest Then $smallest = $size2 $call = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest) _GDIPlus_BitmapUnlockBits($bm1, $BitmapData1) _GDIPlus_BitmapUnlockBits($bm2, $BitmapData2) Return ($call[0]=0) EndFunc ;==>CompareBitmaps Example Script (that basically does the same thing, but works fine) #include <GDIPlus.au3> _GDIPlus_Startup() $fname1=FileOpenDialog("First image","","All images(*.bmp;*.jpg;*.png;)") If $fname1="" Then Exit $fname2=FileOpenDialog("Second image image","","All images(*.bmp;*.jpg;*.png;)") If $fname2="" Then Exit $bm1 = _GDIPlus_ImageLoadFromFile($fname1) $bm2 = _GDIPlus_ImageLoadFromFile($fname2) MsgBox(0, "bm1==bm2", CompareBitmaps($bm1, $bm2)) _GDIPlus_ImageDispose($bm1) _GDIPlus_ImageDispose($bm2) _GDIPlus_Shutdown() Func CompareBitmaps($bm1, $bm2) $Bm1W = _GDIPlus_ImageGetWidth($bm1) $Bm1H = _GDIPlus_ImageGetHeight($bm1) $BitmapData1 = _GDIPlus_BitmapLockBits($bm1, 0, 0, $Bm1W, $Bm1H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData1, "Stride") $Scan0 = DllStructGetData($BitmapData1, "Scan0") $ptr1 = $Scan0 $size1 = ($Bm1H - 1) * $Stride + ($Bm1W - 1) * 4 $Bm2W = _GDIPlus_ImageGetWidth($bm2) $Bm2H = _GDIPlus_ImageGetHeight($bm2) $BitmapData2 = _GDIPlus_BitmapLockBits($bm2, 0, 0, $Bm2W, $Bm2H, $GDIP_ILMREAD, $GDIP_PXF32RGB) $Stride = DllStructGetData($BitmapData2, "Stride") $Scan0 = DllStructGetData($BitmapData2, "Scan0") $ptr2 = $Scan0 $size2 = ($Bm2H - 1) * $Stride + ($Bm2W - 1) * 4 $smallest = $size1 If $size2 < $smallest Then $smallest = $size2 $call = DllCall("msvcrt.dll", "int:cdecl", "memcmp", "ptr", $ptr1, "ptr", $ptr2, "int", $smallest) _GDIPlus_BitmapUnlockBits($bm1, $BitmapData1) _GDIPlus_BitmapUnlockBits($bm2, $BitmapData2) Return ($call[0]=0) EndFunc ;==>CompareBitmaps Any one got a clue why my script crashes?
-
You can get the raw data of a snapshot using FFGetRawData ( [ NoSnapShot ]). From the manual: It returns a string stride with the Raw bytes of the SnapShot in 8 Hex digits (BGRA) of pixels from left to right, top to bottom ; every pixel can be accessed like this: StringMid($sStride, $pixelNo *8 +1 ,8) and you get for example 685E5B00 (blue = 68, green = 5E, red = 5B, alpha = 00). However, I agree it would be nice to have an option for FFSnapShot to return a handle to a HBITMAP, similar to what the _ScreenCapture_Capture method does.
-
Maximum number of chars in one single cmdLine parameter
DHL replied to DHL's topic in AutoIt General Help and Support
Thanks for the fast replies, water and guinness. Water, Yes - I could use two parameters. I'm playing around with some stuff and the example was more a hypothetical than a practical problem. But thanks :-) -
The help file says that a "maximum number of 63 parameters can be returned by the array $CmdLine[]". (https://www.autoitscript.com/autoit3/docs/intro/running.htm) But how many characters can one parameter have at the most? Say I'm creating a script where i input two file-paths in one single command line parameter (delimited by some none-filepath character, like "!"). Do I need to worry about the length of that specific $cmdLine[x] input parameter (string) being too long for AutoIt?
-
Bugreport: ConsoleRead() broken reading on chinese systems
DHL replied to viroman's topic in AutoIt General Help and Support
Just wanted to say that I have the exact same problem. Did you find a solution, viroman? -
Hi FastFrench, Thanks for putting it up on GitHub. I'll have a look at the source code and see if I can contribute.
-
Smooth display of PNGs with transparency, fade-in/out and AOT
DHL replied to timmy2's topic in AutoIt Example Scripts
Hi. Thanks for a nice code example. I'm having some issues getting it to work properly: When I try running this example, nothing appears. I get no error messages in console, but still nothing is displayed. The images are located in the same folder as the script. I also tried adding @ScriptDir, but without any luck. I tried removing the styles from GUICreate, just to see if the windows appeared on my desktop, and that worked, but the window contents were just gray (no image/content) and no image faded in/out. _GDIPlus_ImageGetWidth, etc. reports the correct values, so it seems to be an issue with displaying the images on the Gui. I'm running Autoit 3.3.6.1 on Win 8.1. I'm using UEZs code "Complete Code"-example, Posted 02 November 2013 - 01:49 PM: ; Functions coded by UEZ 2013-11-02 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #NoTrayIcon _GDIPlus_Startup() ;initiate GDI+ #region ; timmy2's simple demonstration of UEZ's code ; ; display blank chalkboard (there will be no fade-in so use default $iAlpha value of 255) $aRes1 = DisplayImage( "Wood-framed-chalkboard.png", -1, -1 ) If @error Then ConsoleWrite( "Error " & @error & " has occured." & @LF ) _GDIPlus_Shutdown() Exit EndIf Sleep (500) ; add first two steps $aRes2 = DisplayImage("step-1.png", -1, -1 ) Sleep(2000) $aRes3 = DisplayImage("step-2.png", -1, -1 ) ; fade in handdrawn circle (therefore start with $iAlpha = 0) $aPos = WinGetPos($aRes1[0]) $aRes4 = DisplayImage("circle.png", $aPos[0] + 290, $aPos[1] + 75, 0) sleep (500) _Fader($aRes4) sleep(1000) _Fader($aRes4, False) ReleaseResources($aRes4) sleep(500) ; add third step $aRes5 = DisplayImage("step-3.png", -1, -1 ) Sleep(2000) ; fade the three steps out in reverse order (faster than defaults) _Fader($aRes5, False, 255, 5, 5) ReleaseResources($aRes5) _Fader($aRes3, False, 255, 5, 5) ReleaseResources($aRes3) _Fader($aRes2, False, 255, 5, 5) ReleaseResources($aRes2) Sleep(500) ; fade out chockboard _Fader($aRes1, False, 255, 10, 5) ReleaseResources($aRes1) #endregion _GDIPlus_Shutdown() Exit ; Display the image at center unless otherwise specified. If Fader will not be used then $iAlpha's default of 0xFF is good. ; If Fader will be used then start with $iAlpha equal to zero. Option to make this image "Always on top" is also available. Func DisplayImage($sFile, $iPosX = -1, $iPosY = -1, $iAlpha = 0xFF, $bTopmost = True) Local Const $hBmp_Background = _GDIPlus_BitmapCreateFromFile($sFile) ;load the image If @error Then Return SetError(1, 0, 0) ;image cannot be loaded Local Const $iW = _GDIPlus_ImageGetWidth($hBmp_Background), $iH = _GDIPlus_ImageGetHeight($hBmp_Background) ;get the dimension of the background image Local Const $hGUI = GUICreate("", $iW, $iH, $iPosX, $iPosY, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST * $bTopmost, $WS_EX_TOOLWINDOW)) ;create GUI with appropriate styles and extented style (borderless transparent GUI) GUICtrlCreateLabel("", 0, 0, $iW, $iH, Default, $GUI_WS_EX_PARENTDRAG) ;create a hidden label for GUI dragging GUISetState(@SW_SHOW, $hGUI) ;show GUI Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH) ;define an empty bitmap where all the gfx stuff will copied to Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap) ;get the context to the bitmap to be able to copy / draw to the bitmap _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp_Background, 0, 0, $iW, $iH) ;draw background image to the empty bitmap ;display GDI+ with transparency on desktop Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap) ;convert GDI+ image to GDI to display it on the screen using GDI functions Local Const $hScrDC = _WinAPI_GetDC($hGUI) ;get the device context (dc) handle of the GUI Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) ;create a compatible dc handle Local Const $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) ;selects the GDI bitmap object into the specified device context Local Const $tSize = DllStructCreate($tagSIZE) ;create a $tagSIZE struct (x = width, y = height) DllStructSetData($tSize, "X", $iW) ;set data for width DllStructSetData($tSize, "Y", $iH) ;set data for height Local $tSource = DllStructCreate($tagPOINT) ;create a $tagPOINT struct (x = x position, y = y position) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) ;create $tagBLENDFUNCTION struct -> see help file for more info DllStructSetData($tBlend, "Alpha", $iAlpha) ;set the alpha channel of the GUI -> 255 = opaque, 0 = transparent DllStructSetData($tBlend, "Format", 1) ;set the format to 1 -> bitmap has alpha channels DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $hGUI, "handle", $hScrDC, "ptr", 0, "struct*", $tSize, "handle", $hMemDC, "struct*", $tSource, "dword", 0, "struct*", $tBlend, "dword", $ULW_ALPHA) ;display bitmap on screen ;release resources otherwise memory will filled up (memory leak) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_BitmapDispose($hBitmap) Local $aResource[7] = [$hGUI, _ ;GUI handle $hScrDC, _ ;device context (dc) handle of the GUI (GDI) $hHBitmap, _ ;GDI bitmap handle of the displayed image $hMemDC, _ ;compatible dc handle from $hScrDC $tBlend, _ ;tBlend struct (source blend oper., flags, alpha value, format) -> see help file for description $tSize, _ ;tSize struct (width and height of the window / image) $tSource] ;tSource struct for x / y position of the GUI Return $aResource ;returns the handles to release it later or to use it for fading effects EndFunc ;==>DisplayImage ; This function releases the resources of a specific image and closes it Func ReleaseResources(ByRef $aResource) If Not IsArray($aResource) Then Return SetError(1, 0, 0) If UBound($aResource) <> 7 Then Return SetError(2, 0, 0) _WinAPI_ReleaseDC($aResource[0], $aResource[1]) _WinAPI_DeleteDC($aResource[3]) _WinAPI_DeleteObject($aResource[2]) GUIDelete($aResource[0]) EndFunc ;==>ReleaseResources ; To fade in an image leave $bIn at default (True); to fade out specify False. ; There are also options to set the ending transparency level (0 transparent, 255 opaque), speed and delay. ; If you change the speed or delay be sure to specify $bIn and $iTrans, otherwise you'll wonder why the fade-in or out isn't what you hoped for. ; The default values are specified in the function below. Func _Fader($res1, $bIn = True, $iTrans = 255, $speed = 3, $delay = 10 ) If Not IsArray($res1) Then Return SetError(1, 0, 0) If UBound($res1) <> 7 Then Return SetError(2, 0, 0) Switch $bIn Case True For $a = 0 To $iTrans Step $speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next Case Else For $a = $iTrans To 0 Step -$speed DllStructSetData($res1[4], "Alpha", $a) DllCall("user32.dll", "bool", "UpdateLayeredWindow", "hwnd", $res1[0], "handle", $res1[1], "ptr", 0, "struct*", $res1[5], "handle", $res1[3], "struct*", $res1[6], "dword", 0, "struct*", $res1[4], "dword", $ULW_ALPHA) ;display bitmap on screen Sleep($delay) Next EndSwitch EndFunc ;==>_FadeIn #region GDI and GDI+ functions Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iPixelFormat = $GDIP_PXF32ARGB, $iStride = 0, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "int", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "handle*", 0) If @error Then Return SetError(@error, @extended, 0) If $aResult[0] Then Return SetError(10, $aResult[0], 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 #endregion GDI and GDI+ functions- 23 replies
-
- PNG
- alpha channel
-
(and 2 more)
Tagged with:
-
Just a small update to my last post with some new bits of information that might help debug the issue: I downloaded version 1.3 of the script (from http://www.autoitscript.fr/forum/viewtopic.php?f=21&t=7090) and it works with FFLocalizeChanges and FFisDifferent (tried on autoit x32 on Windows 8.1) When trying version 1.5-2.1 I get the error message that FastFind.dll cannot be opened when initializing the script. Version 2.2 crashes on second run of FFLocalizeChanges (as described in previous post) Hope this helps.
-
Hi, FastFrench First of all, thank you for a great library. I have one issue though, one that is already mentioned; Any update on this? I'm having the same issue (crash) as BeginnerUser when running FFLocalizeChanges(0, 1) the second time (in FastFind_Demo). I've tried setting FFSetDebugMode(0), but it didn't help. I need to compare two snapshots and see if there's been any changes. Is there a workaround? Either way, I'd love to help out if you decide to share the source. Happy holidays! :-) --DHL