DirectX Hook im Gui (via GDIP(?))

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

DirectX Hook im Gui (via GDIP(?))

04 Mar 2018, 09:37

Hey,

Ich habe mal eine Frage ist es möglich mit dieser API(Directx Hook): https://github.com/agrippa1994/DX9-Overlay-API zb. Strings auf dem Desktop anzeigen zulassen, in einem Gui, evtl dargestellt per GDIP(?)...
Ich bin gerade dabei mit GDIP rumzuprobieren, aber derzeit leider noch erfolglos...
Hat jemand eine Idee, oder sogar Ahnung davon ? :)

Gruß
Renz
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: DirectX Hook im Gui (via GDIP(?))

05 Mar 2018, 03:27

Moin,

soweit ich weiß, ist DirectX eine Alternative zu den Windows GDI/GDI+ Funktionen, die die Grafikausgabe durch direkten Zugriff auf die Grafikhardware beschleunigen kann.
Renz wrote:... zb. Strings auf dem Desktop anzeigen zulassen, in einem Gui, evtl dargestellt per GDIP(?)...
Kannst Du etwas detaillierter beschreiben, was Du tun willst?

Zum Thema GDIP: Für manche Funktionen ist es entscheidend, das zur AHK-Version (32/64 Bit) passende GDIP-Skript zu verwenden. Es gibt mehrere unterschiedliche Skripte. Die ursprüngliche Version von tic ist in Teilen nur für 32-Bit funktionsfähig.
User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

Re: DirectX Hook im Gui (via GDIP(?))

06 Mar 2018, 11:53

Hey, Sry für die späte Antwort...
just me wrote:Kannst Du etwas detaillierter beschreiben, was Du tun willst?
Klar, Ich versuche mir derzeit eine Klasse zuerstellen die mir hilft dabei mit GDIP zuarbeiten für Grafische Overlays auf dem Desktop, statt der "herkömmlichen" Guis/Fenster.
Man kann natürlich auch per HTML/CSS die Guis gestalten, aber das ist "für mich" nicht das richtige^^

Das mit dem Directx Hook von meinem 1. Beitrag ist hinfällig, da ich mich entschieden habe nur mit GDIP zu arbeiten, da es genau das erfüllt was ich suche...

Diesbezüglich hätte ich eine Frage,
Wenn ich mit meiner Klasse eine Box erstelle mit den Koordinaten X=0 Y=0 W=100 H=100 ist alles gut, die Box wird gut angezeigt...
Wenn ich aber die X bzw Y Koordinate erhöhe +10 sind schon genug, verändert sich die ganze Box und die Ränder verziehen und verschwinden...
Kleines Testskript
Hätte jemand dazu evtl eine Idee?
Liegt es an UpdateLayeredWindow() evtl benutze ich es falsch?

Gruß
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: DirectX Hook im Gui (via GDIP(?))

06 Mar 2018, 12:11

Ich hab den Fehler gefunden.
GDIp zeichnet nicht relativ zum Bildschirm sondern relativ zu der Bitmap auf die du gerade Zeichnest.
Wenn du also ein Rechteck bei 0,0 Zeichnen lässt und es dann per UpdateLayeredWindow auf deine GUI legst wird dieses Rechteck in der linken oberen Ecke anfangen.
Du zeichnest jedoch das Rechteck und deinen Rahmen mit einem Offset, sodass sie nicht mehr genau auf deinem GUI liegen.

Es ist zudem Erwähnenswert, dass die Rect Struktur von Windows sehr leicht zu Fehlern führen kann wenn man nicht aufpasst.
Und ich finde es komisch den Rahmen unter die Box zu legen.
Recommends AHK Studio
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: DirectX Hook im Gui (via GDIP(?))

06 Mar 2018, 12:13

Code: Select all

#Persistent
#SingleInstance force
#include <gdip_all>
#NoEnv


global GDITOKEN := GDIP_Startup()
test := new Main.GUICLASS(GDITOKEN)
o := new Main.GDICLASS()
BoxID := o.CreateBox(0,0,500,400,10,0xFFFFFF00)
FilledBoxID := o.FillBox(BoxID,0xAA0000FF)
TextID := o.DrawStringEx("Das ist korrekt, so sollte die Box aussehen! `nKoordinaten: X=0 & Y=0 & W=500 & H=400","Arial",25,0xAA000000,5,5,500,150)
sleep 5000
o.RemoveID(BoxID)
o.RemoveID(FilledBoxID)
o.RemoveID(TextID)

