Speichern???

08/01/2010 19:50 ooOPhoenixXxx#1
Hey Leute,

Also ich möchte als aller erstes anmerken das ich was AutoIt angeht noch Anfänger bin also tut mir den gefallen und verschont mich mit Fach bla bla :rolleyes:.

also nun aber zu meinem eigentlichen Problem:

Stellen wir uns mal vor wir hätten eine GUI mit einem Label, Einem Input feld und einem Button:
Code:
[COLOR="Magenta"]#include[/COLOR] [COLOR="Gray"]<GUIConstants.au3>[/COLOR]

[COLOR="Purple"]#Region ### START Koda GUI section ### Form=[/COLOR]
[COLOR="Red"]$Form1 =[/COLOR] [COLOR="blue"]GUICreate[/COLOR][COLOR="Red"]([/COLOR][COLOR="Gray"]"Form1"[/COLOR][COLOR="red"],[/COLOR] [COLOR="Purple"]174[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]134[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]193[/COLOR] [COLOR="red"],[/COLOR] [COLOR="purple"]125[/COLOR][COLOR="red"])[/COLOR]
[COLOR="red"]$Input1 =[/COLOR] [COLOR="blue"]GUICtrlCreateInput[/COLOR][COLOR="Red"]([/COLOR][COLOR="Gray"]"Eingabe"[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]24[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]72[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]121[/COLOR][COLOR="red"],[/COLOR] [COLOR="Purple"]21[/COLOR][COLOR="red"])[/COLOR]
[COLOR="red"]$Button1 =[/COLOR] [COLOR="blue"]GUICtrlCreateButton[/COLOR][COLOR="Red"]([/COLOR][COLOR="Gray"]"OK!"[/COLOR][COLOR="Red"],[/COLOR] [COLOR="purple"]48[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]96[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]75[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]25[/COLOR][COLOR="red"],[/COLOR] [COLOR="Purple"]0[/COLOR][COLOR="red"])[/COLOR]
[COLOR="red"]$Label1 =[/COLOR] [COLOR="Blue"]GUICtrlCreateLabel[/COLOR][COLOR="Red"]([/COLOR][COLOR="Gray"]"Text"[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]24[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]8[/COLOR][COLOR="red"],[/COLOR] [COLOR="purple"]116[/COLOR][COLOR="red"],[/COLOR] [COLOR="Purple"]57[/COLOR][COLOR="red"])[/COLOR]
[COLOR="Blue"]GUISetState[/COLOR][COLOR="Red"]([/COLOR][COLOR="Magenta"]@SW_SHOW[/COLOR][COLOR="red"])[/COLOR]
[COLOR="Purple"]#EndRegion ### END Koda GUI section ###[/COLOR]

[COLOR="Blue"]While[/COLOR] [COLOR="Purple"]1[/COLOR]
	[COLOR="Red"]$nMsg =[/COLOR] [COLOR="Blue"]GUIGetMsg[/COLOR][COLOR="Red"]()[/COLOR]
	[COLOR="Blue"]Switch[/COLOR] [COLOR="Red"]$nMsg[/COLOR]
		[COLOR="Blue"]Case[/COLOR] [COLOR="Red"]$GUI_EVENT_CLOSE[/COLOR]
			[COLOR="Blue"]Exit[/COLOR]

	[COLOR="blue"]EndSwitch[/COLOR]
[COLOR="blue"]WEnd[/COLOR]
wie bekomme ich dann die 2 folgenden Funktionen hin?:

1. wenn ich in das Inputfeld etwas rein schreibe und auf den Button Drücke
soll im Label das stehen was ich vorher im Inputfeld eingegeben hatte.

2. wenn ich die GUI beende und neu starte soll trotz des Neustarts im
Inputfeld noch das stehen was ich zuvor eingegeben hatte (also wie die
Settings bei einem Game)

Ich bedanke mich schon mal im voraus bei euch
MfG: ooOPhoenixXxx
08/01/2010 20:27 bladerofdarknes#2
kann dir nur mein tutorial ans herzen legen:

[Only registered and activated users can see links. Click Here To Register...]
08/01/2010 20:29 HardCore.1337#3
1)
PHP Code:
GUICtrlSetData($Label1$Variable_aus_InputBox
2)Sch dir dazu INI Write und INI Read an.
08/01/2010 21:02 ooOPhoenixXxx#4
ok ich hab mich jetzt einfach mal an das TuT gehalten und der Code sieht jetzt so aus:

Code:
#include <GUIConstants.au3>


