Jump to content

Bomi

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by Bomi

  1. I surrender, you have destroyed my plan for world domination! Alas, now I am forced to cross out mind reading from my list!
  2. ;Quizzz Vers 2.0 #include <GUIConstants.au3> $QuizzGui = GUICreate("Quiz GUI", 250, 500) $Question = GUICtrlCreateLabel("RawrRawr", 10, 10) ; Different types of GUI stuff: $button = GUICtrlCreateButton( "This is a button | o", 10, 10, 240, 22 ) $checkboxTxt = "This is a checkbox" ;This is used for submission purposes $checkbox = GUICtrlCreateCheckbox( $checkboxTxt, 10, 40 ) $input = GUICtrlCreateInput( "Enter something", 10, 70, 200) $inputOK = GUICtrlCreateButton( "ok", 210, 70, 30, 22 ) ; +Submit Button $Submit = GUICtrlCreateButton( "This is a submit button", 10, 100, 240, 22 ) GUISetState() ;Showtime ;Funky Func btn_toggle($hBtn, $sTrue, $sFalse) If GUICtrlRead($hBtn) = $sTrue Then GUICtrlSetData($hBtn, $sFalse) Else GUICtrlSetData($hBtn, $sTrue) EndIf EndFunc Func input_toggle($hInput, $hBtn, $sTrue, $sFalse) If GUICtrlRead($hBtn) = $sTrue Then GUICtrlSetData($hBtn, $sFalse) GUICtrlSetState( $hInput, $GUI_DISABLE ) Else GUICtrlSetData($hBtn, $sTrue) GUICtrlSetState( $hInput, $GUI_ENABLE ) EndIf EndFunc Func SubmitFunction() local $iniString ;Button If GUICtrlRead($button) = "This is a button | x" Then ; 1 is hooked, 4 is not If Not $iniString = "" Then $iniString &= ", " $iniString &= GUICtrlRead($button) EndIf #CS ;Alternatly, save the button text as is. clicked or not If Not $iniString = "" Then $iniString &= ", " $iniString &= GUICtrlRead($button) #CE ;Checkbox If GUICtrlRead($checkbox) = 1 Then ; 1 is hooked, 4 is not If Not $iniString = "" Then $iniString &= ", " $iniString &= $checkboxTxt EndIf ;Input If GUICtrlRead($inputOK) = "edit" Then ;Means 'ok' was pressed If Not $iniString = "" Then $iniString &= ", " $iniString &= GUICtrlRead($input) EndIf ;Note: the above could easily be converted into a function IniWrite("save.ini", "section z", "Bomi (An)swe(a)rs", $iniString) MsgBox(0, "RAWR", IniRead("save.ini", "section z", "Bomi (An)swe(a)rs", "Reading save.ini failed!")) Exit EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $button Then btn_toggle($button, "This is a button | o", "This is a button | x") ElseIf $msg = $inputOK Then input_toggle($input, $inputOK, "ok", "edit") ElseIf $msg = $Submit Then SubmitFunction() EndIf WEnd This was(/is?) a fun challenge. Did i get it right this time? I beg to differ. Although mind reading over distance can be quite difficult
  3. ;Quizzzz #include <GUIConstants.au3> $QuizzGui = GUICreate("Quiz GUI", 250, 500) $Question = GUICtrlCreateLabel("Select the four first letter in the alphabet,\n but not the third one", 10, 10) dim $Box [6] ;Box[0] isnt used because of ini read/write works best with this blank (used for other values) $Box[1] = GUICtrlCreateCheckbox("A", 10, 40) ;correct $Box[2] = GUICtrlCreateCheckbox("B", 10, 70) ;correct $Box[3] = GUICtrlCreateCheckbox("C", 10, 100) ;incorrect $Box[4] = GUICtrlCreateCheckbox("D", 10, 130) ;correct $Box[5] = GUICtrlCreateCheckbox("E", 10, 160) ;incorrect $Submit = GUICtrlCreateButton("Submit", 10, 190, 240) GUISetState() Func SubmitFunction() Dim $BoxArray[6][2] ;[6] answers [2] data types (key/value) Local $i = 1 While $i < 6 $BoxArray[$i][0] = "Checkbox_"&$i $BoxArray[$i][1] = GUICtrlRead($Box[$i]) $i += 1 WEnd IniWriteSection("Save.ini", "AnswerQuestion1", $BoxArray) MsgBox(0, "Answers Submited", "Answers have been stored!") $IniReadTmp = IniReadSection("Save.ini", "AnswerQuestion1") ;Reads the whole section into a 2d array. E.g. $Array[1][1]. Where [0][0] is the number of keys/values Local $i = 1 $sTmpOut = "" Do ;/Loop $sTmpOut &= $IniReadTmp[$i][0]&" = "&$IniReadTmp[$i][1]&@CRLF ; $s &= "abc" is the same as $s = $s & "abc". @CRLF is linebreak $i += 1 Until $i > $IniReadTmp[0][0] ; Number of keys/values MsgBox(0, "Ini", $sTmpOut) Exit EndFunc While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit ElseIf $msg = $Submit Then SubmitFunction() EndIf WEndoÝ÷ Ù¬º[l{ayú%"âéÚè§Ç¶*'Öl{ On the other hand will result in: [section1] myKey = sometihin myKey2 = something completly different Regards, Eivin
  4. The short answer to your question is: Yes! The long and slightly more complex answer is: Yes, you would be able to do this if you are willing to do a bit of reading and put a bit of effort into it.
  5. While 1 if $msg = $button1 then if IniRead("log.ini", "section2", "key", "") = "button2" Then IniWrite("log.ini", "section2", "key", "button1button2") ElseIf IniRead("log.ini", "section2", "key", "") = "button1button2" Then ;do whatever Else IniWrite("log.ini", "section2", "key", "button1") EndIf EndIf else if $msg = $button2 then if IniRead("log.ini", "section2", "key", "") = "button1" Then IniWrite("log.ini", "section2", "key", "button1button2") ElseIf IniRead("log.ini", "section2", "key", "") = "button1button2" Then ;do whatever Else IniWrite("log.ini", "section2", "key", "button2") EndIf EndIf Sleep(100) WEnd I guess? I fail to see how this is useful. Explain?
  6. Goodie I've been looking for something like this
×
×
  • Create New...