georgegalily,
Welcome to the AutoIt forums.
I would do it this way:
#include <MsgBoxConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
Global $aSubMenuCID[11]
creategui()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case 0
; Do nothing
Case Else
For $i = 1 To 10
If $aSubMenuCID[$i] = $nMsg Then
MsgBox($MB_SYSTEMMODAL, "Text of the menuitem", "Text: " & GUICtrlRead($nMsg, 1))
ExitLoop
EndIf
Next
EndSwitch
WEnd
Func creategui()
Local $keyy
GUICreate("MenuFileMAIN", 100, 100)
$idFileMenu = GUICtrlCreateMenu("FILE")
$idFileMenuRECENT = GUICtrlCreateMenu("RECENT_FILES", $idFileMenu)
$sFilePath = @ScriptDir & "\MYFILES\SETFILES.INI" ;PATH TO SETTING FILE INI
;Local $aArray = IniReadSectionNames($sFilePath)
If Not @error Then
; Enumerate through the array displaying the KEY(RECENT_FILES) names.
For $i = 1 To 10
$keyy = "File " & $i ; IniRead($sFilePath, "RECENT_FILES", $i, "")
$aSubMenuCID[$i] = GUICtrlCreateMenuItem($keyy, $idFileMenuRECENT)
;If IniRead($sFilePath, "RECENT_FILES", $i + 1, "") = "" Then ExitLoop
Next
Local $GUI_EVENT_CLOSE = GUICtrlCreateMenuItem("close", $idFileMenu)
GUISetState(@SW_SHOW)
EndIf
EndFunc ;==>creategui
You will need to reactivate the ini file lines - I changed them just for testing. Please ask if you have any questions.
M23