$text1=IniRead("Label.ini","texte","Read", "")


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 174, 134, 193 , 125)
$Input1 = GUICtrlCreateInput("Eingabe", 24, 72, 121, 21)
$Button1 = GUICtrlCreateButton("OK!", 48, 96, 75, 25, 0)
$Label1 = GUICtrlCreateLabel($text1, 24, 8, 116, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###





While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            call("test")
    EndSwitch
WEnd


func test()
	$read1=GUICtrlRead($Input1)
	iniwrite("Label.ini","texte","Read", $read1)
EndFunc
das Ärgerliche ist nur das man erst das Script neu starten muss damit die veränderte ini neu ausgelesen wird. hab schon versucht es in eine Funktion zu packen und diese nach dem ändern der ini neu aufzurufen aber ... naja das geht net.

habt ihr ne Lösung dafür?
08/01/2010 21:52 bladerofdarknes#5
mach es so wie hardcore es sagte:
GUICtrlSetData($Label1, $Variable_aus_InputBox)
und stadt $Variable_aus_InputBox
GUICtrlSetData($Label1, IniRead("Label.ini","texte","Read", $read1))
sollte so gehen bin gerade nicht zu hause
also zuerst in der ini speichern dann lesen lassen ;)
08/01/2010 22:15 PenGuin :O#6
Btw brauchst du kein "Call" Befehl um die Funktionen aufzurufen...

In deinem Fall reicht ein einfaches "test()"

Könnte dir auch noch MySQL nennen, ist aber etwas schwieriger, für deinen Zweck reicht Inis.

Und zusätzlich schau dir AdlibRegister an.
Du schreibst eine Funktion, die Inis ausliest und bei Veränderungen das geschriebene übernimmt...
08/01/2010 22:16 ooOPhoenixXxx#7
@bladerofdarknes:

also wenn du das jetzt so meinst:

Code:
#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 174, 134, 193 , 125)
$Input1 = GUICtrlCreateInput("Eingabe", 24, 72, 121, 21)
$Button1 = GUICtrlCreateButton("OK!", 48, 96, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("", 24, 8, 116, 57)
GUICtrlSetData($Label1, IniRead("Label.ini","texte","Read", ""))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###





While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            call("test")
    EndSwitch
WEnd


func test()
	$read1=GUICtrlRead($Input1)
	iniwrite("Label.ini","texte","Read", $read1)
EndFunc
dann is das problem geblieben...
wenn ich das aber anders machen sollte (was warscheinlich der fall ist:rolleyes:) musst du mir das nochmal für dumme erklären:confused:
08/01/2010 22:24 PenGuin :O#8
Schau dir mal meinen Post an.
08/01/2010 22:26 Shadow992#9
Quote:
Originally Posted by ooOPhoenixXxx View Post
@bladerofdarknes:

also wenn du das jetzt so meinst:

Code:
#include <GUIConstants.au3>


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 174, 134, 193 , 125)
$Input1 = GUICtrlCreateInput("Eingabe", 24, 72, 121, 21)
$Button1 = GUICtrlCreateButton("OK!", 48, 96, 75, 25, 0)
$Label1 = GUICtrlCreateLabel("", 24, 8, 116, 57)
GUICtrlSetData($Label1, IniRead("Label.ini","texte","Read", ""))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###





While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            call("test")
    EndSwitch
WEnd


func test()
	$read1=GUICtrlRead($Input1)
	iniwrite("Label.ini","texte","Read", $read1)
EndFunc
dann is das problem geblieben...
wenn ich das aber anders machen sollte (was warscheinlich der fall ist:rolleyes:) musst du mir das nochmal für dumme erklären:confused:
Allzuviele Abfragen kannst du da aber nicht machen, AutoIt ist dafür einfach zu langsam:
PHP Code:
#include <GUIConstants.au3>

$FileRead=0

#Region ### START Koda GUI section ### Form=
$Form1 GUICreate("Form1"174134193 125)
$Input1 GUICtrlCreateInput("Eingabe"247212121)
$Button1 GUICtrlCreateButton("OK!"489675250)
$Label1 GUICtrlCreateLabel(""24811657)
$FileRead=IniRead("Label.ini","texte","Read""")
GUICtrlSetData($Label1$FileRead)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###





While 1
    $nMsg 
GUIGetMsg()
    Switch 
$nMsg
        
Case $GUI_EVENT_CLOSE
            
Exit
        Case 
$Button1
            call
("test")
    EndSwitch
    if 
$FileRead<>IniRead("Label.ini","texte","Read""")then
    $FileRead
=IniRead("Label.ini","texte","Read""")
    
GUICtrlSetData($Label1$FileRead)
    EndIf
WEnd


func test
()
    
$read1=GUICtrlRead($Input1)
    
iniwrite("Label.ini","texte","Read"$read1)
EndFunc 
08/01/2010 22:34 ooOPhoenixXxx#10
puh... also:
@Pinguin94:
AdlibRegister is ne feine sache (ich versteh den befehl zwar nicht so ganz... aber nicht so wichtig jedenfalls funktioniert´s damit.)

@Shadow992:
funzt ebenfalls super (hier versteh ich zwar die zusammenhänge nicht ganz... muss ich aber auch zum glück nicht alles was ich brauch hab ich ja jetzt ^^)

Thx @All
08/01/2010 23:55 PenGuin :O#11
Er liest einfach dauerhaft die Ini aus, und wenn sich ein Eintrag geändert hat, setz er ihn in den Input.

AdlibRegister macht das ganze nur schöner, da dort die Hauptschleife nicht so stark belastet wird, wobei das hier egal ist, da sowieso kaum etwas in der Hautpschleife steht...
08/03/2010 13:39 ooOPhoenixXxx#12
xD versteh das jetzt Bitte nicht falsch aber so weit war ich auch schon:p naja trotzdem danke fürs erklären;)