Sign in to follow this  
Followers 0
wakillon

Polaroider v1.0.3.1 Update of 03 july 2013

44 posts in this topic

#1 ·  Posted (edited)

Polaroider 1.0.3.1

Easily Create a picture as a Polaroid and be able after, to create Custom Photos Polaroid Collage.

May be you know Pola a soft for create easily Polaroid-like photos from your digital images, but after some tries, i didn't find it very handy !

So i made mine.

 

201306301803461.jpg

Photo can be positioned by drag and zoomed/unzoomed with mouse wheel ( sorry for Touchpad user :P   )

Polaroid can be inclined 10 or 20 degrees, on left or right, and with simple or multiple frames.

Inclination will only be visible on the saved shoot.

It is also saved with a transparent background for be able to create "Pêle-Mêles" (in french) with a photo editor.

I have set the desktop as save directory.

previous downloads : 122

 

source and executable are available in the Download Section

All files are included in script.

I hope you will like it !

Happy Shooting !  ;)

Edited by wakillon
2 people like this

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Nice work wakillon.  :thumbsup:

Just add to line 611

DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hGraphic6, "int", 4)

to add also antialiasing to Vista+ os.

And here a code to get some information about images:

#include <GDIPlus.au3>

Global $sFile = FileOpenDialog("Select an image", "", "(*.jpg;*.png;*.bmp;*.gif;*.tif;*.ico;*.emf;*.wmf)")
If @error Then Exit
_GDIPlus_Startup()
Global $hImage = _GDIPlus_ImageLoadFromFile($sFile)
Global $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hImage)
Global $aImageRawFormat = _GDIPlus_ImageGetRawFormat($hImage)
Global $hImageContext = _GDIPlus_ImageGetGraphicsContext($hImage)
Global $aImageDPIX = DllCall($ghGDIPDll, "uint", "GdipGetDpiX", "handle", $hImageContext, "float*", 0)
Global $aImageDPIY = DllCall($ghGDIPDll, "uint", "GdipGetDpiY", "handle", $hImageContext, "float*", 0)

MsgBox(0, "Image Information",  "Filename: " & $sFile & @LF & @LF & _
                                "Width: " & @TAB & @TAB & _GDIPlus_ImageGetWidth($hImage) & @LF & _
                                "Height: " & @TAB & @TAB & _GDIPlus_ImageGetHeight($hImage) & @LF & _
                                "DPI: " & @TAB & @TAB & Round($aImageDPIX[2], 0) & "x" & Round($aImageDPIY[2], 0) & @LF & _
                                "Color Depth: " & @TAB & $aPixelFormat[1]  & @LF & _
                                "Image Type: " & @TAB & $aImageRawFormat[1], 30)

_GDIPlus_GraphicsDispose($hImageContext)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit

When loading large images and moving around the window the window will be jerky. My suggestion scale down the preview image instead to copy always the large image to the preview gfx handle.

Are the tiny loves your kids?

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Very nice thank you very much.  :thumbsup:

Share this post


Link to post
Share on other sites

Looks good. Thanks for sharing!


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Nice work wakillon.  :thumbsup:

Just add to line 611

DllCall($ghGDIPDll, "uint", "GdipSetTextRenderingHint", "handle", $hGraphic6, "int", 4)

to add also antialiasing to Vista+ os.

And here a code to get some information about images:

#include <GDIPlus.au3>

Global $sFile = FileOpenDialog("Select an image", "", "(*.jpg;*.png;*.bmp;*.gif;*.tif;*.ico;*.emf;*.wmf)")
If @error Then Exit
_GDIPlus_Startup()
Global $hImage = _GDIPlus_ImageLoadFromFile($sFile)
Global $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hImage)
Global $aImageRawFormat = _GDIPlus_ImageGetRawFormat($hImage)
Global $hImageContext = _GDIPlus_ImageGetGraphicsContext($hImage)
Global $aImageDPIX = DllCall($ghGDIPDll, "uint", "GdipGetDpiX", "handle", $hImageContext, "float*", 0)
Global $aImageDPIY = DllCall($ghGDIPDll, "uint", "GdipGetDpiY", "handle", $hImageContext, "float*", 0)

