Hallo zusammen.
Der Titel könnte etwas unverständlich sein.
Im Prinzip soll das Script den Inhalt eines Fensters per GDI+ speichern und vergrößert/verkleinert in einem anderen Fenster darstellen. Ich tue mich bei GDI+ allerdings noch etwas schwer, jedenfalls wird der Fensterinhalt nicht in meine GUI gezeichnet. Ich hänge mal meinen Code an, vielleicht hat ja jemand ne Idee. Ich gehe zumindest davon aus ;).
Spoiler anzeigen
#include <WindowsConstants.au3>
#Include <GDIPlus.au3>
dim $exe_path="notepad.exe",$exe_windowname="Unbenannt"
consolewrite("waiting for application window"&@CRLF)
if not WinExists($exe_windowname) then
Run($exe_path)
while not WinExists($exe_windowname)
sleep(100)
wend
endif
consolewrite("window found"&@CRLF)
$hwnd=WinGetHandle($exe_windowname)
$gui=GuiCreate("GDI+ Test Parent",320,240,0,0,$WS_SIZEBOX)
GuiSetState(@SW_SHOW,$gui)
$gui_size=WinGetPos($gui)
$app_size=WinGetPos($hwnd)
consolewrite("app size: "&$app_size[2]&"x"&$app_size[3]&@CRLF)
consolewrite("gdi init..."&@CRLF)
if not _GDIPlus_Startup() then consolewrite("couldn' init gdi"&@CRLF)
$g_gui=_GDIPlus_GraphicsCreateFromHWND($gui)
if $g_gui==0 then consolewrite("error 1"&@CRLF)
$g_hwnd=_GDIPlus_GraphicsCreateFromHWND($hwnd)
if $g_hwnd==0 then consolewrite("error 2"&@CRLF)
$b_hwnd=_GDIPlus_BitmapCreateFromGraphics($app_size[2],$app_size[3],$g_hwnd)
if $b_hwnd==0 then
consolewrite("error 3"&@CRLF)
else
consolewrite("image size: "&_GDIPlus_ImageGetWidth($b_hwnd)&"x"&_GDIPlus_ImageGetHeight($b_hwnd)&@CRLF)
endif
if not _GDIPlus_GraphicsDrawImageRectRect($g_gui,$b_hwnd,$app_size[0],$app_size[1],$app_size[2],$app_size[3],0,0,$gui_size[2],$gui_size[3]) then consolewrite("error 4"&@CRLF)
consolewrite("done."&@CRLF&"waiting 3 seconds until script termination..."&@CRLF)
sleep(3000)
ProcessClose(WinGetProcess($hwnd))
consolewrite("clearing gdi+"&@CRLF)
_WinAPI_DeleteObject($b_hwnd)
_GDIPlus_GraphicsDispose($g_hwnd)
_GDIPlus_GraphicsDispose($g_gui)
_GDIPlus_Shutdown()
consolewrite("exiting"&@CRLF)
BTW: Räume ich eigentlich richtig auf am Ende des Codes ?
EDIT: Code zu Spoiler geändert zwecks Übersichtlichkeit.