Sign in to follow this  
Followers 0
Skitty

Gravitational lensing effect on image?

8 posts in this topic

#1 ·  Posted (edited)

So I've been playing with some code I've got, most of which was ripped from UEZ and created some miscellaneous useless scripts and suddenly I felt compelled to find a way to add en effect to an image that would make it look like if there is a black hole in your desktop.

I've searched and searched to no avail and now I'm here. Anyone know how to add an effect to an image as picture related?

Posted Image

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#Include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

HotKeySet("{ESC}","close")

Global $Img = @ScriptDir&"test.png"
Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Init()
Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1,$WS_POPUP,-1,GUICreate("ghost"));$WS_EX_TOPMOST
GUICtrlCreatePic("",0,0,400,400,-1,0x00100000); only for enable dragging of the gui
GUISetBkColor(0x000000,$hwnd)
_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
GUISetState()
Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos
Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
setTrans($hwnd)
Do
  $Pos = WinGetPos($hwnd)
  If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
   GUISetState(@SW_HIDE)
   _GDIPlus_BitmapDispose($image)
   Sleep(100)
   _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser..
   $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
   $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
   $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
   $image = _GDIPlus_ImageLoadFromFile($Img)
   $matrix = _GDIPlus_MatrixCreate()
   _GDIPlus_MatrixTranslate($matrix, 150, 150);True)
   GUISetState(@SW_SHOW)
   $Pos = WinGetPos($hwnd)
   $TmpPos = $Pos
  EndIf
  ;_GDIPlus_MatrixRotate($matrix, 0.01)
  _GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
  _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
  _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
  Sleep(20)
Until 0

Return
EndFunc
Func close()
    Exit
EndFunc  ;==>close
Func setTrans($hW)
Local $x, $Startx, $Endx
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)

    For $y = 0 To 300
        $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
        $Startx = 150 + $x
        $Endx = 300
        addRegion($Startx, $y, $Endx, $y)
        $Startx = 0
        $Endx = 150 - $x
        addRegion($Startx, $y, $Endx, $y)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc  ;==>setTrans
Func addRegion($a, $b, $c, $d)
    Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc  ;==>addRegion

Edit: forgot to explain the script, the script basically takes a snapshot of the background area of where the gui is going to appear and then loads the image to the gui, which is a big circle really, I want to find a way of making the picture look a little warped before adding it to the gui so it will have a black hole effect or something.

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You could use ImageMagick...

$img = ObjCreate("ImageMagickObject.MagickImage.1")
$img.Convert("test.jpg","-implode","-1","out.jpg")

Posted Image

Edited by Werty

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You could use ImageMagick...

$img = ObjCreate("ImageMagickObject.MagickImage.1")
$img.Convert("test.jpg","-implode","-1","out.jpg")

haha, awesome! Thanks, this is actually a little cool, now I'm gonna see what I can do with this.

#NoTrayIcon
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
HotKeySet("{ESC}","close")
Global $Img = @ScriptDir&"test.png"
Global $ImgMgc = ObjCreate("ImageMagickObject.MagickImage.1")
Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Init()
Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1,$WS_POPUP,$WS_EX_TOPMOST,GUICreate("ghost"));
GUICtrlCreatePic("",0,0,400,400,-1,0x00100000); only for enable dragging of the gui
GUISetBkColor(0x000000,$hwnd)
_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
If IsObj($ImgMgc) Then
  $ImgMgc.Convert($Img,"-implode","-1",$Img)
EndIf
GUISetState()
Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos
Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
setTrans($hwnd)
Do
  $Pos = WinGetPos($hwnd)
  If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
   GUISetState(@SW_HIDE)
   _GDIPlus_BitmapDispose($image)
   Sleep(100)
   _ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser..
   If IsObj($ImgMgc) Then
    $ImgMgc.Convert($Img,"-implode","-1",$Img)
   EndIf
   $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
   $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
   $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
   $image = _GDIPlus_ImageLoadFromFile($Img)
   $matrix = _GDIPlus_MatrixCreate()
   _GDIPlus_MatrixTranslate($matrix, 150, 150);True)
   GUISetState(@SW_SHOW)
   $Pos = WinGetPos($hwnd)
   $TmpPos = $Pos
  EndIf
  ;_GDIPlus_MatrixRotate($matrix, 0.01)
  _GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
  _GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
  _GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
  Sleep(20)