MsgBox(0, "Image Information",  "Filename: " & $sFile & @LF & @LF & _
                                "Width: " & @TAB & @TAB & _GDIPlus_ImageGetWidth($hImage) & @LF & _
                                "Height: " & @TAB & @TAB & _GDIPlus_ImageGetHeight($hImage) & @LF & _
                                "DPI: " & @TAB & @TAB & Round($aImageDPIX[2], 0) & "x" & Round($aImageDPIY[2], 0) & @LF & _
                                "Color Depth: " & @TAB & $aPixelFormat[1]  & @LF & _
                                "Image Type: " & @TAB & $aImageRawFormat[1], 30)

_GDIPlus_GraphicsDispose($hImageContext)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
Exit

When loading large images and moving around the window the window will be jerky. My suggestion scale down the preview image instead to copy always the large image to the preview gfx handle.

Are the tiny loves your kids?

Br,

UEZ

 

Hi UEZ 

Is the antialiasing line you suggest need to be repeat for other graphics handles ?

And i don't understand your scale down preview image suggestion...do you want to reduce the preview ? i found it so small !

It interest me because i'm working on another project with bigger photos than this preview.  ;)

And yes, it's my kids (photos are old now)  

Thanks for your help!  :)

 

Very nice thank you very much.  :thumbsup:

 

Glad you like it !

Looks good. Thanks for sharing!

 

Thanks !


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Hi UEZ 

Is the antialiasing line you suggest need to be repeat for other graphics handles ?

And i don't understand your scale down preview image suggestion...do you want to reduce the preview ? i found it so small !

It interest me because i'm working on another project with bigger photos than this preview.  ;)

And yes, it's my kids (photos are old now)  

Thanks for your help!  :)

 

Glad you like it !

 

Thanks !

 

Yes, you can add also to the other gfx handles which makes sense, otherwise only GUI text is anti aliased.

Regarding scale down preview: your polaroid preview has a dimension of 285x285 px and e.g. if you load an image with dimension 2400x3200 px you always copy that image to the preview handle which slows down it extremely. I would scale the image down once only to display it in the preview handle. It will be much faster on repaint activities.

Very cute kids on that picture.

Br,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Nice. And lovely kids!

I'm running executable you provided and unfortunately I get crashes on exit, for example if I start the app and then do nothing but close it. I was intrigued so I went through the source you provided and really without goinng too deep saw it's the _ControlGlobalSubclass() that causes the issues.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Yes, you can add also to the other gfx handles which makes sense, otherwise only GUI text is anti aliased.

Regarding scale down preview: your polaroid preview has a dimension of 285x285 px and e.g. if you load an image with dimension 2400x3200 px you always copy that image to the preview handle which slows down it extremely. I would scale the image down once only to display it in the preview handle. It will be much faster on repaint activities.

Very cute kids on that picture.

Br,

UEZ

 

Ok, if after drag'n drop, i do a copy of the photo with a reduced size, it will be less jerky, I'm right ?

But if size is reduced, is quality zoom not affected ?  :huh:


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Nice. And lovely kids!

 

I'm running executable you provided and unfortunately I get crashes on exit, for example if I start the app and then do nothing but close it. I was intrigued so I went through the source you provided and really without goinng too deep saw it's the _ControlGlobalSubclass() that causes the issues.

 

Hi trancexx, glad you like it !  :king:

I can't reproduce your crashes (win7x64)

 

Can you please try this debug way ?

 

1 - add  If @error Then ConsoleWrite ( '@error : ' & @error & @Crlf ) after _ControlGlobalSubclass () line

 

2 - replace _ControlGlobalSubclass () function by this one

 

