Paint (XP) - Text einfügen (Skript)

  • Hallo,
    ich hab ein Skript gebaut, womit man in Paint vorhher im z.B. Browser kopierten Text(!) als Bild in Paint eifügen können soll. In Paint kommt aber leider ein viel zu großes nur schwarzes Bild an! Ich hoffe ihr könnt mir helfen, danke:

    Spoiler anzeigen
    [autoit]

    #include <Clipboard.au3>
    #include <Misc.au3>
    #include <GDIPlus.au3>
    #include <Constants.au3>

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

    Opt("WinTitleMatchMode",2)

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

    _GDIPlus_Startup()

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

    While Not _IsPressed("1B");Esc
    If WinActive(WinGetTitle("Paint")) And (_IsPressed("A2") Or _IsPressed("A3")) And _IsPressed("56") Then ;Strg+V
    $clip=ClipGet()
    $hwnd=WinGetHandle(WinGetTitle("Paint"))
    If $clip<>"" Then
    $hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
    $hFormat = _GDIPlus_StringFormatCreate()
    $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    $hFont = _GDIPlus_FontCreate($hFamily, 10);Size=10
    $chan=ControlGetHandle($hwnd,"","[CLASS:Afx:1000000:8; INSTANCE:1]")
    $sz=WinGetClientSize($chan)
    $tLayout = _GDIPlus_RectFCreate(0, 0, $sz[0], $sz[1])
    $hGraphic = _GDIPlus_GraphicsCreateFromHWND ($chan)
    $hbmp=_GDIPlus_BitmapCreateFromGraphics($sz[0],$sz[1],$hGraphic)
    _GDIPlus_GraphicsDispose($hGraphic)
    $hGraphic=_GDIPlus_ImageGetGraphicsContext($hbmp)
    _GDIPlus_GraphicsClear($hGraphic,0)
    $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, $clip, $hFont, $tLayout, $hFormat)
    _GDIPlus_GraphicsDrawStringEx($hGraphic, $clip, $hFont, $aInfo[0], $hFormat, $hBrush)
    _GDIPlus_GraphicsDispose($hGraphic)
    _ClipBoard_Open(0)
    $hClipboard_Bitmap = _WinAPI_CopyImage( _GDIPlus_BitmapCreateHBITMAPFromBitmap($hbmp), 0, 0, 0, $LR_COPYDELETEORG + $LR_COPYRETURNORG)
    _ClipBoard_SetDataEx($hClipboard_Bitmap,2);Bild(CF_BITMAP)
    _ClipBoard_Close()
    ControlSend($hwnd,"",$chan,"^v")
    _GDIPlus_BitmapDispose($hbmp)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    _GDIPlus_BrushDispose($hBrush)
    EndIf
    EndIf
    Sleep(10)
    WEnd

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

    _GDIPlus_Shutdown()

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

    Func _WinAPI_CopyImage($hImage, $iType = 0, $xDesired = 0, $yDesired = 0, $iFlags = 0); from _WinAPIEx by Yashied
    Local $Ret = DllCall('user32.dll', 'ptr', 'CopyImage', 'ptr', $hImage, 'int', $iType, 'int', $xDesired, 'int', $yDesired, 'int', $iFlags)
    If (@error) Or (Not $Ret[0]) Then
    Return SetError(1, 0, 0)
    EndIf
    Return $Ret[0]
    EndFunc ;==>_WinAPI_CopyImage

    [/autoit]

    EDIT: Funktioniert doch, war nur beides schwarz, nur die Größe stimmt noch nicht, aber da weiß ich was der grund ist

    2 Mal editiert, zuletzt von TheShadowAE (12. März 2011 um 23:06)