L3G3NdKillEr Posted September 29, 2007 Share Posted September 29, 2007 (edited) hi everyone, i make a button presses counter and save into ini. how to read last value of ini to put in label. #include <GuiConstants.au3> #include <File.au3> #include <misc.au3> HotKeySet("5", "khurram") Global $i = 0 global $j = 0 Opt("Guioneventmode", 1) $gui = GUICreate("", 640, 451) $label = GUICtrlCreateLabel("coins: ", 0, 0, 200, 200) GUICtrlSetFont($label, 18, 400, "", "Arial") $label1 = GUICtrlCreateLabel("Total: ", 200, 0, 200, 200) GUICtrlSetFont($label1, 18, 400, "", "Arial") GUISetState(@SW_SHOW) while 1 Sleep(50) WEnd Func khurram() $iniopen = 'C:\temp\myfile.ini' $i +=1 $read = IniReadSection($iniopen, "Section2") $bound = UBound($read) + 1 $read2 = IniReadSection($iniopen, "Section2") IniWrite($iniopen, "Section2", "total= ", $bound) EndFunc Edited September 29, 2007 by L3G3NdKillEr i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================> Link to comment Share on other sites More sharing options...
Valuater Posted September 29, 2007 Share Posted September 29, 2007 A similar question i answered 2 days ago expandcollapse popup#include <GUIConstants.au3> Global $start Global $way1x, $way1y $showGUI = 0 ; setting the GUI condition HotKeySet("{F6}", "show") ; using hotkey to show menu Read() GUICreate("Testscript", 300, 420) $savebotbutt = GUICtrlCreateButton("Save", 160, 390, 60, 30) ; show the Save button $exitbotbutt = GUICtrlCreateButton("Exit", 220, 390, 80, 30) ; show the Exit button GUICtrlCreateTab(0, 0, 300, 390) $tab2 = GUICtrlCreateTabItem("WayPoints") GUICtrlCreateLabel("Training Ground Location", 10, 30, 200, 20) $checkCN = GUICtrlCreateCheckbox("", 20, 50, 20, 20) ; 1st checkbox location GUICtrlCreateLabel("X : ", 60, 50, 15, 20) ;~ $way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1")) $input_x = GUICtrlCreateInput($way1x, 80, 50, 50, 20) GUICtrlCreateLabel("Y : ", 150, 50, 15, 20) ;~ $way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1")) $input_y = GUICtrlCreateInput($way1y, 170, 50, 50, 20) GUISetState(@SW_HIDE) While 1 ; main body of program, loop till condition met $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; when the top right cancel button is pressed Exit Case $msg = $savebotbutt ; pressing the Save button Write() MsgBox(64, "Test Box", "You clicked on Save!") Case $msg = $exitbotbutt ; pressing the Exit button Exit EndSelect WEnd ;;-------------------------------------- Functions -------------------------------- Func show() If $showGUI = 0 Then Read() GUISetState(@SW_SHOW) ; show the menu when hotkey pressed $showGUI = 1 Else GUISetState(@SW_HIDE) ; hide the menu when hotkey pressed $showGUI = 0 EndIf EndFunc ;==>show Func Write() IniWrite(".\testscript.ini", "Waypoints", "1x", GUICtrlRead($input_x)) IniWrite(".\testscript.ini", "Waypoints", "1y", GUICtrlRead($input_y)) EndFunc ;==>Write Func Read() $way1x = Int(IniRead(".\testscript.ini", "Waypoints", "1x", "-1")) $way1y = Int(IniRead(".\testscript.ini", "Waypoints", "1y", "-1")) EndFunc ;==>Read 8) Link to comment Share on other sites More sharing options...
8879899714 Posted October 9, 2007 Share Posted October 9, 2007 hi Valuater, i added the read and write for the checkbox. but everytime when i save a checked box, the value in the file is always "0", any idea? or is it that i have done it the wrong way? A similar question i answered 2 days ago expandcollapse popup#include <GUIConstants.au3> Global $start Global $way1x, $way1y $showGUI = 0 ; setting the GUI condition HotKeySet("{F6}", "show") ; using hotkey to show menu Read() GUICreate("Testscript", 300, 420) $savebotbutt = GUICtrlCreateButton("Save", 160, 390, 60, 30) ; show the Save button $exitbotbutt = GUICtrlCreateButton("Exit", 220, 390, 80, 30) ; show the Exit button GUICtrlCreateTab(0, 0, 300, 390) $tab2 = GUICtrlCreateTabItem("WayPoints") GUICtrlCreateLabel("Training Ground Location", 10, 30, 200, 20) $checkCN = GUICtrlCreateCheckbox("", 20, 50, 20, 20) ; 1st checkbox location GUICtrlCreateLabel("X : ", 60, 50, 15, 20) ;~ $way1x = Int(IniRead(".\testscript.ini","Waypoints","1x","-1")) $input_x = GUICtrlCreateInput($way1x, 80, 50, 50, 20) GUICtrlCreateLabel("Y : ", 150, 50, 15, 20) ;~ $way1y = Int(IniRead(".\testscript.ini","Waypoints","1y","-1")) $input_y = GUICtrlCreateInput($way1y, 170, 50, 50, 20) GUISetState(@SW_HIDE) While 1 ; main body of program, loop till condition met $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ; when the top right cancel button is pressed Exit Case $msg = $savebotbutt ; pressing the Save button Write() MsgBox(64, "Test Box", "You clicked on Save!") Case $msg = $exitbotbutt ; pressing the Exit button Exit EndSelect WEnd ;;-------------------------------------- Functions -------------------------------- Func show() If $showGUI = 0 Then Read() GUISetState(@SW_SHOW) ; show the menu when hotkey pressed $showGUI = 1 Else GUISetState(@SW_HIDE) ; hide the menu when hotkey pressed $showGUI = 0 EndIf EndFunc ;==>show Func Write() IniWrite(".\testscript.ini", "Waypoints", "1x", GUICtrlRead($input_x)) IniWrite(".\testscript.ini", "Waypoints", "1y", GUICtrlRead($input_y)) IniWrite(".\testscript.ini", "Waypoints", "1y", GUICtrlRead($checkCN)) EndFunc ;==>Write Func Read() $way1x = Int(IniRead(".\testscript.ini", "Waypoints", "1x", "-1")) $way1y = Int(IniRead(".\testscript.ini", "Waypoints", "1y", "-1")) $checkCN = Int(IniRead(".\testscript.ini", "Waypoints", "1y", "-1")) EndFunc ;==>Read 8) Link to comment Share on other sites More sharing options...
8879899714 Posted October 9, 2007 Share Posted October 9, 2007 hi, sorry about this post, saw the your example in the GUI thread. thanks. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now