Hallo name22,
hab ich schon probiert
[autoit]
$sText = Clipget()
StringReplace($sText, @CRLF, Chr(1))
MsgBox(0,"",$sText)
bin nicht weitergekommen.
Wie kann ich z.B. ein SOH vor ist per Code setzen?
Liebe Grüße
Ilse ![]()
Hallo name22,
hab ich schon probiert
[autoit]
$sText = Clipget()
StringReplace($sText, @CRLF, Chr(1))
MsgBox(0,"",$sText)
bin nicht weitergekommen.
Wie kann ich z.B. ein SOH vor ist per Code setzen?
Liebe Grüße
Ilse ![]()
Hallo zusammen,
ich habe eine Datei die SOH Steuerzeichen enthält.
Datei ist im Anhang.
Wie kann man diese Steuerzeichen per Code generieren, ersetzen...
Ich kann weder mit StringReplace od. RegEx darauf zugreifen.
Grüße
Ilse ![]()
Hallo Chip,
prima, gute Idee.
Hab das mal probiert.
Merci
Liebe Grüße
Ilse ![]()
Hallo,
ich habe folgendes Arrayproblem:
Die Arraygröße ist unbekannt. Habe gelesen, daß man das
mit ReDIM erweitern kann.
Komm nicht weiter...
So, das Script mit bestimmter Arraygröße klappt
Global $aNewText[5] = [4, "Neuer Text 1", "Neuer Text 2", "Neuer Text 3", "Neuer Text 4"], $aRow[5]
$hFile = FileOpen(@ScriptDir & "\ilse.txt", 0) ; Datei zum lesen öffnen
If $hFile = -1 Then Exit MsgBox(0, "Fehler", "Konnte Datei nicht zum lesen öffnen.")
$aRow[0] = FileReadLine($hFile)
For $i = 1 To 4
$aRow[$i] = FileReadLine($hFile)
$aRow[$i] = StringRegExpReplace($aRow[$i], ".+?(\|.+)", $aNewText[$i] & "$1", 1)
Next
FileClose($hFile)
$hFile = FileOpen(@ScriptDir & "\ilse.txt", 2) ; Datei zum schreiben öffnen
If $hFile = -1 Then Exit MsgBox(0, "Fehler", "Konnte Datei nicht zum schreiben öffnen.")
FileWriteLine($hFile, $aRow[0])
For $i = 1 To 4
FileWriteLine($hFile, $aRow[$i])
Next
FileClose($hFile)
Die Textdatei sieht so aus
||||||
Rex|89|155|34|0xFFEAE02D|0|Arial
Lissi|224|209|21|0xFFBA0722|0|Arial
Laurie|73|249|13|0xFF26EB21|0|Arial
bis hierhin alles ok!
Wenn nun die Textdatei eine unbestimmte Größe hat,
z.B. 20 Zeilen muß ich dann mit ReDim arbeiten?
Und da komm ich nicht weiter.
Also: Der Text $aNewtext kommt aus einem anderen Feld.
Das wäre egal, Diese Anzahl ist die gleiche wie die Namen der Textdatei.
Mein Versuch das einzubauen hat nicht funktioniert
If $aRow[Ubound($aRow)-1] <> '' Then
ReDim $aRow[Ubound($aRow)+1]
EndIf
Glaube nur der Loop müsste irgendwie neu dimensioniert werden,
damit die Quell-Textdatei immer richtig gelesen wird.
Liebe Grüße
Ilse ![]()
Hallo zusammen,
@ x0r
merci für die schnelle Hilfe.
misterspeed
Jeden Tag was neues.
Das war ein Super Tip!
Für alle anderen...
Hab in der Hilfe ein Beispiel gefunden,
da kann man jeden markierten Text vergrößern, verkleinern...Super!
#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
[/autoit] [autoit][/autoit] [autoit]Global $lblMsg, $hRichEdit
[/autoit] [autoit][/autoit] [autoit]Main()
[/autoit] [autoit][/autoit] [autoit]Func Main()
Local $hGui, $iMsg, $btnDoIt
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName,4) &")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
$lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
$btnDoIt = GUICtrlCreateButton("Do it", 270, 310, 40, 30)
GUISetState()
_GUICtrlRichEdit_SetSel($hRichEdit, 0, -1) ; select all
[/autoit] [autoit][/autoit] [autoit]While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
GUIDelete()
Exit
Case $iMsg = $btnDoIt
ChangeFontSize()
EndSelect
WEnd
EndFunc ;==>Main
Func ChangeFontSize()
Local $av, $iOld, $iNew
$av = _GuiCtrlRichEdit_GetFont($hRichEdit)
$iOld = $av[0]
_GuiCtrlRichEdit_ChangeFontSize($hRichEdit, 2)
$av = _GuiCtrlRichEdit_GetFont($hRichEdit)
$iNew = $av[0]
Report("Was " & $iOld & " points; is now " & $iNew & " points")
EndFunc ;==>ChangeFontSize
Func Report($sMsg)
GUICtrlSetData($lblMsg, $sMsg)
EndFunc ;==>Report
Liebe Grüße
Ilse ![]()
Hallo,
folgendes Problem:
Ich habe ein Editfeld.
Wie kann ich per Klick die Formatierungsoptionen anwenden.
z.B. Text zentrieren, Blocksatz, links, rechts, fett...
Bei GuictrlCreateEdit kann man ja z.B. $ES_Center mit übergeben.
Aber wie macht das das am besten per Buttons?
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$GuiTextbox = GUICreate("Text", 327, 245, 346, 262, BitOR($WS_MINIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_GROUP,$WS_BORDER,$WS_CLIPSIBLINGS))
GUISetIcon("D:\003.ico")
$btnok = GUICtrlCreateButton("zentrieren", 129, 203, 75, 25, $WS_GROUP)
$btnCancel = GUICtrlCreateButton("&Cancel", 210, 203, 75, 25, $WS_GROUP)
$Edit1 = GUICtrlCreateEdit("", 16, 16, 289, 177, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN,$WS_VSCROLL))
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
GUISetState(@SW_SHOW)
;~ Global Const $ES_LEFT = 0
;~ Global Const $ES_CENTER = 1
;~ Global Const $ES_RIGHT = 2
$Center = $ES_Center = 1
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $btnok
GUICtrlSetState($edit1,$ES_Center)
Case $btnCancel
EndSwitch
WEnd
Ist es auch möglich einen Text
innerhalb des Editfeldes unterschiedlich zu bearbeiten.
z.B. ein Wort Fett, unterstrichen evtl. Farben...
Geht das überhaupt?
Liebe Grüße
Ilse ![]()
So,
diese Version verursacht den Fehler
[autoit]
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
Global $_Grafik,$a_Font,$s_Input,$a_FontData
Global $_GrafikOeffnen,$a_FontData[1][7],$aFarbwert
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$_Grafik = GUICtrlCreateMenu ('Grafik')
$hOeffnen = GUICtrlCreateMenuItem ('Öffnen', $_Grafik)
$Label = GUICtrlCreateLabel("Text",20,20)
GUISetState(@SW_SHOW)
[/autoit][autoit][/autoit][autoit][/autoit][autoit]Global $s_Input, $i_UBound, $i_FontID = 1
[/autoit][autoit][/autoit][autoit][/autoit][autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hOeffnen
;_chooseColor()
_fonts()
EndSwitch
[/autoit][autoit][/autoit][autoit]
WEnd
Func _fonts()
If @error Then
return
endif
Msgbox(0,"","Funktion")
$s_Input = $i_FontID
$a_Font = _ChooseFont ($a_FontData[$s_Input][6],$a_FontData[$s_Input][3],$aFarbwert )
endfunc
Grüße
Ilse ![]()
EDIT: Code $Vars angepasst
Sorry, Oscar kommt nicht wieder vor.
...es geht mir nur um das Abfangen von Fehlern.
Also wie kann ich bei einem Fehler eine Meldung ausgeben.
Hallo $Var,
ist scheinbar was anderes.
Ich schau nochmal genau nach.
Eine Frage noch:
Wie kann ich mit _ChooseColor()
die Farbe des Controls ändern?
_ChooseColor() ;$Label
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <array.au3>
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
Global $_Grafik
Global $_GrafikOeffnen
$Form1 = GUICreate("Form1", 625, 443, 192, 124)
$_Grafik = GUICtrlCreateMenu ('Grafik')
$hOeffnen = GUICtrlCreateMenuItem ('Öffnen', $_Grafik)
$Label = GUICtrlCreateLabel("Text",20,20)
GUISetState(@SW_SHOW)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Global $s_Input, $i_UBound, $i_FontID = 1
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hOeffnen
_chooseColor()
EndSwitch
[/autoit] [autoit][/autoit] [autoit]
WEnd
Func _fonts()
Msgbox(0,"","")
$s_Input = $i_FontID
$a_Font = _ChooseFont ( )
endfunc
Grüße
Ilse ![]()
Hallo,
erstmal danke für die vielen Posts...
Ist alles ziemlich komplex,
deshalb wollte ich nur das wichtigste posten, damit man es
nachvollziehen kann.
Also:
Die Func... braucht eine ID
Wenn die noch nicht existiert
und der Button geklickt wird brauche ich die Meldung
daß zuerst eine ID erzeugt werden soll.
Func _MeineFunc()
[/autoit][autoit][/autoit][autoit]$s_Input = $i_FontID
;....
;....
_WinAPI_RedrawWindow ($h_Gui, 0, 0, 0x0002)
Autolaser
http://translation.autoit.de/onlinehilfe/keywords.htm
If @error Then
Return
hat leider nicht geklappt,
weil anschließend der Button generell
nichts mehr macht. Ich könnte mit If ID >=....
Vielleicht noch eine Idee?
Kürze dann den Code
und melde mich wieder
Grüße
Ilse ![]()
Hallo,
folgendes Problem:
[autoit]
Case $Start
_MeineFunc()
Wie kann ich hier einen Fehler
wenn die Func aufgerufen wird, abfangen
ohne das Script zu beenden.
Habe in der Func schon probiert
[autoit]
If @error then
Msgbox(0,"","Bitte Daten eingeben")
endif
;Func.....
aber ich muß ja in der While Schleife bleiben...
Klappt alles irgendwie nicht
Grüße
Ilse ![]()
Hallo,
ich habe ein Syntax Problem mit der Schriftgröße
Die Felder sehen so aus
[autoit]
;Ilse|38|18|14|0x02CE6B98|0|Arial
; Name;x;y;Size;Farbe...
So klappt das.
Das Problem: ich habe nun eine Schriftgröße die verzerrt ist.
Also 2 Koordinaten 200|60 also Breite und Höhe sind variable.
Wie kann ich diese Werte in der Syntax verwenden?
($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color[, $i_Align = 0[, $i_Weight = 0[, $s_Font = 'Arial']]])
geht das überhaupt?
Die Size Werte sind ja z.B. 32, 24... also fest.
Liebe Grüße
Ilse ![]()
Hallo name22,
erstmal ein dankeschön für deine Erklärungen
klar lese ich was du schreibst.
Hab auch versucht das nachzuvollziehen
und den Fehler nicht gleich gefunden.
Das Problem war folgendes:
Die Textdatei wurde mit den Werten falsch generiert.
Deswegen war die Transparenz, Handles...u.s.w bereits in der Textdatei.
Ich bin davon ausgegangen daß die Werte stimmen.
Diese falschen Datei wurde eingelesen.
Nun, ich habe dann die Datei von Hand kpl. neu aufgebaut
und siehe da, es hat funktioniert.
Dank deiner Hilfe...
Liebe Grüße
Ilse ![]()
Hallo,
irgendwie versteh ich das nicht.
Ich lade doch einfach nur die Informationen der Variablen
Name, Arial x, y aus dem Array.
Und das soll auf eine Grafik
Ich kann doch die Werte im Script lesen! (Zeile 60)
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Array.au3>
Global $sFile = @ScriptDir & "\ilse.txt"
Global $anewFile
_FileReadToArray2D($sFile,$anewFile,"|")
[/autoit] [autoit][/autoit] [autoit]_arraydisplay($anewFile); Das sind die Font Daten...
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup ()
;$h_Image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Hunde.jpg")
$h_Image = _GDIPlus_ImageLoadFromFile (FileOpenDialog ('Bild auswählen', @ScriptDir, 'Bilder (*.jpg)'))
If Not $h_Image Then Exit _GDIPlus_Shutdown ()
$i_Width = _GDIPlus_ImageGetWidth ($h_Image)
$i_Height = _GDIPlus_ImageGetHeight ($h_Image)
$h_Gui = GUICreate ('', $i_Width, $i_Height + 20)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$h_Graphics = _GDIPlus_GraphicsCreateFromHWND ($h_Gui)
$h_Bitmap = _GDIPlus_BitmapCreateFromGraphics ($i_Width, $i_Height, $h_Graphics)
$h_Buffer = _GDIPlus_ImageGetGraphicsContext ($h_Bitmap)
_WinAPI_RedrawWindow ($h_Gui, 0, 0, 0x0002)
GUIRegisterMsg (0x000F, 'WM_PAINT')
[/autoit] [autoit][/autoit] [autoit]OnAutoItExitRegister ('_OnExit')
GUISetState (@SW_SHOW, $h_Gui)
While True
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
Exit
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndSwitch
WEnd
;# Hier sollen die Strings auf das Bild gezeichnet werden!
Func WM_PAINT ()
_GDIPlus_GraphicsClear ($h_Buffer)
_GDIPlus_GraphicsDrawImageRect ($h_Buffer, $h_Image, 0, 0, $i_Width, $i_Height)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($h_Bitmap)
[/autoit] [autoit][/autoit] [autoit]For $i = 2 To $anewFile[0][0] ; Hier werden die ganzen vorhandenen Strings gezeichnet
Msgbox(0,"Soll auf die Grafik",$anewFile[$i][0])
; So ist die Textdatei aufgebaut
;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush
_GDIPlus_GraphicsDrawStringCustom ($h_Buffer, $anewFile[$i][0],$anewFile[$i][3],$anewFile[$i][4],$anewFile[$i][7],$anewFile[$i][7],$anewFile[$i][1])
Next
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImageRect ($h_Graphics, $h_Bitmap, 0, 0, $i_Width, $i_Height)
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _OnExit ()
[/autoit] [autoit][/autoit] [autoit]WM_PAINT()
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose ($h_Graphics)
_GDIPlus_BitmapDispose ($h_Bitmap)
_GDIPlus_GraphicsDispose ($h_Buffer)
_GDIPlus_ImageDispose ($h_Image)
_GDIPlus_Shutdown ()
EndFunc
; #FUNCTION# ===================================================================
; Name ..........: _GDIPlus_GraphicsDrawStringCustom
; Description ...: Draw a customized string
; AutoIt Version : v3.3.6.1
; Syntax ........: _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color[, $i_Align = 0[, $i_Weight = 0[, $s_Font = 'Arial']]])
; Parameter(s): .: $h_Graphics - Handle to a Graphics object
; $s_String - String to be drawn
; $n_X - X coordinate where the string will be drawn
; $n_Y - Y coordinate where the string will be drawn
; $n_Size - Font size to use for drawing
; $b_Color - Alpha, Red, Green and Blue components
; $i_Align - The alignment can be one of the following:
; |0 - The text is aligned to the left
; |1 - The text is centered
; |2 - The text is aligned to the right
; $i_Weight - The style of the typeface. Can be a combination of the following:
; |0 - Normal weight or thickness of the typeface
; |1 - Bold typeface
; |2 - Italic typeface
; |4 - Underline
; |8 - Strikethrough
; $s_Font - Name of the Font Family
; Return Value ..: Success - True
; Failure - False
; Author(s) .....: $var
Func _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color, $i_Align = 0, $i_Weight = 0, $s_Font = 'Arial')
Local $a_CreateSolidFill, $a_CreateStringFormat, $a_CreateFontFamilyFromName, $a_CreateFont, $t_Struct, $p_Layout, $a_Return
$a_CreateSolidFill = DllCall ($ghGDIPDll, 'int', 'GdipCreateSolidFill', 'int', $b_Color, 'dword*', 0)
$a_CreateStringFormat = DllCall ($ghGDIPDll, 'int', 'GdipCreateStringFormat', 'int', 0, 'word', 0, 'ptr*', 0)
$a_CreateFontFamilyFromName = DllCall ($ghGDIPDll, 'int', 'GdipCreateFontFamilyFromName', 'wstr', $s_Font, 'ptr', 0, 'handle*', 0)
$a_CreateFont = DllCall ($ghGDIPDll, 'int', 'GdipCreateFont', 'handle', $a_CreateFontFamilyFromName[3], 'float', $n_Size, 'int', $i_Weight, 'int', 3, 'ptr*', 0)
$t_Struct = DllStructCreate ($tagGDIPRECTF)
$p_Layout = DllStructGetPtr ($t_Struct)
DllStructSetData ($t_Struct, 'X', $n_X)
DllStructSetData ($t_Struct, 'Y', $n_Y)
DllStructSetData ($t_Struct, 'Width', 0)
DllStructSetData ($t_Struct, 'Height', 0)
DllCall ($ghGDIPDll, 'int', 'GdipSetStringFormatAlign', 'handle', $a_CreateStringFormat[3], 'int', $i_Align)
$a_Return = DllCall ($ghGDIPDll, 'int', 'GdipDrawString', 'handle', $h_Graphics, 'wstr', $s_String, 'int', -1, 'handle', $a_CreateFont[5], _
'ptr', $p_Layout, 'handle', $a_CreateStringFormat[3], 'handle', $a_CreateSolidFill[2])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteFont', 'handle', $a_CreateFont[5])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteFontFamily', 'handle', $a_CreateFontFamilyFromName[3])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteStringFormat', 'handle', $a_CreateStringFormat[3])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteBrush', 'handle', $a_CreateSolidFill[2])
Return $a_Return[0] = 0
EndFunc ;==> _GDIPlus_GraphicsDrawStringCustom
;==========================================================================================================================================
; Function: _FileReadToArray2D($FILEPATH, $ARRAY [, $DELIM=-1])
;
; Description: Read 1D/2D array from file, if $DELIM is given (<> -1) 2D array will created
;
; Parameter(s): $FILEPATH - path/filename of the file to read in an array
; $ARRAY - array variable to hold readed data
; optional $DELIM - delimiter for 2D-array entries, default -1 (none 2D-array)
;
; Requirement(s): None
;
; Return Value(s): On Success - Returns -1
; On Failure - Returns 0 and sets @error = 1 (given file are not seperated with given delimiter or count of delimiters
; are not equal); @error = 2 (unable to open filepath)
;
; Note: If given file is delimited to create 2D-array ALL lines need the same count of delimiters, otherwise an error occurs!
;
; Author(s): BugFix ( [email='bugfix@autoit.de'][/email] )
;==========================================================================================================================================
Func _FileReadToArray2D($FILEPATH, ByRef $ARRAY, $DELIM=-1)
Local $fh = FileOpen($FILEPATH, 0), $line, $var, $n = 1
If $fh = -1 Then
SetError(2)
Return 0
EndIf
If $DELIM <> -1 Then
$line = FileReadLine($fh, 1)
$var = StringSplit($line, $DELIM)
If IsArray($var) Then
$Ubound2nd = $var[0]
Local $AR[1][$Ubound2nd]
$AR[0][0] = 0
Else
SetError(1)
Return 0
EndIf
While 1
$line = FileReadLine($fh, $n)
If @error = -1 Then ExitLoop
$var = StringSplit($line, $DELIM)
If IsArray($var) Then
ReDim $AR[UBound($AR)+1][$Ubound2nd]
For $i = 0 To $Ubound2nd-1
$AR[UBound($AR)-1][$i] = $var[$i+1]
Next
$AR[0][0] += 1
Else
SetError(1)
Return 0
EndIf
$n += 1
Wend
Else
Local $AR[1]
$AR[0] = 0
While 1
$line = FileReadLine($fh, $n)
If @error = -1 Then ExitLoop
ReDim $AR[UBound($AR)+1]
$AR[UBound($AR)-1] = $line
$AR[0] += 1
$n += 1
WEnd
EndIf
FileClose($fh)
$ARRAY = $AR
Return -1
EndFunc ;==>_FileReadToArray2D
Hab die Textdatei erneuert
Grüße
Ilse ![]()
Hallo name22,
ich habe die Schriftgröße, Farbe, Position...
in das Array exportiert. Da war ein Fehler drin....
Andere Frage:
Könnte man die Werte in einer INI speichern,
dann diese Werte einlesen und anschließend
mit GDI auf die Grafik zeichnen und speichern????
Oder gäbe es dann auch Probleme mit Handles...?
Habe die Datei angehängt!
Liebe Grüße
Ilse ![]()
Hallo UEZ,
merci für den Hinweis.
Kannst du vielleicht nochmal drüberschauen
mit den Tastaturabkürzungen?
Wäre toll wenn das klappen würde.
Liebe Grüße
Ilse ![]()
Hallo,
folgendes Problem:
Ich habe in einer Datei Stringangaben die auf eine GDI Grafik
gezeichnet werden müssen. Das klappt leider nicht.
Die Grafikdatei sollte ohne eine Gui zu öffnen direkt mit den Stringangaben gezeichnet werden.
Das ist die Textdatei (im Anhang)
3|3|||||||||||||
Text 1|Arial|0|12.2449388504028|-96.2585067749023|200|60|0x03F66B98|0x03F66E60|65180408|65180720||||
Text 2|Arial|0|16.3265705108643|-20.7483043670654|77.5510158538818|20.408164024353|0x03E9ACD8|0x03F66E60|65641688|65350072||||
Text 3|Arial|0|83.6735076904297|14.6258459091187|77.551|20.408|0x03E9AD30|0x03F66E60|65359240|65350376||||
So ist die Stringdatei aufgebaut
[autoit]
;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush
also alles was zum Zeichnen benötigt wird.
Diese Datei habe ich nun als 2DArray eingelesen
[autoit]
_FileReadToArray2D($sFile,$anewFile,"|")
Diese Daten sollten nun kpl. mit der Grafikdatei abgespeichert werden
Farben, Position ... ist alles enthalten.
_GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")
Aber die Texte kommen da nie an.... ![]()
Hier mal das kpl. Script
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <File.au3>
#include <Array.au3>
Global $sFile = @ScriptDir & "\ilse.txt"
Global $anewFile
_FileReadToArray2D($sFile,$anewFile,"|")
[/autoit] [autoit][/autoit] [autoit]_arraydisplay($anewFile); Das sind die Font Daten...
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup ()
;$h_Image = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\Hunde.jpg")
$h_Image = _GDIPlus_ImageLoadFromFile (FileOpenDialog ('Bild auswählen', @ScriptDir, 'Bilder (*.jpg)'))
If Not $h_Image Then Exit _GDIPlus_Shutdown ()
$i_Width = _GDIPlus_ImageGetWidth ($h_Image)
$i_Height = _GDIPlus_ImageGetHeight ($h_Image)
$h_Gui = GUICreate ('', $i_Width, $i_Height + 20)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$h_Graphics = _GDIPlus_GraphicsCreateFromHWND ($h_Gui)
$h_Bitmap = _GDIPlus_BitmapCreateFromGraphics ($i_Width, $i_Height, $h_Graphics)
$h_Buffer = _GDIPlus_ImageGetGraphicsContext ($h_Bitmap)
_WinAPI_RedrawWindow ($h_Gui, 0, 0, 0x0002)
GUIRegisterMsg (0x000F, 'WM_PAINT')
[/autoit] [autoit][/autoit] [autoit]OnAutoItExitRegister ('_OnExit')
GUISetState (@SW_SHOW, $h_Gui)
While True
Switch GUIGetMsg ()
Case $GUI_EVENT_CLOSE
Exit
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]EndSwitch
WEnd
;# Hier sollen die Strings auf das Bild gezeichnet werden!
Func WM_PAINT ()
_GDIPlus_GraphicsClear ($h_Buffer)
_GDIPlus_GraphicsDrawImageRect ($h_Buffer, $h_Image, 0, 0, $i_Width, $i_Height)
Local $hContext = _GDIPlus_ImageGetGraphicsContext($h_Bitmap)
[/autoit] [autoit][/autoit] [autoit]For $i = 1 To $anewFile[0][0] ; Hier werden die ganzen vorhandenen Strings gezeichnet
; So ist die Textdatei aufgebaut
;0=sText 1=sFont 2=iStyle 3=iX 4=iY 5=iW 6=iH 7=hFormat 8=hFamily 9=hPath 10=Brush
_GDIPlus_GraphicsDrawStringCustom ($h_Buffer, $anewFile[$i][0],$anewFile[$i][3],$anewFile[$i][4],$anewFile[$i][7],$anewFile[$i][7],$anewFile[$i][1])
Next
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawImageRect ($h_Graphics, $h_Bitmap, 0, 0, $i_Width, $i_Height)
[/autoit] [autoit][/autoit] [autoit]EndFunc
[/autoit] [autoit][/autoit] [autoit]Func _OnExit ()
[/autoit] [autoit][/autoit] [autoit]WM_PAINT()
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_ImageSaveToFile($h_Bitmap, @ScriptDir & "\Ilse.jpg")
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDispose ($h_Graphics)
_GDIPlus_BitmapDispose ($h_Bitmap)
_GDIPlus_GraphicsDispose ($h_Buffer)
_GDIPlus_ImageDispose ($h_Image)
_GDIPlus_Shutdown ()
EndFunc
; #FUNCTION# ===================================================================
; Name ..........: _GDIPlus_GraphicsDrawStringCustom
; Description ...: Draw a customized string
; AutoIt Version : v3.3.6.1
; Syntax ........: _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color[, $i_Align = 0[, $i_Weight = 0[, $s_Font = 'Arial']]])
; Parameter(s): .: $h_Graphics - Handle to a Graphics object
; $s_String - String to be drawn
; $n_X - X coordinate where the string will be drawn
; $n_Y - Y coordinate where the string will be drawn
; $n_Size - Font size to use for drawing
; $b_Color - Alpha, Red, Green and Blue components
; $i_Align - The alignment can be one of the following:
; |0 - The text is aligned to the left
; |1 - The text is centered
; |2 - The text is aligned to the right
; $i_Weight - The style of the typeface. Can be a combination of the following:
; |0 - Normal weight or thickness of the typeface
; |1 - Bold typeface
; |2 - Italic typeface
; |4 - Underline
; |8 - Strikethrough
; $s_Font - Name of the Font Family
; Return Value ..: Success - True
; Failure - False
; Author(s) .....: $var
Func _GDIPlus_GraphicsDrawStringCustom ($h_Graphics, $s_String, $n_X, $n_Y, $n_Size, $b_Color, $i_Align = 0, $i_Weight = 0, $s_Font = 'Arial')
Local $a_CreateSolidFill, $a_CreateStringFormat, $a_CreateFontFamilyFromName, $a_CreateFont, $t_Struct, $p_Layout, $a_Return
$a_CreateSolidFill = DllCall ($ghGDIPDll, 'int', 'GdipCreateSolidFill', 'int', $b_Color, 'dword*', 0)
$a_CreateStringFormat = DllCall ($ghGDIPDll, 'int', 'GdipCreateStringFormat', 'int', 0, 'word', 0, 'ptr*', 0)
$a_CreateFontFamilyFromName = DllCall ($ghGDIPDll, 'int', 'GdipCreateFontFamilyFromName', 'wstr', $s_Font, 'ptr', 0, 'handle*', 0)
$a_CreateFont = DllCall ($ghGDIPDll, 'int', 'GdipCreateFont', 'handle', $a_CreateFontFamilyFromName[3], 'float', $n_Size, 'int', $i_Weight, 'int', 3, 'ptr*', 0)
$t_Struct = DllStructCreate ($tagGDIPRECTF)
$p_Layout = DllStructGetPtr ($t_Struct)
DllStructSetData ($t_Struct, 'X', $n_X)
DllStructSetData ($t_Struct, 'Y', $n_Y)
DllStructSetData ($t_Struct, 'Width', 0)
DllStructSetData ($t_Struct, 'Height', 0)
DllCall ($ghGDIPDll, 'int', 'GdipSetStringFormatAlign', 'handle', $a_CreateStringFormat[3], 'int', $i_Align)
$a_Return = DllCall ($ghGDIPDll, 'int', 'GdipDrawString', 'handle', $h_Graphics, 'wstr', $s_String, 'int', -1, 'handle', $a_CreateFont[5], _
'ptr', $p_Layout, 'handle', $a_CreateStringFormat[3], 'handle', $a_CreateSolidFill[2])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteFont', 'handle', $a_CreateFont[5])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteFontFamily', 'handle', $a_CreateFontFamilyFromName[3])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteStringFormat', 'handle', $a_CreateStringFormat[3])
DllCall ($ghGDIPDll, 'int', 'GdipDeleteBrush', 'handle', $a_CreateSolidFill[2])
Return $a_Return[0] = 0
EndFunc ;==> _GDIPlus_GraphicsDrawStringCustom
;==========================================================================================================================================
; Function: _FileReadToArray2D($FILEPATH, $ARRAY [, $DELIM=-1])
;
; Description: Read 1D/2D array from file, if $DELIM is given (<> -1) 2D array will created
;
; Parameter(s): $FILEPATH - path/filename of the file to read in an array
; $ARRAY - array variable to hold readed data
; optional $DELIM - delimiter for 2D-array entries, default -1 (none 2D-array)
;
; Requirement(s): None
;
; Return Value(s): On Success - Returns -1
; On Failure - Returns 0 and sets @error = 1 (given file are not seperated with given delimiter or count of delimiters
; are not equal); @error = 2 (unable to open filepath)
;
; Note: If given file is delimited to create 2D-array ALL lines need the same count of delimiters, otherwise an error occurs!
;
; Author(s): BugFix ( [email='bugfix@autoit.de'][/email] )
;==========================================================================================================================================
Func _FileReadToArray2D($FILEPATH, ByRef $ARRAY, $DELIM=-1)
Local $fh = FileOpen($FILEPATH, 0), $line, $var, $n = 1
If $fh = -1 Then
SetError(2)
Return 0
EndIf
If $DELIM <> -1 Then
$line = FileReadLine($fh, 1)
$var = StringSplit($line, $DELIM)
If IsArray($var) Then
$Ubound2nd = $var[0]
Local $AR[1][$Ubound2nd]
$AR[0][0] = 0
Else
SetError(1)
Return 0
EndIf
While 1
$line = FileReadLine($fh, $n)
If @error = -1 Then ExitLoop
$var = StringSplit($line, $DELIM)
If IsArray($var) Then
ReDim $AR[UBound($AR)+1][$Ubound2nd]
For $i = 0 To $Ubound2nd-1
$AR[UBound($AR)-1][$i] = $var[$i+1]
Next
$AR[0][0] += 1
Else
SetError(1)
Return 0
EndIf
$n += 1
Wend
Else
Local $AR[1]
$AR[0] = 0
While 1
$line = FileReadLine($fh, $n)
If @error = -1 Then ExitLoop
ReDim $AR[UBound($AR)+1]
$AR[UBound($AR)-1] = $line
$AR[0] += 1
$n += 1
WEnd
EndIf
FileClose($fh)
$ARRAY = $AR
Return -1
EndFunc ;==>_FileReadToArray2D
Bin schon den ganzen Tag an diesem Problem,
ich hoffe ihr habt da ne Lösung.
Liebe Grüße
Ilse ![]()
Hallo UEZ,
danke für die Info.
Mit mitgeben/weitergeben..., meinte ich
darf ich an dem Code arbeiten und z.B. eine exe machen
ohne Rechte u.s.w. zu verletzen.
Habe mit Controlsend probiert, ist aber an den Tastaturabkürzungen gescheitert.
Geht das überhaupt, daß man dann Befehle im Hintergrund ausführen kann
ohne das Fenster zu sehen. Also ohne Winactivate...?
Liebe Grüße
Ilse ![]()
Hallo,
dank euch, zwei tolle Lösungen.
Liebe Grüße
Ilse ![]()
Hallo UEZ,
hab ich gemacht, alle Fehler sind weg.
Danke
Mal ne Frage zu dem Programm und ein paar Problemchen...
Grüße Ilse ![]()
Hallo,
folgendes Problem:
Ich habe mit Hilfe eines 2dArrays eine Textdatei erstellt.
Ich muß nun die erste Spalte lesen.
Im Beispiel soll
Text 1
Text 2
Text 3
Text 3
durch einen neuen Text ersetzt werden. (StringReplace, regex...)
kann ich nicht verwenden da alle Texte sich ändern.
Die Spalte bleibt immer gleich.
Die Textdatei
4|4|||||||||||||
Text 1|Arial|0|10|10|200|60|0x0000000003D29F20|0x0000000003877F10|64321440|64321824||||
Text 2|Arial|0|10|10|200|60|0x0000000003DD4ED0|0x0000000003877F10|64518432|64511168||||
Text 3|Arial|0|10|10|200|60|0x0000000003D85E40|0x0000000003877F10|64524544|64524928||||
Text 4|Arial|0|10|10|200|60|0x0000000003D85EB0|0x0000000003877F10|65010432|65010816||||
Also:
Text 1 wird gelesen, wenn fertig dann ersetzt durch neuer Text
Text 2 wird gelesen, wenn fertig dann ersetzt durch z.B. anderer Text
am Ende wird alles in eine neue Textdatei gespeichert.
Im Prinzip wird nur die Spalte 1 bearbeitet.
Habe mit Filereadline u. Stringsplit probiert
bin aber nicht ans Ziel gekommen.
Liebe Grüß
Ilse ![]()