Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding > Coding Tutorials
You last visited: Today at 06:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[AutoIT] GDI+ auf dem "Bildschirm" malen

Discussion on [AutoIT] GDI+ auf dem "Bildschirm" malen within the Coding Tutorials forum part of the General Coding category.

Reply
 
Old   #1
 
Croco™'s Avatar
 
elite*gold: 235
Join Date: Jan 2012
Posts: 920
Received Thanks: 377
[AutoIT] GDI+ auf dem "Bildschirm" malen

Hi,
ich wollte euch meine Methode zeigen wie man ganz einfach auf den Bildschirm malen kann mit GDI+. Was man dazu braucht ist eine 1x1 Pixel große .gif Datei mit der Farbe 00FF00 (Rot: 0 , Grün: 255, Blau: 0). Diese Datei benutzen wir als "Green Screen" und schneiden sie später aus unserer GUI. ()

Nun zum Code:

1.) GUI erstellen
Es muss nur eine ganz simple GUI mit einem Bild das über die ganze Fläche der GUI geht erstellt werden. Als Flags nehmen wir $WS_POPUP,$WS_EX_TOPMOST und $WS_EX_LAYERED. Hier kommt unsere gif Datei zum Einsatz die wir als Bild benutzen.

Code:
$Form1 = GUICreate("", 10, 10, 192, 124, [COLOR="Green"]$WS_POPUP,BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST)[/COLOR])
$Pic1 = GUICtrlCreatePic("bg.gif", 0, 0, 10, 10)
GUISetState(@SW_SHOW)
2.) Includes
Für das ausschneiden der Grünen Farbe und das Benutzen der GDI+ benötigen wir folgende zwei Includes die wir an den Anfang unseres Scriptes setzen.
Code:
#include <GDIPlus.au3>
#include <WinApi.au3>
3.) Grün ausschneiden
Hierfür stellt uns die WinApi eine Funktion zur Verfügung die als ersten Parameter das Fenster Handle und als zweiten die Farbe fordert.

Code:
_WinAPI_SetLayeredWindowAttributes($Form1, 0x00FF00)
$Form1 = Unser GUI Fenster
0x00FF00 = Die Farbe der gif Datei: Grün

Code:
#include <GDIPlus.au3>
#include <WinApi.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 10, 10, 192, 124, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
$Pic1 = GUICtrlCreatePic("bg.gif", 0, 0, 10, 10)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
4.) Malen
Nun müssen wir nur noch malen
D.h. GDI starten, Graphik initialisieren und unsere gewünschte Form malen.
Code:
_GDIPlus_Startup()
	$Handle = _GDIPlus_GraphicsCreateFromHWND($Form1)
		_GDIPlus_GraphicsDrawRect($Handle,0,0,9,9)

While 1
	Sleep(300)
WEnd

_GDIPlus_Shutdown()
In diesem Fall malen wir ein Rechteck (Rect) auf unser Fenster.
Code:
_GDIPlus_GraphicsDrawRect($Handle,0,0,9,9)
Code:
#include <GDIPlus.au3>
#include <WinApi.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 10, 10, 192, 124, $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_TOPMOST))
$Pic1 = GUICtrlCreatePic("bg.gif", 0, 0, 10, 10)
_WinAPI_SetLayeredWindowAttributes($Form1, 0x00FF00)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_GDIPlus_Startup()
	$Handle = _GDIPlus_GraphicsCreateFromHWND($Form1)
		_GDIPlus_GraphicsDrawRect($Handle,0,0,9,9)

While 1
	Sleep(300)
WEnd

_GDIPlus_Shutdown()
Opt. [5.) Form löschen (übermalen)]
Wollen wir mehrere Sachen malen würde unser Fenster schnell voll werden also löschen wir bevor wir etwas neues kreieren erstmal das alte mit
Code:
_WinAPI_RedrawWindow($Form1)
Dadurch wird unser GUI Fenster "resettet".

Ich danke Achat für sein Tutorial : da es mich auf die Idee gebracht hat.
Croco™ is offline  
Thanks
2 Users
Reply


Similar Threads Similar Threads
Autoit auf den Bildschirm "malen"
12/24/2010 - AutoIt - 5 Replies
Hi ich wollte mal fragen wie es möglich ist mit Autoit auf den Bildschirm zu "malen" Z.b Punkte oder sonstiges markieren und AutoIt "malt" an diese Stelle z.b. einen Punkt oder sonst etwas hin Sollte in überwiegend jedem Programm gehen. Wie Firefox,IE und so Wenn jemand ne Idee hat und sie postet wäre ich sehr dankbar ;)



All times are GMT +1. The time now is 06:01.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.