Until 0

Return
EndFunc

Func close()
    Exit
EndFunc  ;==>close
Func setTrans($hW)
Local $x, $Startx, $Endx
    $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)

    For $y = 0 To 300
        $x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
        $Startx = 150 + $x
        $Endx = 300
        addRegion($Startx, $y, $Endx, $y)
        $Startx = 0
        $Endx = 150 - $x
        addRegion($Startx, $y, $Endx, $y)
    Next
    DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc  ;==>setTrans
Func addRegion($a, $b, $c, $d)
    Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
    DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc  ;==>addRegion

Posted Image

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this:

Lens Effect:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <gdiplus.au3>
#include <guiconstantsex.au3>
#include <screencapture.au3>
#include <windowsconstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.70

Global $hBmp = _ScreenCapture_Capture("", -$iSize , -$iSize, $iWidth + $iSize, $iHeight + $iSize, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lens Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
;~ DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hGfxBuffer, "int", 7)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(30)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0] + $iSize, $aPos[1] + $iSize , $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[3]
EndFunc   ;==>_GDIPlus_TextureCreate

Func _GDIPlus_MatrixSetElements($hMatrix, $nM11, $nM12, $nM21, $nM22, $nDX, $nDY)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_MatrixSetElements

Lens Effect with Black Dot:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <gdip.au3>
#include <guiconstantsex.au3>
#include <screencapture.au3>
#include <windowsconstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.6666

Global $hBmp = _ScreenCapture_Capture("", -$iSize , -$iSize, $iWidth + $iSize, $iHeight + $iSize, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lens Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)


Global $hBrush = _CreateBrush()

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(50)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0] + $iSize, $aPos[1] + $iSize , $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)

    _GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush)

    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _CreateBrush()
    Local $fTmp = $iSize * 0.7
    Local $hPath = _GDIPlus_PathCreate()
    _GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2)

    Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
    _GDIPlus_PathBrushSetCenterColor($hBrush, 0xFFF7F7F7)
    Local $aColor[2] = [1, 0x00111111]
    _GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor)
    _GDIPlus_PathBrushSetFocusScales($hBrush, 0.25, 0.25)
    _GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
    _GDIPlus_PathDispose($hPath)

    Return $hBrush
EndFunc   ;==>_CreateBrush

It is a modification of eukalyptus' Black Hole example.

Br,

UEZ

Edit: add code to display also border instead of black ellipse

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

Try this:

;original code by eukalyptus (Black Hole) - modified by UEZ
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "_Exit")

Opt("GUIOnEventMode", 1)
Opt("MouseCoordMode", 2)

_GDIPlus_Startup()

Global $iWidth = @DesktopWidth
Global $iHeight = @DesktopHeight

Global $iSize = 150
Global $fArea = 0.70

Global $hBmp = _ScreenCapture_Capture("", 0, 0, $iWidth - 1, $iHeight - 1, False)
Global $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
_WinAPI_DeleteObject($hBmp)

Global $hGui = GUICreate("Lense Effect", $iWidth, $iHeight, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0xABCDEF)
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
GUISetState()
_WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)

Global $hGraphics = _GDIPlus_GraphicsCreateFromHWND($hGui)
Global $hBmpBuffer = _GDIPlus_BitmapCreateFromGraphics($iWidth, $iHeight, $hGraphics)
Global $hGfxBuffer = _GDIPlus_ImageGetGraphicsContext($hBmpBuffer)
_GDIPlus_GraphicsSetSmoothingMode($hGfxBuffer, 2)
_GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)

GUIRegisterMsg($WM_PAINT, "WM_PAINT")
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")

;~ _WinAPI_ShowCursor(False)

Global $iOMPosX, $iOMPosY, $aMPos

While 1
    $aMPos = MouseGetPos()
    If $aMPos[0] <> $iOMPosX Or $aMPos[1] <> $iOMPosY Then
         _Draw()
         $iOMPosX = $aMPos[0]
         $iOMPosY = $aMPos[1]
    EndIf
    Sleep(50)
WEnd

