Jump to content

GUICtrlCreateCombo and INI files


Pook
 Share

Recommended Posts

Okay,

Ive been looking around, and I cant find what Im looking for. So I'm going to suck it up and ask for help. I have a script that connects to a remote computer to run a third party app called Remotely Anywhere. I wanted to add a HISTORY dropdown combo box to the script. So I started playing around with GUICtrlCreateCombo and INI files.

The Problem:

-I want the script to write the last 100 Hostname I connected to (or type in). The problem is I dont know how to write the information to an INI file the right order. (From recent connection to very last connection)

- Also I want it to overwrite the information after I pass the 100 mark. Just keep the most recent 100.

Example GUI Layout from my script:

#include <GuiConstants.au3>
GUICreate("(Beta) Problem  (Beta)", 350, 210)
$HistoryGroup= GUICtrlCreateGroup("History", 10, 10, 330, 80)
$HistoryList = GUICtrlCreateCombo("History List", 30, 30, 290, 21)
$ActivateHistory = GUICtrlCreateButton("Connect", 130, 60, 90, 20)
$Exit = GUICtrlCreateButton("Exit", 250, 160, 90, 20)
GUISetState()

;Read ini
$Config = IniReadSection("History.ini", "History")

Any ideas?

Link to comment
Share on other sites

I'm new here so I may not know what I'm talking about so take what I say with a grain of salt. I saw a couple of user defined functions, _FileReadToArray & _FileWriteFromArray, that may be of use. I would just keep the history in an array and then use these fuction to dump/retrieve it to/from the history file. There is another user defined function _ArrayReverse that may also prove useful.

Link to comment
Share on other sites

Maybe you could e.g. use IniWriteSection() to allocate the entries to one section for each date (add the current date) to the section name. Then you could add the current time to the name of the key containing the value of the last used host.

Easier you could just add current date&time to name of the key.

So when reading the ini-file you would have to go backwards from the current date&time and read the values in descending order.

Link to comment
Share on other sites

So when reading the ini-file you would have to go backwards from the current date&time and read the values in descending order.

I've been looking around and I don't see how I read it in "descending order". So it show up in the 'GUICtrlCreateCombo' that way.

MY CODE SO FAR

#include <GuiConstants.au3>
GUICreate("(Beta) (Beta-Test) (Beta)", 350, 210)
$grpHistory= GUICtrlCreateGroup("History", 10, 10, 330, 80)
$HistoryList = GUICtrlCreateCombo("Choose", 30, 30, 290, 21)
$ActivateHistory = GUICtrlCreateButton("Connect", 130, 60, 90, 20)
$Exit = GUICtrlCreateButton("Exit", 250, 160, 90, 20)
GUISetState()
$Config = IniReadSection("History.ini", "History")

If @error Then
    MsgBox(4096, "", "Error occured, probably no INI file.")
Else
    For $i = 1 To $Config[0][0]
        GUICtrlSetData($HistoryList, $Config[$i][0] & "<>" & $Config[$i][1] )
    Next
EndIf
;-------------------------------------
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Exit
            ExitLoop
        Case $msg = $ActivateHistory
            $data= GUICtrlRead($HistoryList)
            $HistoryConfigArray=stringsplit($data,"<>")
            for $i = 1 to $HistoryConfigArray[0]
            next
                $HostNameINI = $HistoryConfigArray[1]
                $UsernameINI = $HistoryConfigArray[3]
                $TimeStampINI = $HistoryConfigArray[5]
            MsgBox(48, "Test", " HostName >> " & $HostNameINI , 0)
            MsgBox(48, "test", "Username >> " & $UsernameINI , 0)
            MsgBox(48, "test", "TimeStamp >>  " & $TimeStampINI , 0)
            Case Else
        ;;;
    EndSelect
WEnd
Exit

INI FILE *example

[History]
Workstation1=JOEBLOW1<>10/29/2008 23:03:34
Workstaiton2=JOEBLOW2<>10/29/2008 23:03:32

screenshot of gui

post-20189-1225331233_thumb.png

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...