Bild in ein EDIT einfügen Topic is solved

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

User avatar
glnklein
Posts: 90
Joined: 23 Oct 2020, 04:26

Bild in ein EDIT einfügen

16 Apr 2021, 13:57

hallo ich hab mal wieder eine frage ob etwas möglich ist :-)

Ich möchte in eine Edit Feld eine bild einfügen anstelle von einem Text ,im genauen handelt es sich um eine Chat in den ich zusätzlich zum Namen ein Avatar möchte .
Online habe ich nix gefunden deshalb frage ich mal direkt ob jemand sowas schon versucht hat
:D verwende AutoHotkey104805 :D ------------------------UPDATE auf ..1.1.33.02 erfolgreich , jetzt kommen neue Probleme :lolno:
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Bild in ein EDIT einfügen

17 Apr 2021, 05:20

Moin,

wenn Du das Edit auch interaktiv für die Texteingabe nutzen willst, ist es vielleicht möglich, aber sehr aufwändig. Warum muss es innerhalb des Edits sein?
User avatar
glnklein
Posts: 90
Joined: 23 Oct 2020, 04:26

Re: Bild in ein EDIT einfügen

17 Apr 2021, 07:38

moin , naja es handelt sich ja um einen Chat und da sollte der Avatar schon neben oder über dem Namen stehen , es ist das irc script von bentschie https://github.com/G33kDude/Socket.ahk/blob/master/Examples/IRC.ahk

Code: Select all

#NoEnv
SetBatchLines, -1

#Include ..\Socket.ahk

Random, Rand, 1000, 9999

Serv := ["chat.freenode.net", 6667]
Chan := "#ahk"
Nick := "Socket" Rand

; Create the Gui
Gui, Margin, 5, 5
Gui, Add, Edit, w640 h240 ReadOnly hWndhLog
Gui, Add, Edit, w640 h240 ReadOnly hWndhChat
Gui, Add, Edit, w580 h20 vMessage
Gui, Add, Button, x+m yp-1 w55 h22 gSubmit Default, Submit
GuiControl, Focus, Message
Gui, Show

; Create the IRC client class instance
Client := new IRC()
Client.hLog := hLog
Client.hChat := hChat

Client.Connect(Serv, Nick)
Client.SendText("JOIN " Chan)
return

GuiClose()
{
	ExitApp
}

Submit()
{
	global Client, Chan, hChat
	
	; Get the message box contents and empty the message box
	GuiControlGet, Message
	GuiControl,, Message
	
	Client.SendText("PRIVMSG " Chan " :" Message)
	EditAppend(hChat, Chan " <" Client.Nick "> " Message)
}

; Use the windows API to append text to an edit control quickly and efficiently
EditAppend(hEdit, Text)
{
	Text .= "`r`n"
	GuiControl, -Redraw, %hEdit%
	SendMessage, 0x00E, 0, 0,, ahk_id %hEdit% ; WM_GETTEXTLENGTH
	SendMessage, 0x0B1, ErrorLevel, ErrorLevel,, ahk_id %hEdit% ; EM_SETSEL
	SendMessage, 0x0C2, False, &Text,, ahk_id %hEdit% ; EM_REPLACESEL
	SendMessage, 0x115, 7, 0,, ahk_id %hEdit% ; WM_VSCROLL SB_BOTTOM
	GuiControl, +Redraw, %hEdit%
}

class IRC extends SocketTCP
{
	static Blocking := False
	static Buffer, hLog, hChat
	
	Connect(Address, Nick, User:="", Name:="", Pass:="")
	{
		this.Nick := Nick
		this.User := (User == "") ? Nick : User
		this.Name := (Name == "") ? Nick : Name
		Socket.Connect.Call(this, Address)
		if (Pass != "")
			this.SendText("PASS " Pass)
		this.SendText("NICK " this.Nick)
		this.SendText("USER " this.User " 0 * :" this.Name)
	}
	
	SendText(Text, Encoding:="UTF-8")
	{
		EditAppend(this.hLog, ">" Text)
		
		; Because we're overriding SendText, we have
		; to use the SendText from the base class.
		SocketTCP.SendText.Call(this, Text "`r`n",, Encoding)
	}
	
	OnRecv()
	{
		; Read the incoming bytes as ANSI (single byte encoding)
		; so we won't accidentally destroy partial UTF-8 multi-byte sequences.
		this.Buffer .= this.RecvText(,, "CP0")
		
		; Split the buffer into one or more lines, putting
		; any remaining text back into the buffer.
		Lines := StrSplit(this.Buffer, "`n", "`r")
		this.Buffer := Lines.Pop()
		
		for Index, Line in Lines
		{
			; Convert to UTF-8 now that we have a full line.
			; Because we read until the end of the line,
			; we know there won't be any partially read sequences.
			VarSetCapacity(ConvBuf, StrPut(Line, "CP0"))
			StrPut(Line, &ConvBuf, "CP0")
			Line := StrGet(&ConvBuf, "UTF-8")
			
			EditAppend(this.hLog, "<" Line)
			this.ParseLine(Line)
		}
	}
	
