Sajadaliraqi Posted April 25, 2020 Share Posted April 25, 2020 Hi everyone. I am new to this forum, and lately I am picking up autoit3. I am trying to develop something for my family, they need it. It is for their personal data, passports and what not. So I know a little bit, like basics, but I looked up on google and got this list. My problem with this list is, how can I make it so after exiting the program, the list saves your added items? And, how can I add a delete button to erase an item. Below is the script: It is not mine and credits goes to who made it. #include <GUIConstantsEx.au3> #include <GuiListView.au3> Opt("GUIOnEventMode", 1) MainGUI() ; ----- GUIs Func MainGUI() Global $listview $listGUI = GUICreate("AutoIt list item GUI", 400, 200, 100, 200, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main") $listview = GUICtrlCreateListView("Users", 10, 10, 200, 150) _GUICtrlListView_SetColumnWidth($listview, 0, 150) GUICtrlCreateListViewItem("First Item", $listview) GUICtrlCreateListViewItem("Second Item", $listview) GUICtrlCreateListViewItem("Third Item", $listview) $BtnAdd = GUICtrlCreateButton("Add Item", 10, 165, 80, 30) GUICtrlSetOnEvent(-1, "Addi") $BtnSelect = GUICtrlCreateButton("Select", 100, 165, 80, 30) GUICtrlSetOnEvent(-1, "SelectItem") GUISetState() While 1 Sleep(10) WEnd EndFunc ; ///// Functions Func Addi() $sToAdd = InputBox("Add", "Enter Item Name", "") GUICtrlCreateListViewItem($sToAdd, $listview) EndFunc Func SelectItem() $sItem = GUICtrlRead(GUICtrlRead($listview)) $sItem = StringTrimRight($sItem, 1) ; Will remove the pipe "|" from the end of the string MsgBox(0, "Selected Item", $sItem) EndFunc Func On_Close_Main() Exit EndFunc Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted April 25, 2020 Share Posted April 25, 2020 Hi @Sajadaliraqi, and welcome to the AutoIt forums You can use a flat file, or a SQLite DB to save your data permantly, and, to design a GUI, try to use Koda, which is in the Program Files (x86)\SciTE\Koda directory; from there, just use _GUICtrlListView_DeleteItem() to delete a specific item. Use the code <> tag when you post the code, so it doesn't mess up! faustf 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 welcome @Sajadaliraqi i think this topic can help you Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 There is nothing called coda on on that directory, can you be more clear. Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 (edited) koda you find in autoit , openscite -- tools koda fromdesign or Alt+m i suggest pin in taskbar also you find here C:\Program Files (x86)\AutoIt3\SciTE\Koda Edited April 25, 2020 by faustf Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 so, can you take a look into my list and lease make it so it saves afer exiting? I would be thankful so much Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 so depend where you want save in DB or in File txt , how to decide to proceed ? Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 What is the difference between DB and file? Let's just start by making a file, and I suppose it is going to be .ini file Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 By the way I tried installing Koda since it does not appear on my autoit. But it can only design a form I can not add buttons or design a GUI Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 for have koda i usually do this: install this 2 packet https://www.autoitscript.com/cgi-bin/getfile.pl?../autoit3/scite/download/SciTE4AutoIt3.exe https://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 I have now koda portable in a folder, but I can't seem to be able to design gui. I have a form opened but there is nothing I can add to it Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 portable ?? open scite in tools you have koda ?? Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 No, because I have Koda in a separate folder. What should I do in order to make Koda appear on Scite? Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 I have Autoit v3 installed with its editional services like scite and whatnot, but I do not find Koda on scite tools Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 install a compleate packet i send link with this you must have https://www.autoitscript.com/cgi-bin/getfile.pl?../autoit3/scite/download/SciTE4AutoIt3.exe Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 I am so sorry for getting you tired with it, I am installing Scite right now. Can you take a look into that code and help me save settings after exiting while I install the package? I really want to learn autoiit Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 i work it give me a minuts Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 I am waiting you. I installed the Scite you gave me, it has koda built in but as I told you when I start Koda, I only have something called form1. But the issue is, I do not know where I should go to add buttons or edit boxes or anything like that. Link to comment Share on other sites More sharing options...
faustf Posted April 25, 2020 Share Posted April 25, 2020 i do somthing , not save because you must do also somthing , look in help file is your firend , but best friend is google , autoi + inifilesave , for start expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <Array.au3> Opt("GUIOnEventMode", 1) Global $listview, $listview MainGUI() ; ----- GUIs Func MainGUI() $listGUI = GUICreate("AutoIt list item GUI", 400, 200, 100, 200, -1) $listview = GUICtrlCreateListView("Users", 10, 10, 200, 150) _GUICtrlListView_SetColumnWidth($listview, 0, 150) GUICtrlCreateListViewItem("First Item", $listview) GUICtrlCreateListViewItem("Second Item", $listview) GUICtrlCreateListViewItem("Third Item", $listview) $BtnAdd = GUICtrlCreateButton("Add Item", 10, 165, 80, 30) $BtnSelect = GUICtrlCreateButton("Select", 100, 165, 80, 30) GUISetState() GUISetOnEvent($GUI_EVENT_CLOSE, On_Close_Main) GUICtrlSetOnEvent($BtnSelect, SelectItem) GUICtrlSetOnEvent($BtnAdd, Addi) EndFunc ;==>MainGUI Func _SaveinFile() Local $SelectedItemIndex = -1 Local $GetCount = _GUICtrlListView_GetItemCount($listview) For $i = 0 To $GetCount - 1 $LineInfo = _GUICtrlListView_GetItemText($listview, $i) MsgBox(0, 'Info', $LineInfo) Next EndFunc ;==>_SaveinFile ; ///// Functions Func Addi() $sToAdd = InputBox("Add", "Enter Item Name", "") GUICtrlCreateListViewItem($sToAdd, $listview) EndFunc ;==>Addi Func SelectItem() $sItem = GUICtrlRead(GUICtrlRead($listview)) $sItem = StringTrimRight($sItem, 1) ; Will remove the pipe "|" from the end of the string MsgBox(0, "Selected Item", $sItem) EndFunc ;==>SelectItem Func On_Close_Main() _SaveinFile() Exit EndFunc ;==>On_Close_Main While 1 Sleep(10) WEnd i suggest read also a wiki of autoit some example you must correct for my advise when you generate a variable use suffi $aCiao a = array , $sCiao s= string i also prefer insert if is Local or Global $aLCiao or $sGCiao when you write long script you can recognize much better look the script while1 , global variable where is , and much more i hope was helpfull Link to comment Share on other sites More sharing options...
Sajadaliraqi Posted April 25, 2020 Author Share Posted April 25, 2020 Error dialog Line 14 (File "C:\Users\mnmkkk\Documents\autoit.au3"): $listGUI = GUICreate("AutoIt list item GUI", 400, 200, 100, 200, -1) ^ ERROR Error: Unable to parse line. 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