BoxID := o.CreateBox(100,100,500,400,10,0xFFFFFF00)
FilledBoxID := o.FillBox(BoxID,0xAA0000FF)
TextID := o.DrawStringEx("Das ist Falsch, Die Rechte und Untere Seite verschwinden`nKoordinaten: X=50 & Y=25 & W=500 & H=400","Arial",25,0xAA000000,50,25,500,574)
sleep 2500
o.RemoveID(BoxID)
o.RemoveID(FilledBoxID)
o.RemoveID(TextID)


class Main
{
	static _ERROR := False,GDITOKEN,GUICOUNT:=0,STRUCT := Object()
	class GDICLASS
	{	
		static HWND,HDC,HBM,OBM,GRAPH,PEN,BRUSH,_tmpSTRUCTID
		__New(pToken) {
			Main._ERROR := False
			Main.GDITOKEN 	:= pToken
			if(!Main.GDITOKEN){
				_E1 := True
				Main._ERROR := True
			}
			If (Main._ERROR){
				this.setlasterror("Error in __New(" Main.GDITOKEN ") -> GDIP StartUp Failed")
				Return 0
			}
		}
		CreateBox(BoxX,BoxY,BoxW,BoxH,BoxBorderSize:=5,BoxColor:=0xAA000000)
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
			