	ParseLine(Line)
	{
		IRCRE := "O)^(?::(\S+?)(?:!(\S+?))?(?:@(\S+?))? )?" ; Nick!User@Host
		. "(\S+)(?: (?!:)(.+?))?(?: :(.+))?$" ; CMD Params Params :Message
		if !RegExMatch(Line, IRCRE, Match)
			EditAppend(this.hLog, "PARSING ERROR")
		
		; Call the class method by the name OnCMD
		this["On" Match[4]](Match)
	}
	
	OnNICK(Match)
	{
		if (Match[1] == this.Nick)
			this.Nick := Match[6]
	}
	
	OnPING(Match)
	{
		this.SendText("PONG :" Match[6])
	}
	
	OnPRIVMSG(Match)
	{
		EditAppend(this.hChat, Match[5] " <" Match[1] "> " Match[6])
	}
}
:D verwende AutoHotkey104805 :D ------------------------UPDATE auf ..1.1.33.02 erfolgreich , jetzt kommen neue Probleme :lolno:
just me
Posts: 9423
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Bild in ein EDIT einfügen

17 Apr 2021, 09:44

Naja, und woher bekommt Dein Chatskript das Bild?
User avatar
glnklein
Posts: 90
Joined: 23 Oct 2020, 04:26

Re: Bild in ein EDIT einfügen

17 Apr 2021, 09:58

z.b aus einem Verzeichnis auf der platte oder erst herunterladen und dann ist es ja auf der Festplatte
:D verwende AutoHotkey104805 :D ------------------------UPDATE auf ..1.1.33.02 erfolgreich , jetzt kommen neue Probleme :lolno:
User avatar
glnklein
Posts: 90
Joined: 23 Oct 2020, 04:26

Re: Bild in ein EDIT einfügen

27 Apr 2021, 02:51

niemand eine Idee ?
:D verwende AutoHotkey104805 :D ------------------------UPDATE auf ..1.1.33.02 erfolgreich , jetzt kommen neue Probleme :lolno:
effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: Bild in ein EDIT einfügen

27 Apr 2021, 10:42

Ich habe leider keine Idee für dich, wenn du an dem Script aber etwas änderst, wäre es toll wenn du es hier teilst, ich habe das Script hier seit 10 Tagen ohne Probleme wie Logoffs am laufen
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Bild in ein EDIT einfügen

28 Apr 2021, 10:23

AFAIK, lassen Controls sich überlappend anlegen, insofern sollte sich doch ein Avatar mittels eines vorangestellten Picture-Control anzeigen lassen? Ähnlich wie Browser Zusatzinformationen (in) der Adresszeile voranstellen.
effel
Posts: 542
Joined: 16 Jan 2018, 13:34

Re: Bild in ein EDIT einfügen

28 Apr 2021, 10:38

oder das Edit zum ListView umcoden, dann sind nicht nur Bilder möglich, habe es schon versucht, aber da geht mit meinen begrenzten Fähigkeiten garnichts
User avatar
glnklein
Posts: 90
Joined: 23 Oct 2020, 04:26

Re: Bild in ein EDIT einfügen  Topic is solved

04 May 2021, 08:44

Hallo , da mit hier schon so viele geholfen haben wollte ich auch mal was posten was eventuell jemand verwenden kann .

ich habe dem Skript von Bertschi ein ListView und Bilder hinzugefügt so das jeder Chat Teilnehmer auch einen Avatar haben kann .

Die beiden Edit felder habe ich nur Deaktiviert sie können jederzeit wieder Aktiviert werden .

in zeile 62 und zeile 155 werden die daten an das ListView übergeben .


würde man nun das Skript mit 10 festen Avataren ausstatten könnte man beim senden seine Avatar Nummer mit senden
und der Empfänger würde diesen mit StrSplit aus der Nachricht raus holen und als richtigen Avatar einfügen .(nur eine Idee)


Hoffe konnte jemanden mit dem Skript helfen



Code: Select all

#NoEnv
SetBatchLines, -1

#Include Socket.ahk

Img := "C:\Windows\Web\Wallpaper\Windows\img0.jpg"
Img1 := "C:\Windows\System32\ApproveChildRequest.exe"
ImgW := 30 ; Breite der Bilder
ImgH := 30 ; Höhe der Bilder
HIL := IL_Create()
IL_SetSize(HIL, ImgW, ImgH)
IL_Add(HIL, Img, 0xFFFFFF, 1)
IL_Add(HIL, Img1, 0xFFFFFF, 2)
Gui, Add, ListView,Background2d3237 ca3aab9 -Hdr -Multi  w640 h240 ReadOnly hWndhLog vLV, Bild|Text
LV_SetImageList(HIL, 1)
LV_ModifyCol(1, ImgW + 4)

IL_SetSize(ILID, W, H) {
   Return DllCall("ComCtl32.dll\ImageList_SetIconSize", "Ptr", ILID, "Int", W, "Int", H, "Int")
}
;########################################################################
Random, Rand, 1000, 9999