Func _Draw()
    Local $aPos = MouseGetPos()
    $aPos[0] -= $iSize / 2
    $aPos[1] -= $iSize / 2
    _GDIPlus_GraphicsClear($hGfxBuffer, 0xFFABCDEF)
    Local $hBitmap = _GDIPlus_BitmapCloneArea($hBGBitmap, $aPos[0], $aPos[1], $iSize, $iSize)

    Local $hTexture = _GDIPlus_TextureCreate($hBitmap)
    _GDIPlus_BitmapDispose($hBitmap)

    $hBitmap = _GDIPlus_BitmapCreateFromGraphics($iSize, $iSize, $hGraphics)
    Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap)

    Local $fScale = 1
    Local $hMatrix = _GDIPlus_MatrixCreate()

    _GDIPlus_GraphicsFillEllipse($hContext, 0, 0, $iSize, $iSize, $hTexture)
    _GDIPlus_GraphicsSetSmoothingMode($hContext, 2)

    Local $fTmp = 0
    For $i = 2 To Floor($iSize / 3.333)
        $fTmp = $i * ($iSize * $fArea) / ($iSize / 2)
        $fScale = (($iSize - $fTmp) / ($iSize - $i * 2))

        _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
        _GDIPlus_MatrixTranslate($hMatrix, $iSize / 2, $iSize / 2)
        _GDIPlus_MatrixScale($hMatrix, $fScale, $fScale)
        _GDIPlus_MatrixTranslate($hMatrix, -$iSize / 2, -$iSize / 2)
        _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
        _GDIPlus_GraphicsFillEllipse($hContext, $i, $i, $iSize - $i * 2, $iSize - $i * 2, $hTexture)
    Next

    _GDIPlus_MatrixSetElements($hMatrix, 1, 0, 0, 1, 0, 0)
    _GDIPlus_GraphicsSetTransform($hContext, $hMatrix)
    _GDIPlus_MatrixDispose($hMatrix)
    _GDIPlus_BrushDispose($hTexture)

    _GDIPlus_GraphicsDrawImage($hGfxBuffer, $hBitmap, $aPos[0] - 1, $aPos[1] + 1)

    _GDIPlus_GraphicsDispose($hContext)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
EndFunc   ;==>_Draw

Func WM_PAINT($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_PAINT

Func WM_ERASEBKGND($hWnd, $uMsgm, $wParam, $lParam)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmpBuffer, 0, 0)
    Return True
EndFunc   ;==>WM_ERASEBKGND

Func _Exit()
    _WinAPI_ShowCursor(True)
    _GDIPlus_GraphicsDispose($hGfxBuffer)
    _GDIPlus_BitmapDispose($hBmpBuffer)
    _GDIPlus_BitmapDispose($hBGBitmap)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    Exit
EndFunc   ;==>_Exit

Func _GDIPlus_TextureCreate($hImage, $iWrapMode = 0)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateTexture", "ptr", $hImage, "int", $iWrapMode, "int*", 0)
    If @error Then Return SetError(@error, @extended, 0)
    Return $aResult[3]
EndFunc   ;==>_GDIPlus_TextureCreate

Func _GDIPlus_MatrixSetElements($hMatrix, $nM11, $nM12, $nM21, $nM22, $nDX, $nDY)
    Local $aResult = DllCall($ghGDIPDll, "uint", "GdipSetMatrixElements", "hwnd", $hMatrix, "float", $nM11, "float", $nM12, "float", $nM21, "float", $nM22, "float", $nDX, "float", $nDY)
    If @error Then Return SetError(@error, @extended, False)
    Return $aResult[0] = 0
EndFunc   ;==>_GDIPlus_MatrixSetElements

It is a modification of eukalyptus' Black Hole example.

Br,

UEZ

That's pretty cool and saved, thanks.

Also, I wanted to ask you but didn't want to PM you, so now that you're here, I wanted to know if you could help me out by adding a little dot to the center of the image created by the script so that no matter where I move it, there would always be a black circle making it look a little more authentic, I've been trying to get some code that will change the pixel color at the very center to a black color so that it will always look like the image I posted above, if it's not asking to much.

Thanks for the examples, I find most of your GDI stuff pretty entertaining!


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