			g_ID=-1
			Main.GUICOUNT++
			g_ID := Main.GUICOUNT
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "w" BoxW " h" BoxH " y" BoxY " x" BoxX ""
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(BoxW,BoxH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.PEN 			:= Gdip_CreatePen(BoxColor,BoxBorderSize)
			;Msgbox % "`nHDC: " this.HDC "`nHBM: " this.HBM "`nOBM: " this.OBM "`nGRAPH: " this.GRAPH "`nPEN: " this.PEN
			Gdip_SetInterpolationMode(this.GRAPH, 7)
			Gdip_SetSmoothingMode(this.GRAPH, 4)
			Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH)
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0)
				return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, this.PEN,BoxX,BoxY,BoxW,BoxH)
			return 0
		}
		FillBox(_STRUCTID, FillColor:=0xAA000000)
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
			
			g_ID=-1
			Main.GUICOUNT++
			g_ID := Main.GUICOUNT
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "w" Main.STRUCT[ _STRUCTID ][12] " h" Main.STRUCT[ _STRUCTID ][13] " y" Main.STRUCT[ _STRUCTID ][11] " x" Main.STRUCT[ _STRUCTID ][10]
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(Main.STRUCT[ _STRUCTID ][12],Main.STRUCT[ _STRUCTID ][13], this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.BRUSH 			:= Gdip_BrushCreateSolid(FillColor)
			;Msgbox % "`nHDC: " this.HDC "`nHBM: " this.HBM "`nOBM: " this.OBM "`nGRAPH: " this.GRAPH "`nPEN: " this.PEN
			Gdip_SetInterpolationMode(this.GRAPH, 7)
			Gdip_SetSmoothingMode(this.GRAPH, 4)
			Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,Main.STRUCT[ _STRUCTID ][12],Main.STRUCT[ _STRUCTID ][13])
			UpdateLayeredWindow(this.HWND,this.HDC,Main.STRUCT[ _STRUCTID ][10],Main.STRUCT[ _STRUCTID ][11],Main.STRUCT[ _STRUCTID ][12],Main.STRUCT[ _STRUCTID ][13])
			
			return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, this.PEN,Main.STRUCT[ _STRUCTID ][10],Main.STRUCT[ _STRUCTID ][11],Main.STRUCT[ _STRUCTID ][12],Main.STRUCT[ _STRUCTID ][13])
			
		}
		;UpdateDrawedStringEx(pText,pFont,pSize,pColor,pX,pY,pW,pH,pPos)
		DrawStringEx(pText,pFont,pSize,pColor,pX,pY,pW,pH,pPos:="vCenter")
		{
			
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()				
			
			g_ID=-1
			Main.GUICOUNT++
			g_ID := Main.GUICOUNT
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH 
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(pW,pH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			Gdip_SetInterpolationMode(this.GRAPH, 7)
			Gdip_SetSmoothingMode(this.GRAPH, 4)
			Gdip_TextToGraphics(this.GRAPH, pText, "x" pX " y" pY " w" pW " h" pH " c" pColor " s" pSize " " pPos, pFont, pW,pH)
			UpdateLayeredWindow(this.HWND,this.HDC,pX,pY,pW,pH)
			return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, -1,pX,pY,pW,pH)
		}
		;SetString(_STRUCTID,Text_To_Set, Font, Size, Color)
		;UpdateString(_STRUCTID,Text_To_Set, Font, Size, Color)
		ADDStruct(pGraph,phwnd,pHDC,pHBM,pOBM,pgID,pBrush,pPen,_X,_Y,_W,_H)
		{
			this._tmpSTRUCTID := -1
			if(Main.STRUCT.MaxIndex() == ""){
				Main.STRUCT.Push([ 1 , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H ])
				this._tmpSTRUCTID:= 1
				return this._tmpSTRUCTID
			}
			Loop
			{	
				if(Main.STRUCT[ A_Index ][1] == ""){
					Main.STRUCT.Push([ A_Index , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H ])
					this._tmpSTRUCTID:= A_Index
					break
				}
				if(A_Index >= 1000)
					break
			}
			if(this._tmpSTRUCTID != -1)
				return this._tmpSTRUCTID
			else
				return this.setlasterror("Fehler: Keine Freie Strukturen ID gefunden | MaxSize(" Main.STRUCT.MaxIndex() ")")
		}
		RemoveID(pID)
		{
			While(A_Index <= Main.STRUCT.MaxIndex())
			{
				if(Main.STRUCT[ A_Index ][1] == pID)
				{
					if(Main.STRUCT[ A_Index ][7] != -1)
						Gdip_DeleteBrush(Main.STRUCT[ A_Index ][7])
					if(Main.STRUCT[ A_Index ][8] != -1)
						Gdip_DeletePen(Main.STRUCT[ A_Index ][8])
					
					SelectObject(Main.STRUCT[ A_Index ][4], Main.STRUCT[ A_Index ][6])
					DeleteObject(Main.STRUCT[ A_Index ][5])
					DeleteDC(Main.STRUCT[ A_Index ][4])
					Gdip_DeleteGraphics(Main.STRUCT[ A_Index ][2])
					g_ID := Main.STRUCT[ A_Index ][9]
					Gui, %g_ID%: Destroy
					Main.GUICOUNT--
					this.STRUCT.RemoveAt( A_Index )
					_tempID := A_Index
					Main._ERROR := False
					break
				}
			}
			return
		}
		INIT_STRUCT()
		{
			_Max:=Main.STRUCT.MaxIndex()
			if(_Max){
				While(A_Index <= _Max)
					Main.STRUCT.RemoveAt(1)
			}
			Loop 99
				Main.STRUCT.Push([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])
		}
		getlasterror(){
			if(Main._ERROR != False){
				Msgbox % Main._ERROR
				this.setlasterror(False)
			}
			return
		}
		setlasterror(ERRORMSG){
			Main._ERROR := ERRORMSG
			return
		}
	} 
}
Recommends AHK Studio
User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

Re: DirectX Hook im Gui (via GDIP(?))

09 Mar 2018, 00:42

Hey,
nnnik wrote:Ich hab den Fehler gefunden.
GDIp zeichnet nicht relativ zum Bildschirm sondern relativ zu der Bitmap auf die du gerade Zeichnest.
Wenn du also ein Rechteck bei 0,0 Zeichnen lässt und es dann per UpdateLayeredWindow auf deine GUI legst wird dieses Rechteck in der linken oberen Ecke anfangen.
Du zeichnest jedoch das Rechteck und deinen Rahmen mit einem Offset, sodass sie nicht mehr genau auf deinem GUI liegen.
Oh vielen dank, werde mir das nochmal genauer anschauen heute, hab ja frei :D
nnnik wrote: Es ist zudem Erwähnenswert, dass die Rect Struktur von Windows sehr leicht zu Fehlern führen kann wenn man nicht aufpasst.
Vielen Dank für den Hinweis :)
Gibt es Alternativen ? Selber erstellen per Linien?
nnnik wrote: Und ich finde es komisch den Rahmen unter die Box zu legen.
Das wurde bereits behoben, hatte das nur noch gelassen, da ich mich erstmal um die darstellung des Rahmens kümmern wollte ^^
User avatar
nnnik
Posts: 4500
Joined: 30 Sep 2013, 01:01
Location: Germany