Func _ControlGlobalSubclass () ; by rover
    If $hNew_ControlProc <> 0 Then Return SetError ( 1, 0, 0 )
    Local $hGUITemp = GUICreate ( '', 1, 1, -10, -10 )
    Local $hButtonTemp = GUICtrlGetHandle ( GUICtrlCreateButton ( '', -10, -10, 1, 1 ) )
    $hNew_ControlProc = DllCallbackRegister ( '_WndProc', 'int', 'hwnd;uint;wparam;lparam' )
    If $hNew_ControlProc = 0 Then Return SetError ( 2, 0, 0 )
    Local $pCallbackPtr = DllCallbackGetPtr ( $hNew_ControlProc )
    If $pCallbackPtr = 0 Then Return SetError ( 3, 0, 0 )
    $pOriginal_ButtonProc = DllCall ( $hUser32DLL, 'dword', 'SetClassLongW', 'hwnd', $hButtonTemp, 'int', -24, 'ptr', $pCallbackPtr ) ; $GCL_WNDPROC
    If @error Then Return SetError ( 4, 0, 0 )
    $pOriginal_ButtonProc = $pOriginal_ButtonProc[0]
    GUIDelete ( $hGUITemp )
    Return SetError ( 0, 0, 1 )
EndFunc ;==> _ControlGlobalSubclass ()

3 - and in _OnAutoItExit () function replace DllCallbackFree ( $hNew_ControlProc ) by :

If $hNew_ControlProc <> 0 Then
        DllCallbackFree ( $hNew_ControlProc )
        If @error Then ConsoleWrite ( '@error : ' & @error & @Crlf )
    EndIf

Thanks for your help  :)

Edit : it's a >Rover's tips for prevent dotted focus lines on controls.

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

^^ I don't have AutoIt installed here where I am so I can't run scripts.

...I can run executables though.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Take rover's example and remove line

GUIDelete($hGUI)

... then try it. What results you get there?

I see he has this comment which you ignored:

; Must delete subclassed controls before freeing DLLCallbacks 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Edited by trancexx

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

^^ I don't have AutoIt installed here where I am so I can't run scripts.

...I can run executables though.

 

Oh, ok

So could you try this Polaroider v1.0.2.9.exe modified ? 


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

 

Take rover's example and remove line

GUIDelete($hGUI)

... then try it. What results you get there?

I see he has this comment which you ignored:

; Must delete subclassed controls before freeing DLLCallbacks 
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 

Results return absolutely no crashes, compiled or not, after 10 tries...

+>09:56:04 AutoIt3.exe ended.rc:0
>Exit code: 0    Time: 3.518

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Still, could you add line like that to your app and upload it for me. Polaroider v1.0.2.9.exe crashes for me also.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Still, could you add line like that to your app and upload it for me. Polaroider v1.0.2.9.exe crashes for me also.

 

No problem, GUIDelete ( $hGUI ) added in _OnAutoItExit function.

Polaroider v1.0.3.0.exe

i must change file version because with googlecode each uploaded file must have a distinct name.

:)


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

No problem, GUIDelete ( $hGUI ) added in _OnAutoItExit function.

Polaroider v1.0.3.0.exe

i must change file version because with googlecode each uploaded file must have a distinct name.

:)

That's the same.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

No wait, that's fine now. I was running older version.

Yep, that one is good!


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

No wait, that's fine now. I was running older version.

Yep, that one is good!

 

Cool, thanks for your help !  :thumbsup:

I look forward to see your polaroids !  :D


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

I look forward to see your polaroids !  :D

Nice one.

Thanks for fixing it for me.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Nice one.

Thanks for fixing it for me.

 