Have a look above (post #4).

Is this what you want?

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

Have a look above (post #4).

Is this what you want?

Br,

UEZ

wow, I really appreciate that, that's what I was after, now I'm off to implement this on the original script I posted, thanks for the help UEZ! :)


Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Have a look above (post #4).

Is this what you want?

Br,

UEZ

Ok, so I got back from some stuff and went back to this, and after about 3 hours... I finally got it to work, this is exactly the effect I was looking for!

#NoTrayIcon
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%%scriptfile%_Obfuscated.au3"
#AutoIt3Wrapper_Run_Obfuscator=y
#Obfuscator_Parameters=/so
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#Obfuscator_Ignore_Funcs=WM_DROPFILES_FUNC
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ScreenCapture.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include "GDIp.au3"

HotKeySet("{ESC}", "close")

Global $Img = @DesktopDir & "test.png"
Global $ImgMgc = ObjCreate("ImageMagickObject.MagickImage.1")

If Not IsObj($ImgMgc) Then
Exit MsgBox(16, "Error", "You need to install the ImageMagic COM object.")
EndIf

Global $aM_Mask, $GUI, $hwnd
Global $IMAGE_BITMAP = 0
Global $STM_SETIMAGE = 0x0172
Global $gaDropFiles[1]

Init()

Func Init()
_GDIPlus_Startup()
Local $hwnd = GUICreate("Test", 300, 300, -1, -1, $WS_POPUP, -1, GUICreate("ghost"));$WS_EX_TOPMOST
Local $Pic = GUICtrlCreatePic("", 0, 0, 400, 400, -1, $GUI_WS_EX_PARENTDRAG); only for enable dragging of the gui
GUISetBkColor(0x000000, $hwnd)
;_ScreenCapture_CaptureWnd($Img,$hwnd);leaving the courser...
CreateImg($hwnd, $Img, 0.50)

If IsObj($ImgMgc) Then
$ImgMgc.Convert($Img, "-implode", "-15", $Img)
EndIf

GUISetState()

Local $graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
Local $bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
Local $backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)

Local $Pos = WinGetPos($hwnd)
Local $TmpPos = $Pos

Local $image = _GDIPlus_ImageLoadFromFile($Img)
Local $matrix = _GDIPlus_MatrixCreate()

_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
;_GDIPlus_MatrixRotate($matrix, 0.01)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)

setTrans($hwnd)

Local $Msg, $SEC = @SEC
While 1
Sleep(20)
$Msg = GUIGetMsg($hwnd)
Switch $Msg
Case $Pic
$Pos = WinGetPos($hwnd)
If ($Pos[0] <> $TmpPos[0]) Or ($Pos[1] <> $TmpPos[1]) Then
GUISetState(@SW_HIDE)
_GDIPlus_BitmapDispose($image)
Sleep(100)
CreateImg($hwnd, $Img, 0.50)

If IsObj($ImgMgc) Then
$ImgMgc.Convert($Img, "-implode", "-18", $Img)
EndIf

$graphics = _GDIPlus_GraphicsCreateFromHWND($hwnd)
$bitmap = _GDIPlus_BitmapCreateFromGraphics(300, 300, $graphics)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($bitmap)
$image = _GDIPlus_ImageLoadFromFile($Img)
$matrix = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix, 150, 150);True)
GUISetState(@SW_SHOW)
$Pos = WinGetPos($hwnd)
$TmpPos = $Pos
EndIf

;_GDIPlus_MatrixRotate($matrix, 0.01)
_GDIPlus_GraphicsSetTransform($backbuffer, $matrix)
_GDIPlus_GraphicsDrawImageRect($backbuffer, $image, -150, -150, 300, 300);-150,-150)
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
EndSwitch
If @SEC <> $SEC Then
_GDIPlus_GraphicsDrawImageRect($graphics, $bitmap, 0, 0, 300, 300)
$SEC = @SEC
EndIf
WEnd
Return
EndFunc   ;==>Init

Func CreateImg($hGui, $ImgPath, $fArea)
If Not IsHWnd($hGui) Then
Exit MsgBox(0, "", "error")
EndIf
Local $iWidth = 300
Local $iHeight = 300
Local $iSize = 300