Re: DirectX Hook im Gui (via GDIP(?))

09 Mar 2018, 05:20

Oh ich habs vergessen zu sagen aber was ich meinte ist in der linken, oberen Ecke der GUI.

Bei der RECT Struktur reicht es eignetlich, wenn du dir anschaust was in MSDN darüber steht.
Wenn du das nicht machst läufst du Gefahr, dass deine Ränder sich z.B. um ein Pixel verschieben und du nicht weißt wieso.
Recommends AHK Studio
User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

Re: DirectX Hook im Gui (via GDIP(?))

10 Mar 2018, 09:23

nnnik wrote:Oh ich habs vergessen zu sagen aber was ich meinte ist in der linken, oberen Ecke der GUI.

Bei der RECT Struktur reicht es eignetlich, wenn du dir anschaust was in MSDN darüber steht.
Wenn du das nicht machst läufst du Gefahr, dass deine Ränder sich z.B. um ein Pixel verschieben und du nicht weißt wieso.
Vielen Dank, das werde ich berücksichtigen, lese mich da gleich rein :)

Ich habe eine Frage zur Anordnung der Gui´s,
Wie kann ich es am besten lösen, das die Gui´s eine feste Reihenfolge haben?

Hier ein Test Skript was mein Problem darstellt...

Code: Select all

#Persistent
#SingleInstance force
#include gdip_New.ahk
#NoEnv
global GUICOUNT:=1
global _GUISTRUCT:= Object()
global DEFAULTBUTTONHANDLE := "BTN_Handle"