All thanks are for you, and between us, I couldn't resist to the beautiful smile of your avatar!  :D


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Similar Content

    • rootx
      By rootx
      how can I fit the image when the GUI is maximized? I would like to always measure the 50% height and width of the GUI and is always in the bottom right poistion, and does not lose its quality.
      THX
       
      #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> #include <Array.au3> #include <WinAPI.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124,BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP)) _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir&"\img.jpg") $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Form1) $resimg = _GDIPlus_ImageResize($hImage,200,300) _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, 0, 0) GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT") ;GUIRegisterMsg($WM_SIZE, "WM_SIZE") GUISetState(@SW_SHOW,$Form1) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func MY_WM_PAINT($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_UPDATENOW) _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, 300, 0) _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_VALIDATE) Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_PAINT ;Func WM_SIZE($hWnd, $iMsg, $iwParam, $ilParam) ; #forceref $hWnd, $iMsg, $iwParam, $ilParam ; Local $xClient, $yClient ; $xClient = BitAND($ilParam, 0x0000FFFF) ; $yClient = BitShift($ilParam, 16) ; _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_UPDATENOW) ; _GDIPlus_GraphicsDrawImage($hGraphics, $resimg, $xClient/2, $yClient/2) ; _WinAPI_RedrawWindow($Form1, 0, 0, $RDW_VALIDATE) ; ConsoleWrite($xClient & " "&$yClient&@CR) ; Return $GUI_RUNDEFMSG ;EndFunc  
    • chacoya121
      By chacoya121
      plz help explain between GDI+ and Winapi, is it desktop inside another desktop, 3 layer dimension?
      i can't get the picture
      1. u get desktop u can visual see
      2. then u create GDI+ startup another desktop screen dimension?
      3. then u have Winapi command inside GDI+, is this another desktop screen dimension? cuz GDI+ could create bitmap that is one dimension? Winapi get windowDC also another dimension?
      plz help and explain, with picture would be nice, im not good with visualize ("dumb newbie"), still learning
      newbie to programming world
      thankyou.
    • mdwerne
      By mdwerne
      I'm attempting to cobble together a replacement for the 64bit version of BGInfo that will run within WinPE 10/64. I've located a couple useful threads:
       Between the two, they get me close (see code below), but for some reason GDI+ is not working the same within WinPE as it does in Windows 10. Bottomline is that the "Text" never get's written to WallPaper.
      Here is what I have thus far. Any thoughts if any of the GDI commands might not work within WinPE? Any other way to achieve the same result (system information on the wallpaper in WinPE 10)?
      #include <GDIPlus.au3> #include <Date.au3> _GDIPlus_Startup() $image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\WallPaper.bmp") $imagegraphics = _GDIPlus_ImageGetGraphicsContext($image) $w = _GDIPlus_ImageGetWidth($image) $h = _GDIPlus_ImageGetHeight($image) $whitebrush = _GDIPlus_BrushCreateSolid(0xFFFFFFFF) $fontfamily = _GDIPlus_FontFamilyCreate("Arial") $font = _GDIPlus_FontCreate($fontfamily, 16) $stringformat = _GDIPlus_StringFormatCreate() _GDIPlus_StringFormatSetAlign($stringformat, 2) $rect = _GDIPlus_RectFCreate(0, $h - $h + 100, $w - 25, $h) ;$rect = _GDIPlus_RectFCreate(100, 100, 200, 200) _GDIPlus_GraphicsDrawStringEx($imagegraphics, _Now() & @CRLF & @UserName & @CRLF & @ComputerName & @CRLF & @IPAddress1, $font, $rect, $stringformat, $whitebrush) _GDIPlus_ImageSaveToFile($image, @ScriptDir & "\NewWallPaper.bmp") _GDIPlus_ImageDispose($image) _GDIPlus_GraphicsDispose($imagegraphics) _GDIPlus_BrushDispose($whitebrush) _GDIPlus_FontFamilyDispose($fontfamily) _GDIPlus_FontDispose($font) _GDIPlus_StringFormatDispose($stringformat) _GDIPlus_Shutdown() _ChangeDesktopWallpaper(@ScriptDir & "\NewWallPaper.bmp", 2) Func _ChangeDesktopWallpaper($bmp, $style = 0) ;=============================================================================== ; ; Function Name: _ChangeDesktopWallPaper ; Description: Update WallPaper Settings ; Usage: _ChangeDesktopWallPaper(@WindowsDir & '\' & 'zapotec.bmp',1) ; Parameter(s): $bmp - Full Path to BitMap File (*.bmp) ; [$style] - 0 = Centered, 1 = Tiled, 2 = Stretched ; Requirement(s): None. ; Return Value(s): On Success - Returns 0 ; On Failure - -1 ; Author(s): FlyingBoz ; Thanks: Larry - DllCall Example - Tested and Working under XPHome and W2K Pro ; Excalibur - Reawakening my interest in Getting This done. ; ;=============================================================================== If Not FileExists($bmp) Then Return -1 ;The $SPI* values could be defined elsewhere via #include - if you conflict, ; remove these, or add if Not IsDeclared "SPI_SETDESKWALLPAPER" Logic Local $SPI_SETDESKWALLPAPER = 20 Local $SPIF_UPDATEINIFILE = 1 Local $SPIF_SENDCHANGE = 2 Local $REG_DESKTOP = "HKEY_CURRENT_USER\Control Panel\Desktop" If $style = 1 Then RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 1) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", 0) Else RegWrite($REG_DESKTOP, "TileWallPaper", "REG_SZ", 0) RegWrite($REG_DESKTOP, "WallpaperStyle", "REG_SZ", $style) EndIf DllCall("user32.dll", "int", "SystemParametersInfo", _ "int", $SPI_SETDESKWALLPAPER, _ "int", 0, _ "str", $bmp, _ "int", BitOR($SPIF_UPDATEINIFILE, $SPIF_SENDCHANGE)) Return 0 EndFunc ;==>_ChangeDesktopWallpaper Thanks for your time,
      -Mike
    • UEZ
      By UEZ
      Here some graphical examples written completely in FreeBasic just for fun.  
      3D Starfield Scrolling v1 Booster 3D Starfield Scrolling v3 Booster GDI - GDI+ 3D Sinus Wave GDI - GDI+ Animated Pythagoras Tree GDI - GDI+ Particles - Repulsive Force Sim v2.0 GDI - GDI+ Plasma v5 Booster GDI - GDI+ Random Pattern GDI - GDI+ Tunnel Flight - WipeOut Style GDI Classic Raytraced Tunnel GDI Elastic Twister Effect GDI Exploding Pixels GDI Liquid Pixels GDI Particle Repulsion Grid GDI Particles Mouse Attraction GDI Starfield GDI The Nautilus Raymarcher GDI+ Performance Test - Au3 vs FB Mandelbrot Rutt_Etra_Izer_Booster  
      Download: FreeBasic Examples build 2017-01-22.7z
      I will add new examples from time to time.
       
      FreeBasic source codes are also included.
       
    • UEZ
      By UEZ
      Here a small function to mark a region on the desktop and capture that region to a bitmap handle or to the clipboard:
      #include-once #include <Clipboard.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #Region Example ;capture manual coordinates FileDelete(@ScriptDir & "\Captured.bmp") Global $hHBitmap = _WinAPI_MarkScreenRegionAndCapture(0, False, True, 0, 0, 99, 99) _WinAPI_SaveHBITMAPToFile(@ScriptDir & "\Captured.bmp", $hHBitmap) _WinAPI_DeleteObject($hHBitmap) If FileExists(@ScriptDir & "\Captured.bmp") Then ShellExecute(@ScriptDir & "\Captured.bmp") ;save the captured bitmap to a file FileDelete(@ScriptDir & "\Captured.bmp") Global $hHBitmap = _WinAPI_MarkScreenRegionAndCapture() _WinAPI_SaveHBITMAPToFile(@ScriptDir & "\Captured.bmp", $hHBitmap) _WinAPI_DeleteObject($hHBitmap) If FileExists(@ScriptDir & "\Captured.bmp") Then ShellExecute(@ScriptDir & "\Captured.bmp") ;copy captured bitmap to clipboard Switch _WinAPI_MarkScreenRegionAndCapture(1, True) Case 1 MsgBox($MB_ICONINFORMATION, "Information", "Marked region was properly captured to clipboard!", 30) Case 0 MsgBox($MB_ICONERROR, "ERROR", "An error has occured!", 30) EndSwitch #EndRegion ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_MarkScreenRegionAndCapture ; Description ...: Selected area on desktop will be captured and save to clipbord or GDI bitmap handle will be returned. ; Syntax ........: _WinAPI_MarkScreenRegionAndCapture([$iFillMode = 0[, $bClipboard = True]]) ; Parameters ....: $iFillMode - [optional] an integer value. Default is 0. ; 0: marked area filled with solid color ; 1: marked area filled with hatch pattern ($HS_DIAGCROSS) ; 2: marked area without any fill pattern / color - only red border ; $bClipboard - [optional] a boolean value. Default is False. If True then no GDI bitmap handle will be returned. ; If false then GDI bitmap handle will be returned. ; $bManual - [optional] a boolean value. Default is False. If True manual capturing is activated. ; $iX1 - [optional] an integer value. Default is 0. If $bManual is true enter the x1 screen pos. ; $iY1 - [optional] an integer value. Default is 0. If $bManual is true enter the Y1 screen pos. ; $iX2 - [optional] an integer value. Default is 0. If $bManual is true enter the x2 screen pos. ; $iY2 - [optional] an integer value. Default is 0. If $bManual is true enter the y2 screen pos. ; Return values .: 0 / 1 / -1 / GDI bitmap handle ; Author ........: UEZ ; Version .......: 0.92 build 2017-01-22 ; Modified ......: ; Remarks .......: Do not forget to dispose returned GDI bitmap handle for non clipboard mode using _WinAPI_DeleteObject! ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_MarkScreenRegionAndCapture($iFillMode = 0, $bClipboard = False, $bManual = False, $iX1 = 0, $iY1 = 0, $iX2 = 0, $iY2 = 0) If @OSBuild > 6299 Then ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx DllCall("Shcore.dll", "long", "PROCESS_DPI_AWARENESS", 1) ;PROCESS_SYSTEM_DPI_AWARE = 1 (https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx) Else DllCall("User32.dll", "bool", "SetProcessDPIAware") EndIf Local $iOld = AutoItSetOption("MouseCoordMode", 1) If Not $bManual Then Local Const $hDesktop = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hDesktop) ;should work also on multi screens Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local Const $hGUI_Screencapture = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState(@SW_SHOW, $hGUI_Screencapture) Local Const $hDC = _WinAPI_GetDC($hGUI_Screencapture) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) Local $tSize = DllStructCreate($tagSIZE) $tSize.x = $iW $tSize.y = $iH Local $tSource = DllStructCreate($tagPOINT) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) $tBlend.Alpha = 0xFF $tBlend.Format = 1 Local $tDest = DllStructCreate($tagPOINT), $pPoint = DllStructGetPtr($tDest) $tDest.x = $aFullScreen[0] $tDest.y = $aFullScreen[1] Local Const $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x0000FF) Local Const $hPen_Orig = _WinAPI_SelectObject($hGfxDC, $hPen) Local $hBrush, $iAlpha2, $iFlag $iFillMode = $iFillMode > 2 ? 2 : $iFillMode < 0 ? 0 : $iFillMode Switch $iFillMode Case 0 $hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0x808080) $iAlpha2 = 0xA0 $iFlag = $ULW_ALPHA Case 1 $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x808000, $HS_DIAGCROSS) $iAlpha2 = 0x30 $iFlag = $ULW_ALPHA Case 2 $hBrush = _WinAPI_CreateBrushIndirect($BS_HOLLOW, 0x000000) $iAlpha2 = 0xFF ;not needed $iFlag = $ULW_COLORKEY EndSwitch Local $hBrush_Orig = _WinAPI_SelectObject($hGfxDC, $hBrush) Else If Not BitOr($iX1, $iX2, $iY1, $iY2) Then Return SetError(4, 0, 0) EndIf Local $aMPos[5], $aMPos_old[4], $tRECT = _WinAPI_CreateRect(0, 0, 0, 0) Do If $bManual Then $aMPos[2] = 1 Else GUISetCursor(16, 1, $hGUI_Screencapture) $aMPos = GUIGetCursorInfo($hGUI_Screencapture) $aMPos_old[0] = $aMPos[0] $aMPos_old[1] = $aMPos[1] $aMPos_old[2] = MouseGetPos(0) $aMPos_old[3] = MouseGetPos(1) EndIf Switch $aMPos[2] Case 0 ;display crosshair _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) _WinAPI_DrawLine($hGfxDC, $tDest.x, $aMPos[1], $iW, $aMPos[1]) _WinAPI_DrawLine($hGfxDC, $aMPos[0], $tDest.y, $aMPos[0], $iH) _WinAPI_UpdateLayeredWindow($hGUI_Screencapture, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $ULW_COLORKEY) Case 1 ;capture selected region If Not $bManual Then $tBlend.Alpha = $iAlpha2 While $aMPos[2] ;mark region GUISetCursor(14, 1, $hGUI_Screencapture) ;WinGetHandle(AutoItWinGetTitle())) $aMPos = GUIGetCursorInfo($hGUI_Screencapture) _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) ;clear bitmap ;draw rectangle $tRECT.Left = $aMPos_old[0] $tRECT.Top = $aMPos_old[1] $tRECT.Right = $aMPos[0] $tRECT.Bottom = $aMPos[1] _WinAPI_Rectangle($hGfxDC, $tRECT) If $iFillMode <> 2 Then _WinAPI_InvertRect($hGfxDC, $tRECT) _WinAPI_UpdateLayeredWindow($hGUI_Screencapture, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $iFlag) Sleep(10) WEnd _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_Screencapture, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hGfxDC, $hBrush_Orig) _WinAPI_DeleteObject($hBrush) GUIDelete($hGUI_Screencapture) ;capture region $aMPos[0] = MouseGetPos(0) $aMPos[1] = MouseGetPos(1) Else $aMPos_old[2] = $iX1 $aMPos_old[3] = $iY1 $aMPos[0] = $iX2 $aMPos[1] = $iY2 EndIf Local Const $hDC_Region = _WinAPI_GetDC(0) Local Const $hMemDC = _WinAPI_CreateCompatibleDC($hDC_Region) Local Const $iW_Region = Abs($aMPos[0] - $aMPos_old[2]) + 1, $iH_Region = Abs($aMPos[1] - $aMPos_old[3]) + 1 Local $hHBitmap_Captured = _WinAPI_CreateCompatibleBitmap($hDC_Region, $iW_Region, $iH_Region) $hObjOld = _WinAPI_SelectObject($hMemDC, $hHBitmap_Captured) _WinAPI_BitBlt($hMemDC, 0, 0, $iW_Region, $iH_Region, $hDC_Region, _ $aMPos[0] > $aMPos_old[2] ? $aMPos_old[2] : $aMPos[0], _ $aMPos[1] > $aMPos_old[3] ? $aMPos_old[3] : $aMPos[1], BitOR($SRCCOPY, $CAPTUREBLT)) Local $hHBitmap_Clipboard = _WinAPI_CopyImage($hHBitmap_Captured, 0, 0, 0, BitOR($LR_COPYDELETEORG, $LR_COPYRETURNORG)) _WinAPI_SelectObject($hHBitmap_Captured, $hObjOld) _WinAPI_DeleteDC($hHBitmap_Captured) _WinAPI_ReleaseDC(0, $hDC_Region) AutoItSetOption("MouseCoordMode", $iOld) If $bClipboard Then ;put captured region to clipboard If Not _ClipBoard_Open(0) Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(1, 0, 0) EndIf If Not _ClipBoard_Empty() Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(2, 0, 0) EndIf Local Const $hCP = _ClipBoard_SetDataEx($hHBitmap_Clipboard, $CF_BITMAP) If Not $hCP Or @error Then _WinAPI_DeleteObject($hHBitmap_Clipboard) Return SetError(3, 0, 0) EndIf _ClipBoard_Close() _WinAPI_DeleteObject($hHBitmap_Clipboard) Return 1 Else Return $hHBitmap_Clipboard EndIf EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_Screencapture, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) GUIDelete($hGUI_Screencapture) AutoItSetOption("MouseCoordMode", $iOld) Return -1 EndSwitch Until False EndFunc ;==>_WinAPI_MarkScreenRegionAndCapture Might be useful...
       
      Download:  _WinAPI_MarkScreenRegionAndCapture.au3  (same as above in the code box)
       
      Tested only on Win10 x64 but should work also on other Window versions. If not please reply.