Local $hBmp = _ScreenCapture_CaptureWnd("", $hGui, 0, 0, $iWidth, $iHeight, False)
Local $hBGBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBmp)
Local $hBrush = _CreateBrush($iSize, $fArea)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($hBGBitmap)
_GDIPlus_GraphicsFillRect($hContext, 0, 0, $iSize, $iSize, $hBrush)

_GDIPlus_ImageSaveToFile($hBGBitmap, $ImgPath)

_WinAPI_DeleteObject($hBmp)
_GDIPlus_BitmapDispose($hBGBitmap)
_GDIPlus_GraphicsDispose($hContext)
_GDIPlus_BitmapDispose($hBGBitmap)

Return $ImgPath
EndFunc   ;==>CreateImg

Func _CreateBrush($iSize, $fArea)
Local $fTmp = $iSize * $fArea * 1.20
Local $hPath = _GDIPlus_PathCreate()
;_GDIPlus_PathAddEllipse($hPath, $fTmp, $fTmp, $iSize - $fTmp * 2, $iSize - $fTmp * 2)
_GDIPlus_PathAddEllipse($hPath, $fTmp - 25, $fTmp - 25, -10, -10)

Local $hBrush = _GDIPlus_PathBrushCreateFromPath($hPath)
_GDIPlus_PathBrushSetCenterColor($hBrush, 0xFF000000)
Local $aColor[2] = [1, 0x00000000]
_GDIPlus_PathBrushSetSurroundColorsWithCount($hBrush, $aColor)
_GDIPlus_PathBrushSetFocusScales($hBrush, 0.5, 0.5)
_GDIPlus_PathBrushSetGammaCorrection($hBrush, True)
_GDIPlus_PathDispose($hPath)

Return $hBrush
EndFunc   ;==>_CreateBrush

Func close()
_GDIPlus_Shutdown()
Exit
EndFunc   ;==>close


Func setTrans($hW)
Local $x, $Startx, $Endx
$aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460)


For $y = 0 To 300
$x = Abs((150 * 150 - (150 - $y) * (150 - $y)) ^ 0.5)
$Startx = 150 + $x
$Endx = 300
addRegion($Startx, $y, $Endx, $y)
$Startx = 0
$Endx = 150 - $x
addRegion($Startx, $y, $Endx, $y)
Next

DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $hW, "long", $aM_Mask[0], "int", 1)
EndFunc   ;==>setTrans

Func addRegion($a, $b, $c, $d)
Local $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $a, "long", $b, "long", $c + 1, "long", $d + 1)
DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3)
EndFunc   ;==>addRegion

Also, I wonder why the tab spaces always disappear when I post code...

Edited by THAT1ANONYMOUSEDUDE

Things that I've done..

Icon Resource Editor: icon resource editor 

AutoIt Piano: a piano

AutoIt Unlocker: unlocks files when you want to delete them

Colorful tooltips: a wrapper for the tool tips UDF

Rouge GoogleBot: a full screen animation

ASciTE text editor: a text editor written in autoit

