Jump to content
Sign in to follow this  
Earthquake

Combo Box with Ini Input and Read the selection

Recommended Posts

Earthquake

Hi Snipez,

I want to create a combo, which gets it contents from a .ini file like this:

Name of file: Scriptregister.ini

[START]

Count=3

Script1=App
Exec1=c:\app.exe

Script2=Appl
Exec2=c:\appl.exe

Script3=Apple
Exec3=c:\apple.exe

I can load the content of the .ini into the combo, thats not the problem.

#include <GUIConstants.au3>
$ScriptFilename=("C:\Scriptregister.ini")
$CountTemplates = IniRead($ScriptFilename, "Start", "Count","1")

    for $i = 1 to $CountTemplates
        
$ComboText = IniRead($ScriptFilename, "Start", "Script"& $i , $i)
        
if ($i = 1) then
   $combo = GUICtrlCreateCombo ($ComboText , 32 , 2 , 200 , 25 , $CBS_DROPDOWNLIST)
else
    GUICtrlSetData($combo, $ComboText)
endif
        
next

How can I get the marked item of the .ini and start the application, which belongs to it???

I have no more ideas...

P.S. Please no replies like "you're such a noob", I know I am and I'm simply asking for help! :D

Edited by Earthquake

Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!

Share this post


Link to post
Share on other sites
rakudave

porbably the easiest way to do this is not to call the exe's "Execl1".

take the name instead:

[START]

Count=3

Script1=App
App=c:\app.exe

Script2=Appl
Appl=c:\appl.exe

Script3=Apple
Apple=c:\apple.exe

then read the dir from the .ini, and run it:

run(IniRead($ScriptFilename, "Start", GUICtrlRead($combo) , "")
Edited by rakudave

Share this post


Link to post
Share on other sites
SmOke_N

EarthQuake, that avatar is a bit distasteful, my kids walk around me from time to time when I'm on my computer.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Xenobiologist

Hi,

I had a quick & dirty solution for this: :">

#Include <GUIConstants.au3>
#include <GuiCombo.au3>
#include <Array.au3>

$var = IniReadSection(@ScriptDir & "\scripts.ini", "start")
If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.")

Global $a
For $i=1 To $var[0][0]
    $a = $a & ($var[$i][0] & '|')
Next

GUICreate("My GUI")  
$combo = GUICtrlCreateCombo("Applications" , 32 , 2 , 200 , 25 , $CBS_DROPDOWNLIST)
$start_B = GUICtrlCreateButton ("Start" , 32 , 200 , 200 , 25 )
GUICtrlSetData($combo,  $a)
GUISetState (@SW_SHOW)   

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Global $index = _GUICtrlComboGetCurSel($combo)
    If $msg = $start_B Then RunWait(@ComSpec & ' /c start ' & $var[$index][1], '', @SW_HIDE)
Wend

With this ini

[START]
App=c:\app.exe
Appl=c:\appl.exe
Apple=c:\apple.exe

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Earthquake

EarthQuake, that avatar is a bit distasteful, my kids walk around me from time to time when I'm on my computer.

Ok, no problem, I'll change it! :D

$Exec = IniRead($ScriptFilename, "Start", $combo,"")

Select
   Case $MsgBoxAnswer = 6
            
      run($Exec)
    
   Case $MsgBoxAnswer = 7
EndSelect

Thats my code now and it works just fine.

First I tried a while loop, to determine, wich number of the "Script" entry in the .ini is meant. <- Horrible!

Edited by Earthquake

Yes, I am a noob! But at least I try to learn!Moddingtech.de - Home of the german Modding-Scene!

Share this post


Link to post
Share on other sites
SmOke_N

Ok, no problem, I'll change it! :D

Thank you! :wacko:

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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
Sign in to follow this  

×