Über GUICtrlCreateInput Variablen belegen?!

03/04/2009 19:48 Waynee#1
Jetzt bin versuche ich gerade die Input Felder (GUICtrlCreateInput)
auslesen zu lassen sobald jemand auf den Speicherbutton drückt...
Ich stelle hier mal den Code von dem Programm rein...

Code:
Global $Paused
; Hier wird der hotkeyset auf die 5 verschiedenen Funktionen weitergeleitet...
Hotkeyset ("^1", "Hotkey1") 
Hotkeyset ("^2", "Hotkey2")
Hotkeyset ("^3", "Hotkey3")
Hotkeyset ("^4", "Hotkey4")
Hotkeyset ("^5", "Hotkey5")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;wartet Hotkey ab
While 1
    Sleep(100)
WEnd
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Variablen
;Hier sollen, wenn es geht die Eingaben aus dem Input Feld eingetragen werden
$ID1 = ("IDNAME") ; Hier passwort aus dem 1. Feld
$PW1 = ("PASWORT") ;PW 1. Feld
$ID2 = ;2. Feld etc...
$PW2 = 
$ID3 =
$PW3 = 
$ID4 =
$PW4 = 
$ID5 =
$PW5 = 

;Programm Anfang
;Hier gehen die Funktionen los
Func Hotkey1 ()
send $ID1 ; Hier soll nun nach Möglichkeit  einfach nur noch das im Input eingetragenen Feld gesendet werden
send ("{enter}")
send $PW1 ; Mit dem Pw genauso
send ("{enter}")
EndFunc
usw.....

Hier der Teil in dem die Variablen vom Benutzer belegt werden sollen...

Code:
GUICtrlCreateLabel ("Account-ID",  80, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$ID1 = GUICtrlCreateInput ( "", 80,  33, 100, 20)
$ID2 = GUICtrlCreateInput ( "", 80,  58, 100, 20)
$ID3 = GUICtrlCreateInput ( "", 80,  83, 100, 20)
$ID4 = GUICtrlCreateInput ( "", 80,  108, 100, 20)
$ID5 = GUICtrlCreateInput ( "", 80,  133, 100, 20)

GUICtrlCreateLabeL ("Passwort", 200, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$Pw1 = GUICtrlCreateInput ( "", 200,  33, 100, 20)
$Pw2 = GUICtrlCreateInput ( "", 200,  58, 100, 20)
$Pw3 = GUICtrlCreateInput ( "", 200,  83, 100, 20)
$Pw4 = GUICtrlCreateInput ( "", 200,  108, 100, 20)
$Pw5 = GUICtrlCreateInput ( "", 200,  133, 100, 20)
Hier das Bild des GUI
[Only registered and activated users can see links. Click Here To Register...]

So jetzt erstma die 1. Frage...
hat jemand verstanden was ich meine? :D
wenn ja dann....
geht das überhaupt was ich hier realisieren möchte??!

Das ich jetzt im moment Variablen unnütz doppelt vergeben habe in den beiden Codes ist mir klar...wollte mein Problem und die Beziehungen verdeutlichen ;)
03/04/2009 21:20 felixli93#2
Code:
$msg = GuiGetMsg ()
If $msg = $speichern_button Then
    $accountname1 = GuiCtrlRead ($Id1)
    $accountname2 = GuiCtrlRead ($Id2)
    ...
    $passwort1 = GuiCtrlRead ($Pw1)
    $passwort2 = GuiCtrlRead ($Pw2)
    ...
EndIf

Erklärung:

"GuiCtrlRead" in Kombination mit einem Input gibt den Inhalt des Inputs zurück
der Inhalt des Inputs "$Id1" wird also, sobald du "$speichern_button" drückst in der Variable "$accountname1" gespeichert!
03/04/2009 23:00 Waynee#3
dankeseeehr ;)
habs jetzt schon alles eingegeben, nur leider kann ich es noch nicht testen, da der mich erst garnicht auf das programm leiten will, wenn ich auf start drücke -.-

