guinness Posted September 14, 2010 Share Posted September 14, 2010 (edited) The example below automates the process of creating GUICtrlCreateMenu's, it's very simple and does nothing but show the item selected in the MsgBox() I normally don't like to post empty handed, so I created this in the hope that someone would be able to help me find a good example. I have searched the forum with various keywords ("GUICtrlCreateMenu, dynamic, for loop, ctrl, dummy()" - to name but a few) with a few results that seem to rely on EventMode. Anyone have any good examples in GUIGetMsg() Mode to Share? Thanks Note: I have seen some around but can't seem to locate them!$GUI = GUICreate("", 330, 220) $CtrlMenu_FirstItem = GUICtrlCreateDummy() For $A = 1 To 4 $Menu = GUICtrlCreateMenu("Menu >> " & $A) ConsoleWrite($Menu & @CRLF) For $B = 1 To 10 $SubItem = GUICtrlCreateMenuItem("In Menu >> " & $A & " and SubMenu >> " & $B, $Menu) ConsoleWrite($SubItem & @CRLF) Next Next $CtrlMenu_LastItem = GUICtrlCreateDummy() GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 ExitLoop Case $CtrlMenu_FirstItem To $CtrlMenu_LastItem MsgBox(0, "MenuItem >> ", $Msg) EndSwitch WEndEdit: Maybe I should have posted this in the GUI Help Section! But it's not a problem with the GUI code, it works, I am just looking for some examples. Edited September 14, 2010 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Achilles Posted September 15, 2010 Share Posted September 15, 2010 I've read your post a couple of times and I'm still lost as to what you're actually looking for. I get that you want examples using GUIGetMsg().. but examples of what? Using menu items? My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
guinness Posted September 15, 2010 Author Share Posted September 15, 2010 I am looking for a similar example that creates GUICtrlCreateMenu's in a loop (For, While any) so its quick and less space (painful). Before I became really interested in AutoIt I was doing this (See Example 1) But in the Example I originally posted the process of creating a GUIMenu with (for example) 1000 MenuItems doesn't have to be a 1000 lines. In the forum I have seen it done with OnEvent Mode (which I understand might be the only way) but I was unable to find a good example using GUIGetMsg() Mode. Example 1 of a long drawn out and inefficient process of creating a GUIMenu. GUICtrlCreateMenu(.... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenu(.... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... GUICtrlCreateMenuItem(... UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
enaiman Posted September 15, 2010 Share Posted September 15, 2010 What is the problem with your first script ?? SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 15, 2010 Moderators Share Posted September 15, 2010 guinness,I am struggling to grasp what real world problem you are trying to solve here. Certainly you are creating a large menu in only a few lines of code, but the menu is hardly useful as it stands. If you wanted to create a "normal" menu in the same manner, I imagine you would also need to create an array holding the text entries for the various options which you would access as the loops ran to give you meaningful menu titles. You would also need an element to state how many sub-menus were to to be created for each main/sub menu item. You would then need code to determine which menu element had been actioned once you got the ControlID as hardcoding the indices would make changing the menu structure a very lengthy chore. Overall, I believe that the added code required and the complexity of managing your suggested solution would outweigh any possible advantage over a simple list with unique variables holding the ControlID - however boring it might seems. By the way, who would ever want a menu with 1000 items? So kudos for using the idea of looking for a series of ControlIDs as you have (I use this trick all the time*), but I do not see it as a sensible coding option for creating menus - which may be why you cannot find any examples! Sorry to be so negative - I will try to be more enthusiastic next time! M23* But beware, for the trick to work, the controls must be created in IMMEDIATE succession and before any previously controls have been deleted. AutoIt uses an internal array to store its ControlIDs and uses the first available slot to store a new ControlID. So deleting earlier controls could well leave a "hole" in the array and you will not get the range of controls you think you should. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted September 15, 2010 Author Share Posted September 15, 2010 (edited) Sorry to be so negative - I will try to be more enthusiastic next time! Not at all, appreciate your expertise. I just thought I saw an example of yours once where you looped a GUICtrlCreateMenu, but I have seen some examples of yours where you do it for Buttons, Labels, Checkboxes, Radio Buttons etc...So I thought why not GUICtrlCreateMenu! I know it's a lot less complicated in Event Mode or the simple way of listing, but I like a challenge, plus this is how I learn by trial and error. And Yeh a 1000 items would require re-looking at my script. I don't think I have been that bad of an AutoIt user by asking the question I could have simply posted "How do I create a GUICtrlCreateMenu with a For...Loop?" with no reason why or not even trying With regards to the HotKeys I have a function which can convert these into the correct format (e.g. ^+S) but I haven't included. And I love to use GUISetAccelerators instead of HotKeySet! And the problem you mentioned I think won't happen because the GUICtrlCreateMenu is created after the GUICreate() function. Example created before I read your message. - Thanksexpandcollapse popup#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <Array.au3> ; Note: For the purposes of the example I have used Global varibales in some places, but they would be better as Local and in the _Main() function. Global $mOpen = "Open", $mNew = "New", $mSaveAs = "SaveAs", $mSave = "Save", $mExit = "Exit", $mFind = "Find", $mRename = "Rename", $mInfo = "Info", $mWebSite = "WebSite" ; ################################################################### ; Start - Customise the Array ; ; ################################################################### Global $__IntMenuArray[4][8] = [ _ ; [4] = Number of Rows & [8] is the most number of SubMenus, which is this case happens to be those in the Edit Menu. [3, "File", "Edit", "Help"], _ ; Heading Names, you can add more by updating the value and adding $mNew & " Name" e.g. [4, "File", "Edit", "Help", $mNew & " Name"], _ [7, $mOpen & "|Ctrl+O", $mNew & "|Ctrl+N", "|", $mSaveAs & "|Ctrl+Shift+N", $mSave & "|Ctrl+S", "|", $mExit & "|"], _ ; Attached to File Menu, you can add by updating the value and "SubItem|HotKey (optional)" Note: Use | when splitting Name and optional HotKey. If you need a blank line then just use only "|" [3, $mFind & "|", "|", $mOpen & "|"], _ ; Attached to Edit Menu, see above. [2, $mInfo & "|", $mWebSite & "|"]] ; Attached to Help Menu, see above ; ################################################################### ; End - Customise the Array ; ; ################################################################### Global $__MenuArray[2][3] = [[0, 3]] _Main() Func _Main() GUICreate("", 330, 220) Local $Menu_FirstItem = GUICtrlCreateDummy() For $A = 1 To $__IntMenuArray[0][0] Local $Menu = GUICtrlCreateMenu($__IntMenuArray[0][$A]) For $B = 1 To $__IntMenuArray[$A][0] If UBound($__MenuArray, 1) <= $__MenuArray[0][0] + 1 Then ReDim $__MenuArray[UBound($__MenuArray, 1) * 2][UBound($__MenuArray, 2)] Local $StringSplit = StringSplit($__IntMenuArray[$A][$B], "|") Local $SubItem = $StringSplit[1] & @TAB & $StringSplit[2] If $StringSplit[1] = "" Then $SubItem = "" $__MenuArray[$__MenuArray[0][0] + 1][0] = GUICtrlCreateMenuItem($SubItem, $Menu) $__MenuArray[$__MenuArray[0][0] + 1][1] = $StringSplit[1] $__MenuArray[$__MenuArray[0][0] + 1][2] = $StringSplit[2] $__MenuArray[0][0] += 1 Next Next Local $Menu_LastItem = GUICtrlCreateDummy() ReDim $__MenuArray[$__MenuArray[0][0] + 1][$__MenuArray[0][1]] ; Remove Empty Rows ;~ _ArrayDisplay($__MenuArray, "This is the Array contents [Handle][Menu Name][HotKey]") GUISetState(@SW_SHOW) While 1 Local $Msg = GUIGetMsg() Switch $Msg Case -3 ExitLoop Case $Menu_FirstItem To $Menu_LastItem For $A = 1 To $__MenuArray[0][0] If $Msg = $__MenuArray[$A][0] And $__MenuArray[$A][1] <> "" Then ConsoleWrite("Item >> " & $__MenuArray[$A][1] & " & Using HotKey >> " & $__MenuArray[$A][2] & @CRLF) Local $MenuItem = $__MenuArray[$A][1] ExitLoop EndIf Next ; ################################################################### ; Start - Customise this Switch ; ; ################################################################### Switch $MenuItem Case $mExit Exit Case $mOpen MsgBox(0, "Example", $mOpen) Case $mNew MsgBox(0, "Example", $mNew) Case $mInfo MsgBox(0, "Example", $mInfo) Case Else MsgBox(0, "Example", "Something Else Was Clicked (" & $MenuItem & ")") EndSwitch ; ################################################################### ; End - Customise this Switch ; ; ################################################################### EndSwitch WEnd EndFunc ;==>_Main Note: I posted an Example because I was hoping users would be able to point me to a good forum post with the similar intention as my script so I could learn an alternative coding style. I dislike seeing posts where users ask for members to search the forum on their behalf! But as Melba23 said the reason I couldn't find good Examples is they probably don't exist! Edited September 15, 2010 by guinness UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 15, 2010 Moderators Share Posted September 15, 2010 guinness,I don't think I have been that bad of an AutoIt user by asking the questionPlease do not take my comments as any form of criticism. As my instructor once told me: "The only stupid questions are the ones you do not ask". In an AutoIt context I would add: "unless you have not even looked at the Help file"! Which you obviously had.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
guinness Posted September 15, 2010 Author Share Posted September 15, 2010 Please do not take my comments as any form of criticism. As my instructor once told me: "The only stupid questions are the ones you do not ask". I am a little more thick skinned than might appear Seems you instructor never crossed paths with a cocky guy who never stops asking questions!I hope my code is up to (your) standard and others might find it useful. Can you see any potential problem with it? I know your busy coder, so input from others interested would be cool UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 15, 2010 Moderators Share Posted September 15, 2010 guinness, Here is how I might go about it creating a menu using loops and an array: expandcollapse popup#include <GUIConstantsEx.au3> _Main() Func _Main() Local $aList[3][8] = _ [["File", "Open", "New", "", "Save", "SaveAs", "-", "Exit"], _ ["Edit", "Find", "", "Open", "-", "-", "-", "-"], _ ["Help", "Help", "", "WebSite", "-", "-", "-", "-"]] $hGUI = GUICreate("", 330, 220) $hStart = GUICtrlCreateDummy() For $j = 0 To UBound($aList) - 1 $mMenu = GUICtrlCreateMenu($aList[$j][0]) For $i = 1 To UBound($aList, 2) - 1 Switch $aList[$j][$i] Case "-" GUICtrlCreateDummy() Case Else GUICtrlCreateMenuItem($aList[$j][$i], $mMenu) EndSwitch Next Next $hEnd = GUICtrlCreateDummy() GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hStart To $hEnd $iIndex = $iMsg - $hStart - 1 $iMenu = Int($iIndex / UBound($aList, 2)) $iItem = Mod($iIndex, UBound($aList, 2)) MsgBox(0, "Menu Selection", $aList[$iMenu][$iItem]) EndSwitch WEnd EndFunc ;==>_Main I hope you find it interesting. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Achilles Posted September 15, 2010 Share Posted September 15, 2010 I know you said you were using GUIGetMsg(), but if you're using a ton of menu items.. you could just create an 2d array with one value for the text, and one for the function.. so, here's what the create line would look like GUICtrlCreateMenuItem($prevMenu, $array[$i][0]) GUICtrlSetOnEVent(-1, $array[$i][1]) Thinking more about it you might want three dimensions in order to manage the separate menu's.. just an idea. I would make an example but have class in a few minutes My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
guinness Posted September 15, 2010 Author Share Posted September 15, 2010 I hope you find it interesting. Of course! I like your approach for finding the Text of the MenuItem. Thanks for taking your time to provide a second example.I know you said you were using GUIGetMsg(), but if you're using a ton of menu items.. you could just create an 2d array with one value for the text, and one for the function.. so, here's what the create line would look likeI already made a working example, a continuation from my first post and so did Melba23! But a 4th would be much appreciated, especially in Event Mode. Thanks UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
taietel Posted September 15, 2010 Share Posted September 15, 2010 Guiness, here is a dynamic menu which reads values/commands from an ini file. You can drop the ini and use arrays.M.I. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
guinness Posted September 15, 2010 Author Share Posted September 15, 2010 This was the example I was referencing in my original post when I said I have found examples that use GUIOnEventMode. I liked the way you use an INI file in creating a Menu, great if you want to create various types of GUI's, with different menus. Now there is a nice selection of GUIGetMsg() and GUIOnEventMode versions! Cheers taietel! UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
taietel Posted September 15, 2010 Share Posted September 15, 2010 You are welcome! M.I. Things you should know first...In the beginning there was only ONE! And zero... Progs: Create PDF(TXT2PDF,IMG2PDF) 3D Bar Graph DeskGadget Menu INI Photo Mosaic 3D Text Link to comment Share on other sites More sharing options...
AlienStar Posted November 23, 2020 Share Posted November 23, 2020 On 9/15/2010 at 9:39 PM, Melba23 said: guinness, Here is how I might go about it creating a menu using loops and an array: expandcollapse popup#include <GUIConstantsEx.au3> _Main() Func _Main() Local $aList[3][8] = _ [["File", "Open", "New", "", "Save", "SaveAs", "-", "Exit"], _ ["Edit", "Find", "", "Open", "-", "-", "-", "-"], _ ["Help", "Help", "", "WebSite", "-", "-", "-", "-"]] $hGUI = GUICreate("", 330, 220) $hStart = GUICtrlCreateDummy() For $j = 0 To UBound($aList) - 1 $mMenu = GUICtrlCreateMenu($aList[$j][0]) For $i = 1 To UBound($aList, 2) - 1 Switch $aList[$j][$i] Case "-" GUICtrlCreateDummy() Case Else GUICtrlCreateMenuItem($aList[$j][$i], $mMenu) EndSwitch Next Next $hEnd = GUICtrlCreateDummy() GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hStart To $hEnd $iIndex = $iMsg - $hStart - 1 $iMenu = Int($iIndex / UBound($aList, 2)) $iItem = Mod($iIndex, UBound($aList, 2)) MsgBox(0, "Menu Selection", $aList[$iMenu][$iItem]) EndSwitch WEnd EndFunc ;==>_Main I hope you find it interesting. M23 how can I apply this code if I have 1D array please ?? because I've tried a lot but failed Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 23, 2020 Moderators Share Posted November 23, 2020 AlienStar, i imagine you would just need the inner loop as you would only have the single menu to create. But if you posted the content of the array you wish to use and the code you tried then I might be able to offer some more precise help. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
AlienStar Posted November 23, 2020 Share Posted November 23, 2020 (edited) 1 hour ago, Melba23 said: AlienStar, i imagine you would just need the inner loop as you would only have the single menu to create. But if you posted the content of the array you wish to use and the code you tried then I might be able to offer some more precise help. M23 finally the code succeed but I need sometimes to add a new item but the code isn't detecting! the item "end" isn't detected by code as below: #include <GUIConstantsEx.au3> _Main() Func _Main() Local $array[8] = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"] ;---------------------------- $hGUI = GUICreate("", 500, 220) ;---------------------------- $listview = GUICtrlCreateListView("categories", 20, 20, 460, 180) $mMenu = GUICtrlCreateContextMenu($listview) ;---------------------------- $hStart = GUICtrlCreateDummy() For $i = 0 To UBound($array) - 1 GUICtrlCreateMenuItem($array[$i], $mMenu) Next $hEnd = GUICtrlCreateDummy() ;---------------------------- ; here we add a new item after the loop has finished GUICtrlCreateMenuItem("end", $mMenu) ;---------------------------- GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hStart To $hEnd $iIndex = $iMsg - $hStart - 1 MsgBox(0, "Menu Selection", $array[$iIndex]) EndSwitch WEnd EndFunc ;==>_Main how to fix please ? Edited November 23, 2020 by AlienStar Link to comment Share on other sites More sharing options...
Nine Posted November 23, 2020 Share Posted November 23, 2020 (edited) It is working for me. End is added at the bottom of the menu list. Oh you mean it is not triggered when you select it. Put $hend =... after and increase your array size : expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> _Main() Func _Main() Local $array[8] = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"] ;---------------------------- $hGUI = GUICreate("", 500, 220) ;---------------------------- $listview = GUICtrlCreateListView("categories", 20, 20, 460, 180) $mMenu = GUICtrlCreateContextMenu($listview) ;---------------------------- $hStart = GUICtrlCreateDummy() For $i = 0 To UBound($array) - 1 GUICtrlCreateMenuItem($array[$i], $mMenu) Next ;---------------------------- ; here we add a new item after the loop has finished GUICtrlCreateMenuItem("end", $mMenu) _ArrayAdd($array,"end") ;---------------------------- $hEnd = GUICtrlCreateDummy() GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hStart To $hEnd $iIndex = $iMsg - $hStart - 1 MsgBox(0, "Menu Selection", $array[$iIndex]) EndSwitch WEnd EndFunc ;==>_Main But beware that it may not work correctly if you insert new menu items in between other controls. Edited November 23, 2020 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
AlienStar Posted November 23, 2020 Share Posted November 23, 2020 1 hour ago, Nine said: It is working for me. End is added at the bottom of the menu list. Oh you mean it is not triggered when you select it. Put $hend =... after and increase your array size : expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> _Main() Func _Main() Local $array[8] = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"] ;---------------------------- $hGUI = GUICreate("", 500, 220) ;---------------------------- $listview = GUICtrlCreateListView("categories", 20, 20, 460, 180) $mMenu = GUICtrlCreateContextMenu($listview) ;---------------------------- $hStart = GUICtrlCreateDummy() For $i = 0 To UBound($array) - 1 GUICtrlCreateMenuItem($array[$i], $mMenu) Next ;---------------------------- ; here we add a new item after the loop has finished GUICtrlCreateMenuItem("end", $mMenu) _ArrayAdd($array,"end") ;---------------------------- $hEnd = GUICtrlCreateDummy() GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hStart To $hEnd $iIndex = $iMsg - $hStart - 1 MsgBox(0, "Menu Selection", $array[$iIndex]) EndSwitch WEnd EndFunc ;==>_Main But beware that it may not work correctly if you insert new menu items in between other controls. my friend I don't wanna add a new item before $hEnd = GUICtrlCreateDummy() because I need to use items before and after adding new items Link to comment Share on other sites More sharing options...
Nine Posted November 23, 2020 Share Posted November 23, 2020 3 minutes ago, AlienStar said: I don't wanna add a new item before $hEnd = GUICtrlCreateDummy() because I need to use items before and after adding new items I think I understand what you mean (not exactly sure). But anyway here a stronger approach I would use : expandcollapse popup#include <GUIConstantsEx.au3> #include <Array.au3> _Main() Func _Main() Local $array[8] = ["Sat", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri"] $hGUI = GUICreate("", 500, 300) $listview = GUICtrlCreateListView("categories", 20, 20, 460, 180) $mMenu = GUICtrlCreateContextMenu($listview) Local $aMenuId[UBound($array)] For $i = 0 To UBound($array) - 1 $aMenuId[$i] = GUICtrlCreateMenuItem($array[$i], $mMenu) Next $idButton = GUICtrlCreateButton("OK", 200, 220, 100, 25) Local $idTemp = GUICtrlCreateMenuItem("end", $mMenu) _ArrayAdd($array, "end") _ArrayAdd($aMenuId, $idTemp) GUISetState(@SW_SHOW) While True $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_NONE ; not truly required but it will prevent triggering Case Else for nothing Case $GUI_EVENT_CLOSE Exit Case $idButton ConsoleWrite ("Button was pressed" & @CRLF) Case Else For $i = 0 To UBound($aMenuId) - 1 If $iMsg = $aMenuId[$i] Then MsgBox(0, "Menu Selection", $array[$i]) Next EndSwitch WEnd EndFunc ;==>_Main AlienStar 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now