Warning: Posts by this user are subject to change or may disappear without notice.

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

    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • DeathChicken
      By DeathChicken
      If possible please add or edit the comments to explain how this works.
       
      ;includes functions from other things
      #include <GDIPlus.au3>
      #include <ScreenCapture.au3>
      ;hotkeys
      HotKeySet("{ESC}", _exit)
      HotKeySet("{F1}", _scan)
      ;global variables
      Global $win_title                    ;name of the window
      Global $area_x                        ;
      Global $area_y                        ;
      Global $area_w                       ;
      Global $area_h                        ;
      Global $cursor                         ;
      Global $rect_file                      ;
      Global $hbmpscreen              ;
      Global $i=  1043                      ;moves the rect
      Global $ii=    378                      ;moves the rect
      Global $x=1044                        ;inner rect offset
      Global $y=501                          ;inner rect offset
      Global $hbmprect                    ;image inside rect
      Global $hscreen                        ;image whole screen
                                         
      _GDIPlus_Startup()                    ;?
      ;display hotkeys on screen
      ToolTip("Press F1 to scan | Press ESC to Exit",0,0)
                                          ;infinite loop to keep prog running
      While 1
          Sleep(100)
      WEnd
      Func _scan()
      ;~ reads your screen area:
      _read()
      ;~ converts screen captured into bmp
      _convert()
      ;~ .  Loads converted bmp to be read
      _loadBMP()
      ;~ compares the bmp of your scanned screen to the actual screen that is being displayed
      _compare()
      EndFunc
                                          ;reads screen
      Func _read()
          $hscreen = _ScreenCapture_CaptureWnd("", WinGetHandle($win_title), $area_x, $area_y, $area_x + $area_w, $area_y + $area_h, $cursor)
      EndFunc
                                          ;converts screen into bmp
      Func _convert()
          _GDIPlus_BitmapCreateFromHBITMAP($hscreen)
      EndFunc
                                          ;loads converted screen
      Func _loadBMP()
      _GDIPlus_BitmapCreateFromFile($rect_file)
      EndFunc
                                          ;compares savedBMP to current screen
      Func _compare()
      ;If(                              below code                                     ) = (                   below code           ) Then
      If _GDIPlus_BitmapGetPixel($hbmpscreen, ($i + $x) - $area_x, ($ii + $y) - $area_y) = _GDIPlus_BitmapGetPixel($hbmprect, $x, $y) Then
      ;display message box titled found with a message of found
      MsgBox("","","found")
      ;if above is not correct then
      EndIf
      EndFunc
                                          ;exit func
      Func _exit()
          Exit
      EndFunc
    • GordonFreeman
      By GordonFreeman
      Hi, i searched some topics but cannot found a simple way to do that:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) ; I tried this but user reported that it work in 2006, not seems work actually $filemenu = GUICtrlCreateMenu ("&File") $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu) GuiCtrlSetImage($fileitem, "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Also tried:
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) GUISetState(@SW_SHOW) $filemenu = TrayCreateMenu("&File") $fileitem = TrayCreateItem("Open",$filemenu) ;GuiCtrlSetImage($fileitem, "shell32.dll", 4) ;GuiCtrlSetImage(TrayItemGetHandle($fileitem), "shell32.dll", 4) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Well.. thanks in advance!
       
      Ok. I found this working example from Yashied. If i cannot find a simple then i will go with it
      #Include <GUIConstantsEx.au3> #Include <GUIMenu.au3> #Include <Constants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $hMenu, $hForm, $hFile = 1000, $idNew, $idExit $hForm = GUICreate('Menu', 400, 300) $hFile = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem ($hFile, 0, ' &Favorites', $idNew) _GUICtrlMenu_InsertMenuItem ($hFile, 1, '', 0) _GUICtrlMenu_InsertMenuItem($hFile, 2, ' E&xit', $idExit) $hMenu = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMenu, 0, '&File', 0, $hFile) _GUICtrlMenu_SetMenu($hForm, $hMenu) _GUICtrlMenu_SetItemBmp($hFile, 0, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 43, 16, 16)) _GUICtrlMenu_SetItemBmp($hFile, 2, _CreateBitmapFromIcon(_WinAPI_GetSysColor($COLOR_MENU), @SystemDir & '\shell32.dll', 27, 16, 16)) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _CreateBitmapFromIcon($iBackground, $sIcon, $iIndex, $iWidth, $iHeight) Local $hDC, $hBackDC, $hBackSv, $hIcon, $hBitmap $hDC = _WinAPI_GetDC(0) $hBackDC = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateSolidBitmap(0, $iBackground, $iWidth, $iHeight) $hBackSv = _WinAPI_SelectObject($hBackDC, $hBitmap) $hIcon = _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) If Not @error Then _WinAPI_DrawIconEx($hBackDC, 0, 0, $hIcon, 0, 0, 0, 0, $DI_NORMAL) _WinAPI_DestroyIcon($hIcon) EndIf _WinAPI_SelectObject($hBackDC, $hBackSv) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hBackDC) Return $hBitmap EndFunc ;==>_CreateBitmapFromIcon Func _WinAPI_PrivateExtractIcon($sIcon, $iIndex, $iWidth, $iHeight) Local $hIcon, $tIcon = DllStructCreate('hwnd'), $tID = DllStructCreate('hwnd') Local $Ret = DllCall('user32.dll', 'int', 'PrivateExtractIcons', 'str', $sIcon, 'int', $iIndex, 'int', $iWidth, 'int', $iHeight, 'ptr', DllStructGetPtr($tIcon), 'ptr', DllStructGetPtr($tID), 'int', 1, 'int', 0) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf $hIcon = DllStructGetData($tIcon, 1) If ($hIcon = Ptr(0)) Or (Not IsPtr($hIcon)) Then Return SetError(1, 0, 0) EndIf Return $hIcon EndFunc ;==>_WinAPI_PrivateExtractIcon Ok, i noticed that is a pain create submenu with _GUICtrlMenu_CreatePopup to do like in Tray, and Tray better located, then i need images/icon with Tray functions, some workaround?? 
    • SimTheNo1
      By SimTheNo1
      I am busy with building a solution for change monitoring of VOIP call program and to be properly automated means among others need for some limited OCR functionality. Current works of others are way too much overkill for this case what makes the need to build it myself. But to do it properly I significantly have to increase my knowledge about digital graphics management.
      For now I already have discovered here and there some mind blowing  Autoit miracles what can be achieved with Windows own possibilities to manipulate that what is output to the monitor. And as far I can judge there are 2 options to process graphics without use of any external libraries like ImageMagick, FreeImage and so on. These are:
       WinAPI  GDIPlus It is for me quite obvious to have various holes in general understanding of graphics and it is once more very clear what advantages gives consistent general study in 1 or another official institutions like University.  Cause there you are introduced into certain domain of knowledge in a way which usually has been perfected over long period of time. So you are not overloaded by stuff which requires a certain amount of information to be initially clear for you. For example, before starting to solve physics you first learn to read, count and so on and then move to subjects like physics.
      Though in my case opportunity to study in such educational system I had only for 8 years, from my 7th to 15th year of age in the country that was falling apart now Ukraine but used to be USSR, was all what it was. After have immigrated to Netherlands possibilities to study further haven't occur. And this therefor causes often various implications when going deep in that or another field of practical knowledge acquiring for any needed physical result, like programming to perform enormous amount of tasks. In this particular case automating VOIP call program.
      Anyway, right now I think the best direction to move is to concentrate on as basic as possible image management and if someone would maybe explain in general what is a pixel will definitely help. Particularly I am very curious about how to do picture manipulations in Autoit. Especially would help a lot to produce eventually following functions:
      createImage($imageFileName, $width, $height, $color) readImagePixel($imageFileName, $x, $y)  writeImagePixel($imageFileName, $x, $y) I do not know exactly how image is handled in computer but preferably above mentioned functions should deal with so far possible origin of graphics creation on computer. But nevertheless I definitely would love to hear any proposition for solution.
      The problem with explaining screenshots:
       VOIPConnect full Window  Part of Window with control to monitor for changes  Exact location of area where actual changes occur and have to be processed  It comes down to a rectangle of approximately 51 pixel wide and 7 pixel high. In fact if I get to learn as far as to be able exactly read, write and compare 2 images consistently across different computers I could narrow down then even further the area to watch as little as a square of 2-5 pixels wide. 
      To finish here is last detail about particularly no need for ultra fast solution at all. This because it is needed only once when it is first run on a new computer and to have to wait few minutes while it is being set instead of just a few seconds make no sence.
      This is it and what I too think to do beside this very particular case is to purify out beautiful generic Autoit functions for core image manipulation by using WinAPI or/and GDIPlus. 
    • Ian_Mac
      By Ian_Mac
      Func dg_get_images() $x1=0 $y1=0 ;MsgBox(0,"start","start") do $result = _ImageSearch("C:\Users\Server\Desktop\my project\image.png",1,$x1,$y1,0) until $result = 1; if $result=1 Then MouseMove($x1,$y1,3) MouseClick("left", $x1,$y1, 1) WinWait("[Title:TightVNC File Transfer]", "", 10) EndIf  this code works when i search the image, but when i change the location of the desktop icon it can't find the desktop icon anymore.   i wanna try image search area. but i don't know how to use it because i cant understand the parameter for the image search area.  please help me how to solve it thank you in advance.