Code:
 Case $Start 
		Starthotkeys ()
das ist die Funktion die ich hinterlegt habe...


Code:
Func Starthotkeys ()
	MsgBox(64, "Tutorial", "Hello World!")

	Global $Paused
; Hier wird der hotkeyset auf die 5 verschiedenen Funktionen weitergeleitet...
Hotkeyset ("^1", "Hotkey1") 
Hotkeyset ("^2", "Hotkey2")
Hotkeyset ("^3", "Hotkey3")
Hotkeyset ("^4", "Hotkey4")
Hotkeyset ("^5", "Hotkey5")
und darauf soll das leiten....
Das Hello World Kästchen hab ich nur kurzfristig eingebaut, damit ich nach jeder veränderung sehen kann, ob er mir nun in die Funktion springt oder nicht...
03/04/2009 23:10 felixli93#4
du bist sicher, dass $start ein GuiCtrlCreateButton ist?
03/04/2009 23:37 Waynee#5
Code:
GUISetState ()
$GUI1 = GUICreate("Metin2 Hotscript", 400, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box
$Start = GUICtrlCreateButton ("Start Script ", 240,160)
$Beenden = GUICtrlCreateButton ("Beenden ", 325, 160)
$Hotkey = GUICTRLCREATEBUTTON ("Hotkey-Settings", 20, 160)
$Pic1 = GuiCtrlCreatePic("Banner/1.jpg", 0, 0, 400, 100)
GUICtrlSetImage($Pic1, "Banner/"".jpg")
; Run the GUI until the dialog is closed
jo bin ich mir....

hab den Fehler gefunden -.-
man darf keine Func in Func schleifen schreiben.... 0o
aber was bau ich jetzt um die Hotkeys+ Funktionen rum, damit
sie reagieren, wenn man auf Start gedrückt hat?



Ah hab zu wenig nachgedacht ^^
hab jetzt ne Func schleife einfach um die Tastenbelegung gelegt...

Jetzt tritt aber mal wieder ein problem auf, welches ich nicht so einfach beheben kann...

Der sagt mir jetzt immer, send $accountname1
^ Error
Error parsing function call
nachdem ich in den Einstellungen ein Pw + ID abgelegt habe, auf Start gedrückt habe und strg+1 drücke....
Ich schätze, das er die Variable nicht erkennt weil ich irgendwas falsch eingesetzt habe...
Hier ma die Codes wo ich mir vorstellen kann, das ich einen Fehler gemacht habe...

Hier habe ich das Auslesen des Input mit in die Schleife geschrieben und unter die Input Felder getan.....
Code:
Func _GUI3 ()
#include <GUIConstants.au3>
$GUI3 = GUICreate("Metin2 Hotscript", 400, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

GUICtrlCreateLabel ("Hotkey",  10, 10)
GUICtrlSetFont (-1, 9, -1, -9)
GUICtrlCreateLabel ("Strg+1",  10, 35)
GUICtrlCreateLabel ("Strg+2",  10, 60)
GUICtrlCreateLabel ("Strg+3",  10, 85)
GUICtrlCreateLabel ("Strg+4",  10, 110)
GUICtrlCreateLabel ("Strg+5",  10, 135)

GUICtrlCreateLabel ("Account-ID",  80, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$ID1 = GUICtrlCreateInput ( "", 80,  33, 100, 20)
$ID2 = GUICtrlCreateInput ( "", 80,  58, 100, 20)
$ID3 = GUICtrlCreateInput ( "", 80,  83, 100, 20)
$ID4 = GUICtrlCreateInput ( "", 80,  108, 100, 20)
$ID5 = GUICtrlCreateInput ( "", 80,  133, 100, 20)

GUICtrlCreateLabeL ("Passwort", 200, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$Pw1 = GUICtrlCreateInput ( "", 200,  33, 100, 20)
$Pw2 = GUICtrlCreateInput ( "", 200,  58, 100, 20)
$Pw3 = GUICtrlCreateInput ( "", 200,  83, 100, 20)
$Pw4 = GUICtrlCreateInput ( "", 200,  108, 100, 20)
$Pw5 = GUICtrlCreateInput ( "", 200,  133, 100, 20)

$Speichern = GUICtrlCreateButton ("Speichern ", 10, 170)
$Abbrechen = GUICTRLCREATEBUTTON ("Abbrechen", 80, 170) 
$Pic3 = GuiCtrlCreatePic("Banner/3.jpg", 308, 10, 90, 180)
GUICtrlSetImage($Pic3, "Banner/"".jpg")
While 1
    $msg = GUIGetMsg()
	Switch $msg
		Case $Abbrechen
			GUIDelete ()
			Return (1)
If $msg = $Speichern Then
    $accountname1 = GuiCtrlRead ($Id1)
    $accountname2 = GuiCtrlRead ($Id2)
    $accountname3 = GuiCtrlRead ($Id3)
	$accountname4 = GuiCtrlRead ($Id4)
	$accountname5 = GuiCtrlRead ($Id5)
    $passwort1 = GuiCtrlRead ($Pw1)
    $passwort2 = GuiCtrlRead ($Pw2)
    $passwort3 = GuiCtrlRead ($Pw3)
	$passwort4 = GuiCtrlRead ($Pw4)
	$passwort5 = GuiCtrlRead ($Pw5)
EndIf
	Case $Beenden, $GUI_EVENT_CLOSE
	ExitLoop
	
EndSwitch

WEnd
Endfunc
Und hier könnte ich mir Vorstellen, das ich die Variable nicht einfach so senden kann, wie ich mir das vorstelle...

Code:
Func Hotkey1 ()
send $accountname1
send ("{enter}")
send $passwort1
send ("{enter}")
Endfunc
03/05/2009 17:21 deadline99#6
Code:
Func Hotkey1 ()
send $accountname1
send ("{enter}")
send $passwort1
send ("{enter}")
Endfunc
machs so:

PHP Code:
send($accountname1)
send("{enter}")
send($passwort1)
send("{enter}"
03/05/2009 18:13 felixli93#7
Quote:
Originally Posted by Waynee View Post
Code:
GUISetState ()
$GUI1 = GUICreate("Metin2 Hotscript", 400, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box
$Start = GUICtrlCreateButton ("Start Script ", 240,160)
$Beenden = GUICtrlCreateButton ("Beenden ", 325, 160)
$Hotkey = GUICTRLCREATEBUTTON ("Hotkey-Settings", 20, 160)
$Pic1 = GuiCtrlCreatePic("Banner/1.jpg", 0, 0, 400, 100)
GUICtrlSetImage($Pic1, "Banner/"".jpg")
; Run the GUI until the dialog is closed
jo bin ich mir....

hab den Fehler gefunden -.-
man darf keine Func in Func schleifen schreiben.... 0o
aber was bau ich jetzt um die Hotkeys+ Funktionen rum, damit
sie reagieren, wenn man auf Start gedrückt hat?



Ah hab zu wenig nachgedacht ^^
hab jetzt ne Func schleife einfach um die Tastenbelegung gelegt...

Jetzt tritt aber mal wieder ein problem auf, welches ich nicht so einfach beheben kann...

Der sagt mir jetzt immer, send $accountname1
^ Error
Error parsing function call
nachdem ich in den Einstellungen ein Pw + ID abgelegt habe, auf Start gedrückt habe und strg+1 drücke....
Ich schätze, das er die Variable nicht erkennt weil ich irgendwas falsch eingesetzt habe...
Hier ma die Codes wo ich mir vorstellen kann, das ich einen Fehler gemacht habe...

Hier habe ich das Auslesen des Input mit in die Schleife geschrieben und unter die Input Felder getan.....
Code:
Func _GUI3 ()
#include <GUIConstants.au3>
$GUI3 = GUICreate("Metin2 Hotscript", 400, 200)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

GUICtrlCreateLabel ("Hotkey",  10, 10)
GUICtrlSetFont (-1, 9, -1, -9)
GUICtrlCreateLabel ("Strg+1",  10, 35)
GUICtrlCreateLabel ("Strg+2",  10, 60)
GUICtrlCreateLabel ("Strg+3",  10, 85)
GUICtrlCreateLabel ("Strg+4",  10, 110)
GUICtrlCreateLabel ("Strg+5",  10, 135)

GUICtrlCreateLabel ("Account-ID",  80, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$ID1 = GUICtrlCreateInput ( "", 80,  33, 100, 20)
$ID2 = GUICtrlCreateInput ( "", 80,  58, 100, 20)
$ID3 = GUICtrlCreateInput ( "", 80,  83, 100, 20)
$ID4 = GUICtrlCreateInput ( "", 80,  108, 100, 20)
$ID5 = GUICtrlCreateInput ( "", 80,  133, 100, 20)

GUICtrlCreateLabeL ("Passwort", 200, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$Pw1 = GUICtrlCreateInput ( "", 200,  33, 100, 20)
$Pw2 = GUICtrlCreateInput ( "", 200,  58, 100, 20)
$Pw3 = GUICtrlCreateInput ( "", 200,  83, 100, 20)
$Pw4 = GUICtrlCreateInput ( "", 200,  108, 100, 20)
$Pw5 = GUICtrlCreateInput ( "", 200,  133, 100, 20)

$Speichern = GUICtrlCreateButton ("Speichern ", 10, 170)
$Abbrechen = GUICTRLCREATEBUTTON ("Abbrechen", 80, 170) 
$Pic3 = GuiCtrlCreatePic("Banner/3.jpg", 308, 10, 90, 180)
GUICtrlSetImage($Pic3, "Banner/"".jpg")
While 1
    $msg = GUIGetMsg()
	Switch $msg
		Case $Abbrechen
			GUIDelete ()
			Return (1)
If $msg = $Speichern Then
    $accountname1 = GuiCtrlRead ($Id1)
    $accountname2 = GuiCtrlRead ($Id2)
    $accountname3 = GuiCtrlRead ($Id3)
	$accountname4 = GuiCtrlRead ($Id4)
	$accountname5 = GuiCtrlRead ($Id5)
    $passwort1 = GuiCtrlRead ($Pw1)
    $passwort2 = GuiCtrlRead ($Pw2)
    $passwort3 = GuiCtrlRead ($Pw3)
	$passwort4 = GuiCtrlRead ($Pw4)
	$passwort5 = GuiCtrlRead ($Pw5)
EndIf
	Case $Beenden, $GUI_EVENT_CLOSE
	ExitLoop
	
EndSwitch

WEnd
Endfunc
Und hier könnte ich mir Vorstellen, das ich die Variable nicht einfach so senden kann, wie ich mir das vorstelle...

Code:
Func Hotkey1 ()
send $accountname1
send ("{enter}")
send $passwort1
send ("{enter}")
Endfunc
ich glaube, es liegt daran, dass du oben, wo du die variable bestimmst ein Global vor $accountname1 setzen musst
sonst wirkt sie soweit ich weiß nur in der funktion, in der sie deklariert wird!

also immer, wenn du willst, dass ne variable überall im script wirkt, ein Global vor machen
03/05/2009 18:26 Waynee#8
Also wenn ich Klammern um die Variablen mache kommt leider das gleiche bei raus :(
andere Vorschläge? ^^
03/05/2009 18:34 Waynee#9
Also ich hab das Global jetzt ma so davor gesetzt...

Code:
If $msg = $Speichern Then
    Global $accountname1 = GuiCtrlRead ($Id1)
der sagt mir aber sofort wieder das $accountname 1 den Fehler auslöst... 0o
03/05/2009 18:44 felixli93#10
müsste dann schon gehen
Global $accountname1 = GUICtrlRead ($Id1)
...

Send ($accountname1)


das "Global" brauchst du!
03/05/2009 19:25 Waynee#11
Hab alles so drinn und die Fehlermeldung is immer noch da 0o

Hier die Input Felder

Code:
$ID1 = GUICtrlCreateInput ( "", 80,  33, 100, 20)
$ID2 = GUICtrlCreateInput ( "", 80,  58, 100, 20)
$ID3 = GUICtrlCreateInput ( "", 80,  83, 100, 20)
$ID4 = GUICtrlCreateInput ( "", 80,  108, 100, 20)
$ID5 = GUICtrlCreateInput ( "", 80,  133, 100, 20)

GUICtrlCreateLabeL ("Passwort", 200, 10)
GUICtrlSetFont (-1, 9, -1, -9)
$Pw1 = GUICtrlCreateInput ( "", 200,  33, 100, 20)
$Pw2 = GUICtrlCreateInput ( "", 200,  58, 100, 20)
$Pw3 = GUICtrlCreateInput ( "", 200,  83, 100, 20)
$Pw4 = GUICtrlCreateInput ( "", 200,  108, 100, 20)
$Pw5 = GUICtrlCreateInput ( "", 200,  133, 100, 20)
Hier das Auslesen und schreiben in die Variable

Code:
If $msg = $Speichern Then
    Global $accountname1 = GuiCtrlRead ($Id1)
    Global $accountname2 = GuiCtrlRead ($Id2)
    Global $accountname3 = GuiCtrlRead ($Id3)
	Global $accountname4 = GuiCtrlRead ($Id4)
	Global $accountname5 = GuiCtrlRead ($Id5)
    Global $passwort1 = GuiCtrlRead ($Pw1)
    Global $passwort2 = GuiCtrlRead ($Pw2)
    Global $passwort3 = GuiCtrlRead ($Pw3)
	Global $passwort4 = GuiCtrlRead ($Pw4)
	Global $passwort5 = GuiCtrlRead ($Pw5)
EndIf
und hier das was er ausführen soll

Code:
Func Hotkey1 ()
send ($accountname1)
send ("{enter}")
send ($passwort1)
send ("{enter}")
Endfunc
03/05/2009 19:49 felixli93#12
welche fehlermeldung genau kommt?
03/05/2009 20:12 Waynee#13
send ($accountname1)
send (^ERROR

Error: Variable used without being declared.

Das ist die Fehlermeldung die immer kommt...
hab auch schonmal den Kompletten teiel rausgenommen...
dann kommt die gleiche Fehlermeldung mit der 2. Variable also
mit $passwort1
03/05/2009 20:38 felixli93#14
hmmm, versuch mal ganz am anfang vom script einzufügen:

Global $accountname1 = "noch nicht eingestellt"
Global $accountname2 = "noch nicht eingestell"
...


dann im GUI

$accountname1 = GuiCtrlRead ($Id1)
...

Ohne Global

versuchs dann mal

das problem ist, dass du im script die variable $accountname1 verwendest, aber der bot sie noch überhaupt nicht erstellt hat, warum auch immer
03/05/2009 20:53 Waynee#15
ok danke die Fehlermeldung kommt jetzt schonmal nicht mehr xD
aber ich denke das ich da eine kleinigkeit falsch verstanden habe....
Du sagst ich soll an den Anfang eine uneingestellte Variable stellen...
Wie mach ich das denn???

Ich hab das jetzt einfach mal so gemacht....

Code:
Global $accountname1 = ""
hierbei macht der mir nach start drücken aber einfach nur die 2 Lehrtastendrücke :P