GDI+ Maus Position

  • Hallo habe folgendes Problem:
    1.) Ich habe eine GDI+ GUI und möchte dass auf der GUI erkannt wird wo die maus ist und dass wenn sie in einem bestimmten bereich ist wie z.B. von x1 = 5 und y1 = 5 bis x2 = 25 bis y2 = 25 dass in diesem bereich eine Aktion ausgeführt wird
    2.) Das ich das Fenster mit einem Hotkey aufrufen will aber wenn ich es dann schließe (programm beende) dass dann immer eine Fehlermeldung kommt.

    Bitte um Hilfe

    [autoit]

    #include <GuiConstants.au3>
    #include <GdiPlus.au3>
    HotKeySet("{F5}","gui")
    HotKeySet("{ESC}","end")

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    func gui()

    [/autoit][autoit][/autoit][autoit]

    $Gui = GUICreate("Beispiel", 500, 630, 100,100)
    $button1 = GUICtrlCreateButton("WinClose",0,600,500,30)
    GUISetState(@SW_SHOW)

    [/autoit][autoit][/autoit][autoit]

    _GDIPlus_Startup()

    [/autoit][autoit][/autoit][autoit]

    $hGraphics = _GDIPlus_GraphicsCreateFromHWND($Gui)
    $hImage = _GDIPlus_ImageLoadFromFile("C:\Users\Pascal\Desktop\Neuer Ordner (2)\Backgrounds\gui_background5.jpg")
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage, 0, 0)

    [/autoit][autoit][/autoit][autoit]

    While 4
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
    Exit
    case $button1
    _GDIPlus_GraphicsDispose($hGraphics)
    EndSwitch

    [/autoit][autoit][/autoit][autoit]

    $pos = MouseGetPos()
    $pix = PixelGetColor($pos[0], $pos[1])
    If $pos[0] = 15 And $pos[1] = 12 Then
    $hImage2 = _GDIPlus_ImageLoadFromFile("C:\Users\Pascal\Desktop\gui_background_label.jpg")
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 11,10)
    _GDIPlus_StringFormatCreate(0x0001,0)
    _GDIPlus_GraphicsDrawString($hGraphics,"TEST", 15,12)
    EndIf

    [/autoit][autoit][/autoit][autoit]

    If Not $pos[0] = 15 And $pos[1] = 12 Then
    $hImage2 = _GDIPlus_ImageLoadFromFile("")
    _GDIPlus_GraphicsDrawImage($hGraphics, $hImage2, 11,10)
    _GDIPlus_StringFormatCreate(0x0001,0)
    _GDIPlus_GraphicsDrawString($hGraphics,"", 15,12)
    EndIf

    [/autoit][autoit][/autoit][autoit]

    WEnd
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    Func end ()
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    EndFunc

    [/autoit][autoit][/autoit][autoit]

    while 1

    WEnd

    [/autoit]