Moin moin,
hat jemand von euch ne gute Idee, was für ein Skript ich als Übung schreiben könnte?
Meine Erfahrungen mit Autoit halten sich noch in Grenzen.
Freue mich auf gute Vorschläge.
Suche Ideen
-
- [ offen ]
-
FojhtirfX -
28. April 2009 um 14:35 -
Geschlossen -
Erledigt
-
-
Durchforste doch ertsmal die Hilfe.
Da findest du hunderte Ansätze, mit denen du als Anfänger etwas anfangen kannst
Schau erstmal so in den GUI bereich, das ist so die Hauptfunktion von AutoIt, bzw. das was am meisten benutzt wird.
-
wie wäre es mit einem kleinen spiel ?
bsp. : Wer wird Millionär ?
Fragen :
-In einer Ini abspeichern
Joker :- 50:50
- Publikum
- Anrufen
Ich weiß nicht wie du dich mit AutoIt auskennst also weiß ich nicht ob das für dich ein angemessenes Projekt ist.
Falls du Hilfe brauchst kannst du dich gerne melden.mfg nof@ker
-
Das hört sich ganz gut an, schätze, dass ich das hinbekomme.
Warum soll man Daten (Fragen) in einer .ini speichern und nicht einfach in einer .txt?
Kann man die besser auslesen? -
Hab das mit der ini jetz kapiert...
-
Hab das mit der ini jetz kapiert...
Nur, dass mit dem Editbutton hastu noch nich so drauf ;P
Also ich hab mir das meißte von Autoit so beigebracht, dass ich mir einfach im deutschem und eglischem Forum die fertigen Scripte angesehen hab und dann versucht diese zu verstehen und zu verbessern..
-
Ich hab so angefangen:
Mir die Deutsche Hilfe runtergeladen.
Dann erstmal so über den Index geflogen.Dann hab ich mir etwas ausgesucht, was mir net ganz so schwer vorkam.
Nun hab ich versucht, die fertigen Beispiel scripts aus der Hilfe zu erweitern,
etwas neues hinzuzufügen, gucken, was man brauch und was net...Das hab ich dann immer so vortgesetzt...
-
So, hab mal ein bisschen angefangen, hab aber ein Problem: Wie mach ich das, dass wenn die erste Frage richtig beantwortet wurde, die Zufallsvariabel (die für die Auswhl der Frage zuständig ist) neu generiert wird? Sonst kommt ja immer wieder dieselbe Frage.
Ach ja, so wies jetz ist, meint der immer : Wend staement has no matching while statement.Spoiler anzeigen
[autoit]#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
[/autoit] [autoit][/autoit] [autoit]
Author: FrithjofScript Function:
[/autoit] [autoit][/autoit] [autoit]
Ein Quiz.#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#include <GUIConstants.au3>
[/autoit] [autoit][/autoit] [autoit]$Zufall = Random(1,2,1)
[/autoit] [autoit][/autoit] [autoit]$Frage = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 1, "Frage1" , "Nicht Gefunden")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$Antwort1 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 2, "Antwort1" , "Nicht Gefunden")
[/autoit] [autoit][/autoit] [autoit]
$Antwort2 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 3, "Antwort2" , "Nicht Gefunden")
$Antwort3 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 4, "Antwort3" , "Nicht Gefunden")
$Antwort4 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 5, "Antwort4" , "Nicht Gefunden")$richtig = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 6, "Lösung" , "Nicht Gefunden")
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]#Region ### START Koda GUI section ### Form= ;Grafische Oberfläche
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]
$Form1 = GUICreate("Wer wird Millionär", 633, 447, 193, 125)
$Label1 = GUICtrlCreateLabel("Frage:"& $Frage, 152, 32, 316, 57)
$Button1 = GUICtrlCreateButton($Antwort1, 144, 192, 129, 49, 0)
$Button2 = GUICtrlCreateButton($Antwort2, 344, 192, 129, 49, 0)
$Button3 = GUICtrlCreateButton($Antwort3, 144, 264, 129, 49, 0)
$Button4 = GUICtrlCreateButton($Antwort4, 344, 264, 129, 49, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###While 1
[/autoit] [autoit][/autoit] [autoit]
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $nMsg <> 0
EndSwitch
Select
Case $nMsg = $Button1
If $richtig <> 2 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1) ;runde 1
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button2
If $richtig <> 3 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button3
If $richtig <> 4 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button4
If $richtig <> 5 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!") ;runde 2
EndIf
EndSelect
$Zufall = Random(1,2,1)Select
[/autoit] [autoit][/autoit] [autoit]
Case $nMsg = $Button1
If $richtig <> 2 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1) ;runde 1
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button2
If $richtig <> 3 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button3
If $richtig <> 4 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!")
EndIf
Case $nMsg = $Button4
If $richtig <> 5 Then
MsgBox(0,"Falsch", "richtig wäre:" & $richtig -1)
Else
MsgBox(0,"Super", "Sie haben richtig getippt!!!") ;runde 2
EndIfWEnd
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] -
ich verstehe dein problem nicht ganz ...
[autoit]
eine Zufallszahl kannst du ja einfach überschreiben$ErsteZahl=Random(1,6,1)
[/autoit]
MsgBox(0,"",$ErsteZahl)
$ErsteZahl=Random(1,6,1)
MsgBox(0,"",$ErsteZahl)
So verändert sich die Zufallszahl falls du das gemeint hastmfg nof@ker
-
FojhtirfX komm mal ICQ online. Habe auch ein wenig angefangen mit dem Spiel, vielleicht können wir ja zusammen ein wenig rumbasteln.
-
Ehm hab das mal n bisschen umgeschrieben, konnte es aber nicht wirklich testen..
Hoffe es ist soweit nachvollziehbarSpoiler anzeigen
[autoit]#cs ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]AutoIt Version: 3.3.0.0
[/autoit] [autoit][/autoit] [autoit]
Author: FrithjofScript Function:
[/autoit] [autoit][/autoit] [autoit]
Ein Quiz.#ce ----------------------------------------------------------------------------
[/autoit] [autoit][/autoit] [autoit]; Script Start - Add your code below here
[/autoit] [autoit][/autoit] [autoit]#include <GUIConstantsEx.au3>
[/autoit] [autoit][/autoit] [autoit]
Opt ("GuiOnEventMode",1)
Global $Frage, $Antwort1, $Antwort2, $Antwort3, $Antwort4, $richtig#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit]
$Form1 = GUICreate("Wer wird Millionär", 633, 447, 193, 125)
GuiSetOnEvent($GUI_EVENT_CLOSE, "Terminate")
$Label1 = GUICtrlCreateLabel("Frage:", 152, 32, 316, 57)
$Button1 = GUICtrlCreateButton("", 144, 192, 129, 49, 0)
GuiCtrlSetOnEvent(-1, "result")
$Button2 = GUICtrlCreateButton("", 344, 192, 129, 49, 0)
GuiCtrlSetOnEvent(-1, "result")
$Button3 = GUICtrlCreateButton("", 144, 264, 129, 49, 0)
GuiCtrlSetOnEvent(-1, "result")
$Button4 = GUICtrlCreateButton("", 344, 264, 129, 49, 0)
GuiCtrlSetOnEvent(-1, "result")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###While 1
[/autoit] [autoit][/autoit] [autoit]
sleep(100)
WEndFunc SetQuestions()
[/autoit] [autoit][/autoit] [autoit]
$Zufall = Random(1,2,1)
$Frage = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 1, "Frage1" , "Nicht Gefunden")
$Antwort1 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 2, "Antwort1" , "Nicht Gefunden")
$Antwort2 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 3, "Antwort2" , "Nicht Gefunden")
$Antwort3 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 4, "Antwort3" , "Nicht Gefunden")
$Antwort4 = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 5, "Antwort4" , "Nicht Gefunden")
$richtig = IniRead("C:\Dokumente und Einstellungen\Frithjof\Desktop\fragen"& $zufall & ".ini", 6, "Lösung" , "Nicht Gefunden")
GuiCtrlSetData($Label1, $Frage)
GuiCtrlSetData($Button1, $Antwort1)
GuiCtrlSetData($Button2, $Antwort2)
GuiCtrlSetData($Button3, $Antwort3)
GuiCtrlSetData($Button4, $Antwort4)
EndFuncFunc result()
[/autoit] [autoit][/autoit] [autoit]
Switch @GUI_CtrlId
Case 4;Button 1
If $Antwort1 = $richtig Then
MsgBox(0,"Info!", "Die Antwort ist richtig!")
Else
MsgBox(0,"Info!", "Die Antwort ist falsch!")
EndIf
Case 5
If $Antwort2 = $richtig Then
MsgBox(0,"Info!", "Die Antwort ist richtig!")
Else
MsgBox(0,"Info!", "Die Antwort ist falsch!")
EndIf
Case 6
If $Antwort3 = $richtig Then
MsgBox(0,"Info!", "Die Antwort ist richtig!")
Else
MsgBox(0,"Info!", "Die Antwort ist falsch!")
EndIf
Case 7;Button 4
If $Antwort4 = $richtig Then
MsgBox(0,"Info!", "Die Antwort ist richtig!")
Else
MsgBox(0,"Info!", "Die Antwort ist falsch!")
EndIf
EndSwitch
SetQuestions()
EnDFuncFunc Terminate()
[/autoit]
Exit
EndFunc -
Meine version sieht bis jetzt so aus
Spoiler anzeigen
[autoit]#include <EditConstants.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <GUIConstantsEx.au3>;Variablen deklarierung
[/autoit] [autoit][/autoit] [autoit]
Global $ini = @ScriptDir & "\Daten.ini", $splash = @ScriptDir & "\Millionär.jpg", $bkgr = @ScriptDir & "\a.jpg", $var = IniReadSection(@ScriptDir & "\Daten.ini", "Fragen")
Global $Antwort[5],$a
;<==;Splash
[/autoit] [autoit][/autoit] [autoit]
SplashImageOn("", $splash, 320, 322, -1, -1, 1)
Sleep(1500)
SplashOff()
;<==;Main Gui
[/autoit] [autoit][/autoit] [autoit]
GUICreate("Wer wird Millionär", 631, 378)
GUICtrlCreatePic($bkgr, 0, 0, 631, 378)
GUISetFont(15)
$Frage = GUICtrlCreateEdit("", 50, 235, 390, 47, $ES_READONLY, 0) ;Feld für Frage
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Antwort[1] = GUICtrlCreateLabel("", 63, 300, 150, 23) ;Feld für Antwort A
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Antwort[2] = GUICtrlCreateLabel("", 63, 337, 150, 23) ;Feld für Antwort B
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Antwort[3] = GUICtrlCreateLabel("", 295, 300, 150, 23) ;Feld für Antwort C
GUICtrlSetBkColor(-1, 0xFFFFFF)
$Antwort[4] = GUICtrlCreateLabel("", 295, 337, 150, 23) ;Feld für Antwort D
GUICtrlSetBkColor(-1, 0xFFFFFF)$question = Random(1, UBound($var) - 1, 1) ;Zufällige Frage
[/autoit] [autoit][/autoit] [autoit]$str = StringSplit($var[$question][1], '-', 1) ;Antworten splitten
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($Frage, $var[$question][0]) ;Frage Nr. 1For $i = 1 To 4
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($Antwort[$i], $str[$i]) ;Antwortmöglichkeiten zu Frage Nr. 1
NextGUISetState()
[/autoit] [autoit][/autoit] [autoit]Switch $str[5]
[/autoit] [autoit][/autoit] [autoit]Case 1
[/autoit] [autoit][/autoit] [autoit]
$a = "A"
Case 2
$a = "B"
Case 3
$a = "C"
Case 4
$a = "D"
EndSwitchMsgBox(0,"Richtige Antwort","Richtige antwort ist " & $a)
[/autoit] [autoit][/autoit] [autoit]
;<==;Mainloop
[/autoit]
While 1
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
$close = MsgBox(4, "Wirklich Beenden?", "Wollen sie wirklich aufhören?")
Switch $close
Case 6
Exit
EndSwitch
EndSwitch
WEnd
;<==Edit: Habs jetzt nen bisschen verändert... nur leider komme ich nicht weiter im moment
@FojhtirfX add mich mal ICQ (261461364) dann können wa zusammen bisschen was machenEdit2: So, kann mir wer helfen ? Ich bräuchte etwas, das einen Mausklick auf ein Label regestriert. Dann lege ich ein Transparentes Label auf die Antwortmöglichkeiten, und wenn sie gedrückt werden, dann soll entweder Richtig oder Falsch kommen
-
Alter schwede, hier bekommt man ja verdammt schnell Hilfe!!! echt super
-
So, habe es jetzt soweiter erst einmal zum Funktionieren bekommen. Wer mal Lust hat es zu Spielen hier derDownloadlink
und hier der SourceCode: (Noch unsauber aber das mache ich morgen -.-)
Spoiler anzeigen
[autoit]#include <StaticConstants.au3>
[/autoit] [autoit][/autoit] [autoit]
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>;Variablen deklarierung
[/autoit] [autoit][/autoit] [autoit]
Global $ini = @ScriptDir & "\Daten.ini", $splash = @ScriptDir & "\Millionär.jpg", $bkgr = @ScriptDir & "\a.jpg", $var = IniReadSection(@ScriptDir & "\Daten.ini", "Fragen")
Global $Antwort[5], $e, $question, $str, $y = 315, $Euro = "0 Euro"
;<==If $var = 1 Then
[/autoit] [autoit][/autoit] [autoit]
MsgBox(0, "Fehler", "Datei 'Daten.ini konnte nicht gelesen werden." & @CRLF & "Bitte überprüfen Sie, ob sich die Datei im Ordner Befindet.")
Exit
EndIf;Splash
[/autoit] [autoit][/autoit] [autoit]
SplashImageOn("", $splash, 320, 322, -1, -1, 1)
Sleep(1500)
SplashOff()
;<==;Main Gui
[/autoit] [autoit][/autoit] [autoit]
GUICreate("Wer wird Millionär", 631, 378)
GUICtrlCreatePic($bkgr, 0, 0, 631, 378)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetFont(15)
$Frage = GUICtrlCreateEdit("", 50, 235, 390, 47, $ES_READONLY, 0) ;Feld für Frage
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetFont(12)
$Antwort[1] = GUICtrlCreateLabel("", 63, 300, 155, 23) ;Feld für Antwort A
GUICtrlSetBkColor(-1, 0xFFFFFF)
$A = GUICtrlCreateLabel("", 30, 294, 195, 37) ;Soll auf Klick reagieren
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_ONTOP)
$Antwort[2] = GUICtrlCreateLabel("", 63, 337, 155, 23) ;Feld für Antwort B
GUICtrlSetBkColor(-1, 0xFFFFFF)
$B = GUICtrlCreateLabel("", 30, 331, 195, 37) ;Soll auf Klick reagieren
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_ONTOP)
$Antwort[3] = GUICtrlCreateLabel("", 295, 300, 155, 23) ;Feld für Antwort C
GUICtrlSetBkColor(-1, 0xFFFFFF)
$C = GUICtrlCreateLabel("", 262, 294, 195, 37) ;Soll auf Klick reagieren
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_ONTOP)
$Antwort[4] = GUICtrlCreateLabel("", 295, 337, 155, 23) ;Feld für Antwort D
GUICtrlSetBkColor(-1, 0xFFFFFF)
$D = GUICtrlCreateLabel("", 262, 331, 195, 37) ;Soll auf Klick reagieren
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetState(-1, $GUI_ONTOP)
GUISetFont(20)
$Geld = GUICtrlCreateLabel("X", 505, $y)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)_Next()
[/autoit] [autoit][/autoit] [autoit]GUISetState()
[/autoit] [autoit][/autoit] [autoit];Mainloop
[/autoit] [autoit][/autoit] [autoit]
While 1
Local $l
$Msg = GUIGetMsg()
Switch $Msg
Case $GUI_EVENT_CLOSE
$close = MsgBox(4, "Wirklich Beenden?", "Wollen sie wirklich aufhören?")
Switch $close
Case 6
Exit
EndSwitch
Case $A
$l = 1
If $l = $str[5] Then
_Geld()
$y -= 20
_Next()
GUICtrlSetPos($Geld, 505, $y)
Else
MsgBox(0, "Falsch", "Antwort A ist leider falsch, die richtige Lösung wäre " & $e & " gewesen.")
_NewGame()
EndIf
Case $B
$l = 2
If $l = $str[5] Then
_Geld()
$y -= 20
_Next()
GUICtrlSetPos($Geld, 505, $y)
Else
MsgBox(0, "Falsch", "Antwort B ist leider falsch, die richtige Lösung wäre " & $e & " gewesen.")
_NewGame()
EndIf
Case $C
$l = 3
If $l = $str[5] Then
_Geld()
$y -= 20
_Next()
GUICtrlSetPos($Geld, 505, $y)
Else
MsgBox(0, "Falsch", "Antwort C ist leider falsch, die richtige Lösung wäre " & $e & " gewesen.")
_NewGame()
EndIf
Case $D
$l = 4
If $l = $str[5] Then
_Geld()
$y -= 20
_Next()
GUICtrlSetPos($Geld, 505, $y)
Else
MsgBox(0, "Falsch", "Antwort D ist leider falsch, die richtige Lösung wäre " & $e & " gewesen.")
_NewGame()
EndIf
EndSwitch
WEnd
;<==Func _Next()
[/autoit] [autoit][/autoit] [autoit]
$question = Random(1, UBound($var) - 1, 1) ;Zufällige Frage$str = StringSplit($var[$question][1], '-', 1) ;Antworten splitten
[/autoit] [autoit][/autoit] [autoit]
;~ If @error Then _Next()
GUICtrlSetData($Frage, $var[$question][0]) ;Frage Nr. 1For $i = 1 To 4
[/autoit] [autoit][/autoit] [autoit]
GUICtrlSetData($Antwort[$i], $str[$i]) ;Antwortmöglichkeiten zu Frage Nr. 1
NextSwitch $str[5]
[/autoit] [autoit][/autoit] [autoit]
Case 1
$e = "A"
Case 2
$e = "B"
Case 3
$e = "C"
Case 4
$e = "D"
EndSwitch
EndFunc ;==>_NextFunc _Geld()
[/autoit] [autoit][/autoit] [autoit]
Switch $y
Case 315
$Euro = "100 Euro"
Case 295
$Euro = "200 Euro"
Case 275
$Euro = "200 Euro"
Case 255
$Euro = "500 Euro"
Case 235
$Euro = "1.000 Euro"
Case 215
$Euro = "2.000 Euro"
Case 195
$Euro = "4.000 Euro"
Case 175
$Euro = "8.000 Euro"
Case 155
$Euro = "16.000 Euro"
Case 135
$Euro = "32.000 Euro"
Case 115
$Euro = "64.000 Euro"
Case 95
$Euro = "125.000 Euro"
Case 75
$Euro = "250.000 Euro"
Case 55
$Euro = "500.000 Euro"
Case Else
MsgBox(0, "Richtig", "Glückwunsch, Sie haben 1 Milion Euro Gewonnen!!!!")
_NewGame()
EndSwitch
MsgBox(0, "Richtig", "Glückwunsch, Sie haben " & $Euro & " bis jetzt.")
EndFunc ;==>_GeldFunc _NewGame()
[/autoit]
GUICtrlSetData($Frage, "")
$y = 315
GUICtrlSetPos($Geld, 505, $y)
For $i = 1 To 4
GUICtrlSetData($Antwort[$i], "")
Next
$New = MsgBox(4, "Neues Spiel?", "Möchten sie ein neues Spiel beginnen?")
Switch $New
Case 6
_Next()
Case 7
Exit
EndSwitch
EndFunc ;==>_NewGameEdit: Source ein wenig angepasst. Im Downloadlink aber nicht!!! Also Leute Copy & Paste
mfg SiLenCa