dirty Posted September 20, 2011 Share Posted September 20, 2011 $FileMenu = GUICtrlCreateMenu ("&File") $Open = GUICtrlCreateMenuItem ("Open",$FileMenu) If there are more then 1 menu item, how to read one that was selected ? or how to use it as: because each file opened is stored into this menu and by selecting one opened file or another from the drop down created by each entered item, nothing happens caz i dont know how to read it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 21, 2011 Moderators Share Posted September 21, 2011 dirty, Another canine-ingested Help file, I assume. GUICtrlRead ( controlID [, advanced] )In 'advanced' mode the return value contains additional data of the controlMenu, MenuItem - The text of the control 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...
dirty Posted September 21, 2011 Author Share Posted September 21, 2011 (edited) Thanks i now learned how to use advanced parametes for guictrlread. thanks to u. $FileMenu = GUICtrlCreateMenu ("&File") $Recent = GUICtrlCreateMenu ("Recent Files", $FileMenu) GUICtrlCreateMenuItem ("",$FileMenu) GUICtrlCreateMenuItem has no variable assigned to it and is being created by openfiledialog, so how do i read it if it has no variable and there are many of them since i opened many files ? Edited September 21, 2011 by dirty Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 21, 2011 Moderators Share Posted September 21, 2011 dirty, You can do it like this: expandcollapse popup#include <GUIConstantsEx.au3> ; Create an array to hold the ControlIDs of the MenuItems Global $aMenuItem[3] $hGUI = GUICreate("Test", 500, 500) ; Create the menu $mMenu = GUICtrlCreateMenu("File") For $i = 0 To 2 $aMenuItem[$i] = GUICtrlCreateMenuItem("Item " & $i, $mMenu) Next ; Clicking this adds an item to the menu $hButton = GUICtrlCreateButton("Add Menu Item", 10, 10, 80, 30) GUISetState() While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $hButton ; Resize the array $iCount = UBound($aMenuItem) ReDim $aMenuItem[$iCount + 1] ; And add the new item ControlID $aMenuItem[$iCount] = GUICtrlCreateMenuItem("Item " & $iCount, $mMenu) Case Else ; Run through the array to see if we have a match For $i = 0 To UBound($aMenuItem) - 1 If $iMsg = $aMenuItem[$i] Then ; We do, so read the text of the menu item $sText = GUICtrlRead($iMsg, 1) ; And display it ConsoleWrite($sText & @CRLF) ; No point in looking any further ExitLoop EndIf Next EndSwitch WEnd As you can see, when you add an item to the menu you also add the ControlID to the array. All clear? 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...
dirty Posted September 21, 2011 Author Share Posted September 21, 2011 (edited) am lost.Can you open my whole script and see how i can fix it to get this working ? your example does make enough since to me.My other post with another issue with my script included is here thanks for quick reply and a very detailed examplelook into line 326 is where i try to read the value off if created menuitem in line 214 Edited September 21, 2011 by dirty Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 21, 2011 Moderators Share Posted September 21, 2011 dirty,Here is an untested version of your script using code similar to the example I posted above - look for the <<<<<<<<<<<< lines to see where I have changed it: This updowngraded editor is screwing up the AutoIt tags yet again so I have had to attach it as a file.There are no syntax errors, but as I do not have any of your data I cannot really test it fully. Let me know when you have downloaded it and if it works. M23P.S. You might want to look at using a Switch structure rather than all those If $GUIGETMSG...EndIf statements. And why are you using Assign to set values to variables - what is wrong with a simple = operator? 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...
dirty Posted September 25, 2011 Author Share Posted September 25, 2011 It does thanks. Ways you created this to work are very confusing to me, but am sure i will understand it later. For now ill just use it. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 25, 2011 Moderators Share Posted September 25, 2011 dirty, If you do run into difficulties understanding what I did and why, please ask so I can explain. 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...
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