Serv := ["chat.freenode.net", 6667]
Chan := "#meintestkanal"
Nick := "Socket" Rand

; Create the Gui
Gui,  Margin, 5, 5
;Gui,  Add, Edit, w640 h240 ReadOnly hWndhLog
;Gui,  Add, Edit, w640 h240 ReadOnly hWndhChat
Gui,  Add, Edit, w500 h20 vMessage
Gui,  Add, Button, x+m yp-1 w55 h22 gSubmit Default, Submit
GuiControl, Focus, Message
Gui,  Show
LV_Add("Icon0", "", "ONLINE") ;STATUS

; Create the IRC client class instance
Client := new IRC()
Client.hLog := hLog
Client.hChat := hChat

Client.Connect(Serv, Nick)
Client.SendText("JOIN " Chan)
return

GuiClose()
{
	ExitApp
}

Submit()
{
	global Client, Chan, hChat
	
	; Get the message box contents and empty the message box
	GuiControlGet, Message
	GuiControl,, Message
	
	Client.SendText("PRIVMSG " Chan " :" Message)
	EditAppend(hChat, Chan " <" Client.Nick "> " Message)
	LV_Add("Icon2", "",Client.Nick ":`n" Message) ; ###############################  Das was man sendet 
	;msgbox, % Message
}

; Use the windows API to append text to an edit control quickly and efficiently
EditAppend(hEdit, Text)
{
	Text .= "`r`n"
	GuiControl, -Redraw, %hEdit%
	SendMessage, 0x00E, 0, 0,, ahk_id %hEdit% ; WM_GETTEXTLENGTH
	SendMessage, 0x0B1, ErrorLevel, ErrorLevel,, ahk_id %hEdit% ; EM_SETSEL
	SendMessage, 0x0C2, False, &Text,, ahk_id %hEdit% ; EM_REPLACESEL
	SendMessage, 0x115, 7, 0,, ahk_id %hEdit% ; WM_VSCROLL SB_BOTTOM
	GuiControl, +Redraw, %hEdit%
}

class IRC extends SocketTCP
{
	static Blocking := False
	static Buffer, hLog, hChat
	
	Connect(Address, Nick, User:="", Name:="", Pass:="")
	{
		this.Nick := Nick
		this.User := (User == "") ? Nick : User
		this.Name := (Name == "") ? Nick : Name
		Socket.Connect.Call(this, Address)
		if (Pass != "")
			this.SendText("PASS " Pass)
		this.SendText("NICK " this.Nick)
		this.SendText("USER " this.User " 0 * :" this.Name)
	}
	
	SendText(Text, Encoding:="UTF-8")
	{
		EditAppend(this.hLog, ">" Text)
		; Because we're overriding SendText, we have
		; to use the SendText from the base class.
		SocketTCP.SendText.Call(this, Text "`r`n",, Encoding)
	}
	
	OnRecv()
	{
		; Read the incoming bytes as ANSI (single byte encoding)
		; so we won't accidentally destroy partial UTF-8 multi-byte sequences.
		this.Buffer .= this.RecvText(,, "CP0")
		
		; Split the buffer into one or more lines, putting
		; any remaining text back into the buffer.
		Lines := StrSplit(this.Buffer, "`n", "`r")
		this.Buffer := Lines.Pop()
		
		for Index, Line in Lines
		{
			; Convert to UTF-8 now that we have a full line.
			; Because we read until the end of the line,
			; we know there won't be any partially read sequences.
			VarSetCapacity(ConvBuf, StrPut(Line, "CP0"))
			StrPut(Line, &ConvBuf, "CP0")
			Line := StrGet(&ConvBuf, "UTF-8")
			
			EditAppend(this.hLog, "<" Line)
			this.ParseLine(Line)
				
			
		}
	}
	
	ParseLine(Line)
	{
		IRCRE := "O)^(?::(\S+?)(?:!(\S+?))?(?:@(\S+?))? )?" ; Nick!User@Host
		. "(\S+)(?: (?!:)(.+?))?(?: :(.+))?$" ; CMD Params Params :Message
		if !RegExMatch(Line, IRCRE, Match)
			EditAppend(this.hLog, "PARSING ERROR")
		
		; Call the class method by the name OnCMD
		this["On" Match[4]](Match)
	}
	
	OnNICK(Match)
	{
		if (Match[1] == this.Nick)
			this.Nick := Match[6]
	}
	
	OnPING(Match)
	{
		this.SendText("PONG :" Match[6])
	}
	
	OnPRIVMSG(Match)
	{
		EditAppend(this.hChat, Match[5] " <" Match[1] "> " Match[6])
		LV_Add("Icon1", "", Match[1]":`n" Match[6]) ; ###############################  Das was man sendet 
	}
}
Attachments
chat.jpg
chat.jpg (19.5 KiB) Viewed 597 times
:D verwende AutoHotkey104805 :D ------------------------UPDATE auf ..1.1.33.02 erfolgreich , jetzt kommen neue Probleme :lolno:

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 30 guests