Jump to content

Create button based from array


sensalim
 Share

Recommended Posts

I'm sure this has been asked before but I just don't know how to search for it.

Ok say I have an ini file that lists like this

FileOpen=!fo
FilePrint=!fp
FilePrintPreview=!fv
FilePageSetup=!fu

So now a script would load this ini file into an array, say $array1

How do I make a GUI that takes this array and create 4 buttons (or 5 if this array has 5 members)?

The button would then be like:

GUICtrlCreateButton("FileOpen", ... )

GUICtrlSetOnEvent(-1, ...)

GUICtrlCreateButton("FilePrint", ... )

GUICtrlSetOnEvent(-1, ...)

which point to a dynamically created functions. For FileOpen, it would be send("!fo"). For FilePrint, it would send("!fp")

etc.

Does it make sense?

Thanks!

Link to comment
Share on other sites

maybe it can help :

#include-once
#include <GUIConstants.au3>

Opt("GUICoordMode", 2) 

$array = IniReadSection(@ScriptDir & "\test.ini","TASKS")
If @error Then Exit
GUICreate("test")

Dim $a_Buttons[$array[0][0]]

For $i = 1 To $array[0][0]
    $a_Buttons[$i-1] = GUICtrlCreateButton($array[$i][0],-1,1,100,40)
Next
GUISetState()

While 1
    $msg = GUIGetMsg()
    For $i = 1 To $array[0][0]
        If $msg = $a_Buttons[$i-1] Then FuncSend($array[$i][1])
    Next
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

Func FuncSend($myString)
    Send($myString)
EndFunc
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...