Jump to content

.ini To Treeview


Recommended Posts

Hey I have AutoIT since a few weeks (and i LOVE it :) )

I want to make a script that reads a .ini file and makes a TreeView from it like this:

Part1 - this is not the trinky thing

users.ini file

[Users]
user=name1
user=name2
user=name3
user=name4
[group]
group=group1
group=group2

it has to make a treeview like this

TreeView
   |
   |-----users
   |         |-name1
   |         |-name2
   |         |-name3
   |         |-name4
   |
   |-----group
   |         |-group1
   |         |   |-name1
   |         |   |-name2
   |         |
   |         |-group2
   |               |-name3
   |               |-name4

Part2: this is the trinky thing

if i click a name it has to show the name in a label + it hase to change a $var to name1

I hope some1 can help me

Thnx i advance, adored

Link to comment
Share on other sites

lol,

The ini to treeview has been done on the forum a few times, might try using the search features of the forum.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hey, ive used the search fucntion already but couldn't find what i want

This is what i have so far,

;includes
#include <GuiConstants.au3>
Opt("GUIOnEventMode", 1)
;GUI
$netcommander = GuiCreate("NetCommander - 2.0", 383, 315,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

;GUIctrls
$Treeview = GuiCtrlCreateTreeview(10, 10, 140, 300)
$usernamelabel = GuiCtrlCreateLabel("Net Commander", 160, 10, 220, 40)
$sendmessagegroup = GuiCtrlCreateGroup("Send Message", 160, 70, 220, 150)
$sendmessageinput = GuiCtrlCreateInput("Your Message", 180, 90, 180, 90)
$sendmessagesend = GuiCtrlCreateButton("Send Message", 180, 180, 90, 30)
$sendmessageclear = GuiCtrlCreateButton("Clear", 280, 180, 80, 30)
$extragroup = GuiCtrlCreateGroup("Extra", 160, 220, 220, 90)
$extrashutdown = GuiCtrlCreateButton("Shutdown user", 180, 240, 180, 30)
$extrashowlog = GuiCtrlCreateButton("Show message log", 180, 270, 180, 30)

;GUIevents
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

;GUIstyles
GUICtrlSetFont($usernamelabel, 18, 400, 1, "Arial Black")
GUICtrlSetColor($usernamelabel,0x37AECC)
GUICtrlSetBkColor($Treeview,0x37AECC)

;GUIshow
GUISwitch($netcommander)
GUISetState(@SW_SHOW)
GuiSetState()

;GUIhides
GUICtrlSetState($sendmessagegroup, $GUI_HIDE)
GUICtrlSetState($sendmessageinput, $GUI_HIDE)
GUICtrlSetState($sendmessagesend, $GUI_HIDE)
GUICtrlSetState($sendmessageclear, $GUI_HIDE)
GUICtrlSetState($extragroup, $GUI_HIDE)
GUICtrlSetState($extrashowlog, $GUI_HIDE)
GUICtrlSetState($extrashutdown, $GUI_HIDE)

;TreeView groups
$maintreeview = GUICtrlCreateTreeViewItem ("Main",$Treeview)
$users = GUICtrlCreateTreeViewItem ("Users",$maintreeview)
$groups = GUICtrlCreateTreeViewItem ("Groups",$maintreeview)

;INIread
$iniread = IniReadSection("usersonnet.ini", "usersonnet")
If @error Then 
                MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $iniread[0][0]
                $usernames = GUICtrlCreateTreeViewItem ($iniread[$i][1],$users)
        $groupnames = GUICtrlCreateTreeViewItem ($iniread[$i][1],$groups)
    Next
EndIf

While 1
sleep(1000)
WEnd

Func CLOSEClicked()
  If @GUI_WINHANDLE = $netcommander Then 
    Exit
  EndIf 
EndFunc

it makes a nice treeview, but now is the question, how do i make the control show & the label $usernamelabel change to the user name if i click on a specific name

adored....

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...