Jump to content

Dropdown menu from INI file


Recommended Posts

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

Link to comment
Share on other sites

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

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.

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

Link to comment
Share on other sites

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. 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

 

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