BTN_POS := {X:25,Y:25,W:55,H:35,Size: 16}
o := new Main.GDICLASS(GDIP_Startup(),DEFAULTBUTTONHANDLE)
Box1 := o.CreateBox(15,15,250,250,0xDD000000,[True,5,0xFFD4FFFF])
Str1 := o.DrawStringEx("HIER KLICKEN","Arial",25,"FFFFFFFFF",30,70,200,30,"Centre vCentre")
BTN1 := o.CreateButton(BTN_POS.X,BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Solo",0xFF000000,[True,"Solo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN2 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Duo",0xFF000000,[True,"Duo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN3 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Trio",0xFF000000,[True,"Trio","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN4 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Squad",0xFF000000,[True,"Squad","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
return

class Main
{
	static _ERROR := False
		   ,GDITOKEN
		   
	class GDICLASS
	{	
		static HWND,HDC,HBM,OBM,GRAPH,PEN,BRUSH,_tmpSTRUCTID
		__New(pToken) {
			Main._ERROR := False
			Main.GDITOKEN 	:= pToken
			if(!Main.GDITOKEN){
				return this.SetLastError("Error in __New(" Main.GDITOKEN ") -> GDIP StartUp Failed")
			}
		}
		
		CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pSize:=5,pColor:=0xFF000000)
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
				
			g_ID := this.HandleGUIID("INC")
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "w" BoxW " h" BoxH " y" BoxY " x" BoxX ""
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(BoxW,BoxH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.PEN 			:= Gdip_CreatePen(pColor,pSize)
			Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH)
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0)
				return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_BORDERONLY")
			return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
		}
		CreateBox(BoxX,BoxY,BoxW,BoxH,pColor:=0xAA000000,pBorder:="")
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
				
			g_ID := this.HandleGUIID("INC")
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(BoxW,BoxH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.BRUSH 			:= Gdip_BrushCreateSolid(pColor)
			pBorder[1] == True ? this.PEN:=Gdip_CreatePen((pBorder[3] <> "" ? pBorder[3] : 0xFF000000), (pBorder[2] <= 1 || pBorder[2] < 0 ? 2 : pBorder[2])) : ""
			Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
			IsObject(pBorder) && pBorder[1] == True ? Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH) : ""
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
				bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
				return bID
			}
			return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
		}
		
		CreateEditBox(BoxX,BoxY,BoxW,BoxH,pText,pColor:=0xAA000000,pBorderColor:=0xFFFFFFFF)
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
				
			g_ID := this.HandleGUIID("INC")
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(BoxW,BoxH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.BRUSH 			:= Gdip_BrushCreateSolid(pColor)
			Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
				bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
				If(IsObject(pBorder) && pBorder[1] == True) 
					this.CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pBorder[2],pBorder[3])
				return bID
			}
			return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
		}
		
		;############################################################################################################
		;BorderArray := [State,Size,Color] on Todo!
		;TextArray := [State,Text,Font,Size,Pos,Color] - Done
		CreateButton(pX,pY,pW,pH,pButtonName,pColor:=0xAA000000,TextArr:="")
		{
			
			Default_Values_Text := [False,"Button",Arial,10,"vCentre",0xAA000000]
			if(!TextArr)
			{
				for _i,_v in Default_Values_Text
				{
					TextArr[_i] <> "" ? continue : TextArr[_i] := _v
				}
				this.SetLastError("Handling Error: The Text Array Parameter in the Func: " A_ThisFunc " has been setted to Default.`nParams: PosX, PosY, PosW, PosH, TextArray[State,Text,Font,Size,Pos,Color]")
			}
			
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()
			
			if(!pButtonName)
				return this.SetLastError("Handling Error: Insert a Label in Function: " A_ThisFunc "`nParams: PosX, PosY, PosW, PosH, Label (for response), ButtonColor, TextArray(Text,Font,Size,Color),BorderArray(UseBorder, Heigth, Color)")
			
			g_ID := this.HandleGUIID("INC")
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: add, button, w%pW% h%pH% hwndhBTN
			_F := Func(DEFAULTBUTTONHANDLE).Bind(pButtonName,(TextArr[2] <> "" ? TextArr[2] : "NONE"))
			GuiControl +g, % hBTN, % _F
			Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH 
			this.HWND 			:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(pW,pH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			this.BRUSH 			:= Gdip_BrushCreateSolid(pColor)
			Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,pW,pH)
			TextArr[1] ? Gdip_TextToGraphics(this.GRAPH, TextArr[2], "c" (instr(TextArr[6],"0x") ? StrReplace(TextArr[6],"0x","") : TextArr[6]) " s" TextArr[4] " " TextArr[5], TextArr[3], pW,pH) :
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){ 
				return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,pX,pY,pW,pH,"TYP_BUTTON")
			}
			return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc "`nParams(" ("x" pX " y" pY " w" pW " h" pH " g" pLabel " c" pColor) ")")
		}
		;############################################################################################################
		
		DrawStringEx(pText,pFont,pSize,pColor,pX,pY,pW,pH,pPos:="vCenter")
		{
			if(!Main.GDITOKEN)
				Main.GDITOKEN := Gdip_Startup()				
				
			g_ID := this.HandleGUIID("INC")
			Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
			Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH 
			this.HWND 	:= WinExist()
			this.HDC 			:= CreateCompatibleDC()
			this.HBM 			:= CreateDIBSection(pW,pH, this.HDC ,32)
			this.OBM 			:= SelectObject(this.HDC, this.HBM)
			this.GRAPH 			:= Gdip_GraphicsFromHDC(this.HDC)
			
			RC := Gdip_TextToGraphics(this.GRAPH, pText, "c" pColor " s" pSize " " pPos, pFont, pW,pH)
			if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
				return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, -1,pX,pY,pW,pH,pSize,pColor,pFont,pPos,"TYP_STRINGEX")
			}
			return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
		}
		ADDStruct(pGraph=-1,phwnd=-1,pHDC=-1,pHBM=-1,pOBM=-1,pgID=-1,pBrush=-1,pPen=-1,_X=-1,_Y=-1,_W=-1,_H=-1,pSize=-1,pColor=-1,pFont=-1,pPos=-1,_Typ=-1)
		{
			this._tmpSTRUCTID := -1
			if(_GUISTRUCT.MaxIndex() == ""){
				_GUISTRUCT.Push([ 1 , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
				this._tmpSTRUCTID:= 1
				return this._tmpSTRUCTID
			}
			Loop
			{	
				if(_GUISTRUCT[ A_Index ][1] == "" || _GUISTRUCT[ A_Index ][1] == -1){
					_GUISTRUCT.Push([ A_Index , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
					if(_GUISTRUCT[ A_Index ][1] != -1)
						return this._tmpSTRUCTID:=A_Index
					break
				}
				if(A_Index >= 1000)
					break
			}
			if(this._tmpSTRUCTID != -1){
				return this._tmpSTRUCTID
			}else
				return this.SetLastError("Fehler: Keine Freie Strukturen ID gefunden | MaxSize(" _GUISTRUCT.MaxIndex() ")")
		}
		RemoveID(pID)
		{
			While(A_Index <= _GUISTRUCT.MaxIndex())
			{	
				if(_GUISTRUCT[ A_Index ][1] == pID)
				{
					if(_GUISTRUCT[ A_Index ][7] != -1)
						Gdip_DeleteBrush(_GUISTRUCT[ A_Index ][7])
					if(_GUISTRUCT[ A_Index ][8] != -1)
						Gdip_DeletePen(_GUISTRUCT[ A_Index ][8])
				
					SelectObject(_GUISTRUCT[ A_Index ][4], _GUISTRUCT[ A_Index ][6])
					DeleteObject(_GUISTRUCT[ A_Index ][5])
					DeleteDC(_GUISTRUCT[ A_Index ][4])
					Gdip_DeleteGraphics(_GUISTRUCT[ A_Index ][2])
					g_ID := _GUISTRUCT[ A_Index ][9]
						Gui, %g_ID%: Destroy
					this.HandleGUIID("DEC")
					Main._ERROR := False
					Loop % _GUISTRUCT[ A_Index ].MaxIndex()
						_GUISTRUCT[ pID ][ A_Index ] := -1 
					break
				}
			}
			return
		}
		GetLastError(){
			if(Main._ERROR != False){
				Msgbox % Main._ERROR
				this.SetLastError(False)
			}
			return
		}
		SetLastError(ERRORMSG){
			Main._ERROR := ERRORMSG
			return
		}
		HandleGUIID(Typ:="INC",pVal:=0)
		{
			if(Typ == "INC"){
				return GUICOUNT++
			}else if(Typ == "DEC"){
				return GUICOUNT--
			}else if(Typ == "GET"){
				return GUICOUNT
			}else if(Typ == "SET"){
				return GUICOUNT:= pVal
			}
			return this.SetLastError("Handling ERROR: Wrong Param setted to Func: " A_ThisFunc)
		}
	} 
}
return

BTN_Handle(ButtonName,ButtonText)
{
   Msgbox % "ButtonName: " ButtonName "`nButtonText: " ButtonText
}
return
Ich hoffe jemand hat eine Idee, bin derzeit am versuchen das ganze über GetControlFocus(?) zu lösen, aber bisher erfolglos...
just me
Posts: 9450
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: DirectX Hook im Gui (via GDIP(?))

10 Mar 2018, 10:40

Moin,

wenn sich das Ganze dem Betrachter als ein Fenster darstellen soll, ist das Konzept, für unterschiedliche Gui-Bereiche unterschiedliche Top-Level-Fenster zu erstellen, gelinde gesagt suboptimal. Ich halte in diesem Fall eine Bitmap, in die alle Bestandteile des 'Gui-Fensters' nacheinander gezeichnet werden, für besser. Deine Klassenstruktur muss dafür aber massiv überarbeitet werden.

Zur Klasse an sich: Kompliment!
User avatar
Renz
Posts: 20
Joined: 05 Sep 2015, 21:56
Location: Dortmund (NRW|GER)
Contact:

Re: DirectX Hook im Gui (via GDIP(?))

10 Mar 2018, 10:56

just me wrote:Moin,

wenn sich das Ganze dem Betrachter als ein Fenster darstellen soll, ist das Konzept, für unterschiedliche Gui-Bereiche unterschiedliche Top-Level-Fenster zu erstellen, gelinde gesagt suboptimal.

Ja, ich bemerke es auch langsam...
just me wrote:Ich halte in diesem Fall eine Bitmap, in die alle Bestandteile des 'Gui-Fensters' nacheinander gezeichnet werden, für besser.
Deine Klassenstruktur muss dafür aber massiv überarbeitet werden.
Das werde ich denk ich in angriff nehmen, diese Version ruhen lassen und V2 mit Bitmap schreiben...
Diese ganzen Gui´s sind auch nicht sehr performant, schon alleine beim aufbau, hatte das mal mit 100+ getestet, irgendwann bei 30-40 ca. verzögert sich schon die Darstellung ...
just me wrote:Zur Klasse an sich: Kompliment!
Danke :)

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 46 guests