Jump to content
silver2002

Dropdown menu from INI file

Recommended Posts

silver2002

hi guys

im new here and need your help

i wanna create dropdown menu with list of keys from INI file and when i choose key i need to show Value outside of dropdown menu (like just show result)

i hope u understand what i need

example of ini

[Phone]
John Johnson=1234567890
Jack Jackson=2345678901
Dany Danson=0987654321

so in dropdown menu by selecting key (ex.John Johnson) i need see result on screen

i searching for some similar code but i cant find any

Share this post


Link to post
Share on other sites
careca

The basic idea is to read the ini, and then grab that list and populate the drop down, then when you select the item in the dropdown, read it and put the value wherever you want.

I would start with IniReadSection, create the combo box with GUICtrlCreateCombo and go from there.

Edited by careca

Spoiler

Paster - Main function is to paste text, but has more functions. (No longer mantained, switched to String Trigger)

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Share this post


Link to post
Share on other sites
silver2002

i dont know how... i need basic script :(

Share this post


Link to post
Share on other sites
TheXman
11 minutes ago, silver2002 said:

i need basic script

The help file is FULL of example scripts.  You should start with example scripts for the functions that @careca suggested.  The more effort you show, the more help you're likely to get. 

Share this post


Link to post
Share on other sites
Subz

Welcome to AutoIt, here is a basic script to get you started, use the help file to understand how it works.

#include <Array.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iUserList
    ;~ Get data from ini file
    Local $aUserInfo = IniReadSection(@ScriptDir & "\test.ini", "Phone")
        If @error Then Exit MsgBox(4096, "Error", "Error opening ini file")

    Local $hGUI = GUICreate("User Info", 305, 200)
    Local $idUserList = GUICtrlCreateCombo("Select User", 10, 10, 150, 20)
        ;~ Add names from the array.
        GUICtrlSetData($idUserList, _ArrayToString($aUserInfo, "|", 1, -1, "|", 0, 0), "Select User")
    Local $idUserPhone = GUICtrlCreateLabel("", 170, 13, 150, 20)
    GUICtrlSetFont(-1, 11, 800)
    Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idButton_Close
                ExitLoop
            Case $idUserList
                $iUserList = _GUICtrlComboBox_GetCurSel($idUserList)
                GUICtrlSetData($idUserPhone, $aUserInfo[$iUserList][1])
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc

 

Share this post


Link to post
Share on other sites
silver2002

thank you very much :D

ill analyze script now to see how it work...

Share this post


Link to post
Share on other sites
silver2002

ok... now im stuck on another problem...

i dont know if that possible but i would like show some pic (splash screen) from ini file

i try this but not work:

#include <Array.au3>
#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>

Example()

Func Example()
    Local $iUserList
    ;~ Get data from ini file
    Local $aUserInfo = IniReadSection(@ScriptDir & "\test.ini", "Phone")
        If @error Then Exit MsgBox(4096, "Error", "Error opening ini file")

    Local $hGUI = GUICreate("User Info", 305, 200)
    Local $idUserList = GUICtrlCreateCombo("Select User", 10, 10, 150, 20)
        ;~ Add names from the array.
        GUICtrlSetData($idUserList, _ArrayToString($aUserInfo, "|", 1, -1, "|", 0, 0), "Select User")
    Local $idUserPhone = GUICtrlCreateLabel("", 170, 13, 150, 20)
    GUICtrlSetFont(-1, 11, 800)
    Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    GUISetState()

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idButton_Close
                ExitLoop
            Case $idUserList
                $iUserList = _GUICtrlComboBox_GetCurSel($idUserList)
                $showpic = GUICtrlSetData($idUserPhone, $aUserInfo[$iUserList][1])
                SplashImageOn("Splash Screen", $showpic, 400, 400, -1, -1, $DLG_NOTITLE)
                Sleep(5000)
        EndSwitch
    WEnd
    GUIDelete($hGUI)
EndFunc

and test.ini is:

[Phone]
John Johnson=john.bmp
Jack Jackson=jack.bmp
Dany Danson=dany.bmp

 

Share this post


Link to post
Share on other sites
Subz

You would need to use the array item or use GuiCtrlRead for $idUserPhone.  You could also look at GuiCtrlCreatePic if you wanted it embedded in the Gui, just read the help file for more information.

Case $idUserList
                $iUserList = _GUICtrlComboBox_GetCurSel($idUserList)
                GUICtrlSetData($idUserPhone, $aUserInfo[$iUserList][1])
                SplashImageOn("Splash Screen", $aUserInfo[$iUserList][1], 400, 400, -1, -1, $DLG_NOTITLE)
                ;~ Or
                ;~ SplashImageOn("Splash Screen", GUICtrlRead($idUserPhone), 400, 400, -1, -1, $DLG_NOTITLE)
        EndSwitch

 

Share this post


Link to post
Share on other sites
silver2002

thank you again :D:D:D !!!

i readed help file but i need a looottt of knowledge for sure... ;)

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

×