Hi i have big ini and i have problem with searching data in it.
My script is need to:
open ini
search items i write in search field
put in list items that it founded
when i click on item it need to show up in edit field
But mine main problem is that i can't get all items in my list like here , because ini have multiple items with same name like, Blode ring, Blode ring, Blode ring, Briliant blode ring, Inteligent blode ring, Glorious blode ring so i need to get them all on my listbox so i can choose what to edit.
I tried to convert it to .txt and .ini but didn't end up with any positive results.
here is ini file
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#Region ### START Koda GUI section ###
$hGUI = GUICreate("Form1", 684, 364, 607, 439)
GUICtrlCreateGroup(" Search ", 8, 16, 342, 297)
GUICtrlCreateLabel("Search for text", 22, 40, 73, 17)
$hSearchInput = GUICtrlCreateInput("", 23, 60, 185, 21)
$hFinddAllButton = GUICtrlCreateButton("Find All", 222, 58, 75, 25)
GUICtrlCreateLabel("Found Items ( click to edit )", 22, 102, 131, 17)
$hList = GUICtrlCreateList("", 22, 120, 313, 175)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Edit Item", 355, 16, 321, 137)
GUICtrlCreateLabel("Name", 372, 40, 32, 17)
$hNameInput = GUICtrlCreateInput("", 371, 60, 289, 21)
$hSaveButton = GUICtrlCreateButton("Save", 587, 112, 75, 25)
GUICtrlCreateLabel("Item ID", 372, 95, 38, 17)
$hItemID = GUICtrlCreateInput("", 369, 112, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hOpenIniButton = GUICtrlCreateButton("Open INI for Edit", 8, 328, 105, 25)
$hWriteIniButton = GUICtrlCreateButton("Write Modified INI", 123, 328, 105, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $file, $sFile
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hOpenIniButton
_FileOpen()
Case $hFinddAllButton
$sRead = GUICtrlRead($hSearchInput) ; input field for search
$oFile = FileReadToArray($file)
For $i = 0 To UBound($oFile) - 1 ; Loop through the array.
GUICtrlSetData($hList, "Results = " & $oFile[$i] & @CRLF) ; Display the contents of the array.
Next
EndSwitch
WEnd
; open file
Func _FileOpen()
Global $file = FileOpenDialog("Open INI for edit", "", "INI file (*.txt)")
If FileExists($file) Then
$sFile = FileOpen($file)
If @error Then
MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended)
Else
GUICtrlSetState($hOpenIniButton, $GUI_DISABLE)
EndIf
Else
MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended)
EndIf
EndFunc
And if u ask me why i dont use ini read or ini read section names its because of this, this is all section numbers
Don't use textiles at all, use binary files.
You could use this kind of file format:
Header:
ItemCount (4 Byte) then for every item the Position (4 Byte) in the file.
Then begins the content:
For each ITEM:
ID (4Byte)
LengthOfName (4 Byte)
Name (LengthOfName Byte)
Other stuff
Other Stuff
This format is easy to read, you don't need to load the complete list into the memory to process it but its a bit difficult to write
Don't use textiles at all, use binary files.
You could use this kind of file format:
Header:
ItemCount (4 Byte) then for every item the Position (4 Byte) in the file.
Then begins the content:
For each ITEM:
ID (4Byte)
LengthOfName (4 Byte)
Name (LengthOfName Byte)
Other stuff
Other Stuff
This format is easy to read, you don't need to load the complete list into the memory to process it but its a bit difficult to write
Working in memory is allways better, than working in the filesystem (Memory>HDD). Even when you're working with files, larger than your physical memory, you should try to read as big as possible parts of the file and handle it in the memory.
Beside that, Autoit is extremely slow in File-Operations (especially Binary-Operations).
Working in memory is allways better, than working in the filesystem (Memory>HDD). Even when you're working with files, larger than your physical memory, you should try to read as big as possible parts of the file and handle it in the memory.
of course memory is faster, but if you have a program that needs only to load one Item at the time, why should you read all the file at once? Lets say the file is about 600 MB big, i don't want to waste 600MB of my Memory on something i might not even need to load. That this is faster was more about string Processing, because running through the whole text for every single Item is pretty much waste of Processor Time, and you can still load all Items into an Array (or something like this) than working on Memory with binary data is way faster than everything working text based
@lokop u see results on yours example
so there is only 5 "Blode Ring" this works fine
This ini file its not mine, its from the game that contains data like droping items, so i need to edit them, but problem is that ini is 16 mb big and there is like few items with same name like
- Blode ring
- Inteligent Blode Ring
- Briliant Blode Ring
- Glorious Blode Ring
So i need to change only Blode Ring not inteligent, briliant, glorious rows
I edit code a bit but still i can read only small ini files but not big
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Array.au3>
#include <FileConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ###
$hGUI = GUICreate("INI Editor", 684, 364, 607, 439)
GUICtrlCreateGroup(" Search ", 8, 16, 342, 297)
GUICtrlCreateLabel("Search for text", 22, 40, 73, 17)
$hSearchInput = GUICtrlCreateInput("", 23, 60, 185, 21)
$hFinddAllButton = GUICtrlCreateButton("Find All", 222, 58, 75, 25)
GUICtrlCreateLabel("Found Items ( click to edit )", 22, 102, 131, 17)
;~ $hList = GUICtrlCreateList("", 22, 120, 313, 175)
$hList = GUICtrlCreateListView("", 22, 120, 313, 175)
; Add columns
_GUICtrlListView_InsertColumn($hList, 0, "ID", 50)
_GUICtrlListView_InsertColumn($hList, 1, "Item name", 350)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup(" Edit Item", 355, 16, 321, 137)
GUICtrlCreateLabel("Name", 372, 40, 32, 17)
$hNameInput = GUICtrlCreateInput("", 371, 60, 289, 21)
$hSaveButton = GUICtrlCreateButton("Save", 587, 112, 75, 25)
GUICtrlCreateLabel("Item ID", 372, 95, 38, 17)
$hItemID = GUICtrlCreateInput("", 369, 112, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER,$ES_READONLY))
GUICtrlCreateGroup("", -99, -99, 1, 1)
$hOpenIniButton = GUICtrlCreateButton("Open INI for Edit", 8, 328, 105, 25)
$hWriteIniButton = GUICtrlCreateButton("Write Modified INI", 123, 328, 105, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $file, $sFile
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $hOpenIniButton
_FileOpen()
Case $hFinddAllButton
If Not FileExists($file) Then
MsgBox(48, "Error", "test.ini not found!")
EndIf
$sections = IniReadSectionNames($file)
$test = GuiCtrlRead($hSearchInput) ; read the search input
For $i = 1 to $sections[0] ; loop through sections
$tmp = IniRead($file, $sections[$i], "1", "not found") ; read key named "1"
;~ If StringInStr($tmp, $test) Then GUICtrlSetData($hList, "[" & $sections[$i] & "] " & $tmp)
If StringInStr($tmp, $test) Then
_GUICtrlListView_BeginUpdate($hList)
GUICtrlCreateListViewItem("[" & $sections[$i] & "]|" & $tmp, $hList) ; populate list with founded items
_GUICtrlListView_EndUpdate($hList)
EndIf
Next
EndSwitch
WEnd
; open file
Func _FileOpen()
Global $file = FileOpenDialog("Open INI for edit", "", "INI files (*.*)")
If FileExists($file) Then
$sFile = FileOpen($file)
If @error Then
MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended)
Else
GUICtrlSetState($hOpenIniButton, $GUI_DISABLE)
EndIf
Else
MsgBox(48, "Error", "Error = " & @error & ", Extended = " & @extended)
EndIf
EndFunc
Func Compare($Str1, $Str2)
If StringLen($Str1) <> StringLen($Str2) Then Return False
For $i = 1 To StringLen($Str1)
If StringMid($Str1, $i, 1) <> StringMid($Str2, $i, 1) Then
Return False
EndIf
Next
Return True
EndFunc
Func Compare($Str1, $Str2)
If StringLen($Str1) <> StringLen($Str2) Then Return False
For $i = 1 To StringLen($Str1)
If StringMid($Str1, $i, 1) <> StringMid($Str2, $i, 1) Then
Return False
EndIf
Next
Return True
EndFunc
This function dont ready anything from your ini.
It just compare 2 strings.
Code:
If Compare($tmp, $test) Then
_GUICtrlListView_BeginUpdate($hList)
GUICtrlCreateListViewItem("[" & $sections[$i] & "]|" & $tmp, $hList) ; populate list with founded items
_GUICtrlListView_EndUpdate($hList)
EndIf
This function dont ready anything from your ini.
It just compare 2 strings.
Code:
If Compare($tmp, $test) Then
_GUICtrlListView_BeginUpdate($hList)
GUICtrlCreateListViewItem("[" & $sections[$i] & "]|" & $tmp, $hList) ; populate list with founded items
_GUICtrlListView_EndUpdate($hList)
EndIf
Yea i used it like that and it need 3-4 min to find 1 string, so this is too slow, @lolkop's example is very good but i don't know how to put that founded results from _ArrayDisplay() in my listview
Code:
Case $hFinddAllButton
$sections = IniReadSectionNames($file) ; read section names
$test = GuiCtrlRead($hSearchInput) ; read the search input
; loop through sections
For $i = 1 to $sections[0]
$tmp = IniRead($file, $sections[$i], "1", "not found") ; read key named "1"
;~ If StringInStr($tmp, $test) Then GUICtrlSetData($hList, "[" & $sections[$i] & "] " & $tmp)
If Compare($tmp, $test) Then ; If StringInStr($tmp, $test) Then
_GUICtrlListView_BeginUpdate($hList)
GUICtrlCreateListViewItem("[" & $sections[$i] & "]|" & $tmp, $hList) ; populate list with founded items
_GUICtrlListView_EndUpdate($hList)
EndIf
Next
This works on small ini and give me all results from search field but won't work with big ini , try download this game ini u have in first post and try to find "Blode" without ""
Code:
Case $hFinddAllButton
; check if ini is opened
; check if empty field
$sections = IniReadSectionNames($file) ; read section names
$test = GuiCtrlRead($hSearchInput) ; read the search input
;~ _ArrayDisplay(StringRegExp(FileRead('ItemTemplateAll1.ini'), "[1]=(.*"&InputBox("Search for", "Enter your Text:")&".*)", 3))
; loop through sections
For $i = 1 To $sections[0]
; read key named "1"
$tmp = IniRead($file, $sections[$i], "1", "")
#cs
Checks if a string contains a given substring
Return Value
Success: the position of the substring.
Failure: 0 if substring not found.
@error: 1 = Invalid "start" or "occurrence" parameter given.
#ce
If StringInStr($tmp, $test) Then
If @error Then
MsgBox(48, "Error", "Error : " & @error & ", Extended : " & @extended)
Else
; populate list with founded items
_GUICtrlListView_BeginUpdate($hList)
GUICtrlCreateListViewItem("[" & $sections[$i] & "]|" & $tmp, $hList)
_GUICtrlListView_EndUpdate($hList)
EndIf
EndIf
Next
I want this in listview like this so when i click on item, that item appears here so i can edit it and save back to ini.
Is in c++, delphi, c# this things works faster ?
Yeah they are a lot faster, i won't even say that it is more difficult to do this than in AutoIt, but you need to learn more to get started with these languages.
TF2 Multihack I found (READ first!) 01/09/2020 - Team Fortress 2 - 7 Replies Hi guys,
I'm collecting VACs on my CS:GO smurf so I'm trying to hack in f2p games. So far I got 2 bans. Anyway, the next candidate is Team Fortress 2 and I found a suitable multi-hack, I've been using it as a rage-hack for a couple of hours and the cheat itself is actually detected as of July 2014.
24 hours have passed and I'm not VACced. Therefore I'm uploading the hack here as a PUBLIC CHEAT for people who want to kill time on fresh Steam Accounts.
Note: Again, this hack is DETECTED...