Jump to content

GDIplus funcions help...


Recommended Posts

Hello, i maded this script but its bugged...i don't know why...

Please help to fix this...

Error Screenshot:

Posted Image

Here is script:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Avatar", 128, 158, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Avatar Maker", 15, 10, 98, 18)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$Pic1 = GUICtrlCreatePic("", 10, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetImage($Pic1,@DesktopDir & "\image.jpg")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)

_GDIPlus_Startup()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_ShutDown()
            Exit
        Case $Pic1
        If _IsPressed(01) Then
            Do
            $pos = MouseGetPos()
            $hBitmap = _ScreenCapture_Capture("", $pos[0]-50, $pos[1]-50, $pos[0]+50, $pos[1]+50)
            $hImage    = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
            $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 14, 44)
        Until Not _IsPressed(01)
        MouseMove(@DesktopWidth,@DesktopHeight,0)
        _ScreenCapture_Capture(@DesktopDir & "\image.jpg", $pos[0]-50, $pos[1]-50, $pos[0]+50, $pos[1]+50)
        GUICtrlSetImage($Pic1,@DesktopDir & "\image.jpg")
        MouseMove($pos[0],$pos[1],0)
    EndIf
    EndSwitch
WEnd

[quote name='dbzfanatic' post='609696' date='Nov 26 2008, 08:46 AM']This is a help forum not a "write this for me" forum.[/quote](Sorry for bad English) :)

Link to comment
Share on other sites

First, you have to delete all imjage-objects, which are created, second, there should be a Sleep in the Loop. e.g.:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <Misc.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Avatar", 128, 158, -1, -1, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS))
$Label1 = GUICtrlCreateLabel("Avatar Maker", 15, 10, 98, 18)
GUICtrlSetFont(-1, 10, 800, 0, "Verdana")
$Pic1 = GUICtrlCreatePic("", 10, 40, 100, 100, BitOR($SS_NOTIFY,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS), BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetImage($Pic1,@DesktopDir & "\image.jpg")
GUICtrlSetCursor (-1, 0)
GUISetState(@SW_SHOW)
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GDIPlus_GraphicsDispose($hGraphic)
            _GDIPlus_ShutDown()
            Exit
        Case $Pic1
            ConsoleWrite(".........." & @CRLF)
        If _IsPressed("01") Then
            Do
            $pos = MouseGetPos()
            $hBitmap = _ScreenCapture_Capture("", $pos[0]-50, $pos[1]-50, $pos[0]+50, $pos[1]+50,0)
            $hImage = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap)
            _WinAPI_DeleteObject($hBitmap)
            _GDIPlus_GraphicsDrawImage($hGraphic, $hImage, 14, 44)
            _GDIPlus_BitmapDispose($hImage)
            Sleep(100)
        Until Not _IsPressed("01")
        MouseMove(@DesktopWidth,@DesktopHeight,0)
        MsgBox(0, '', "No capture now")
;~       _ScreenCapture_Capture(@DesktopDir & "\image.jpg", $pos[0]-50, $pos[1]-50, $pos[0]+50, $pos[1]+50)
        GUICtrlSetImage($Pic1,@DesktopDir & "\image.jpg")
        MouseMove($pos[0],$pos[1],0)
    EndIf
    EndSwitch
WEnd

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...