AC130 Posted May 24, 2011 Share Posted May 24, 2011 Is there a way to treat this as a button, so that when I click on it, it will do a script? Like: Case $GUICtrlCreateMenu1 MsgBox (0, "OK", "DEMO" ) Link to comment Share on other sites More sharing options...
monoscout999 Posted May 24, 2011 Share Posted May 24, 2011 Is there a way to treat this as a button, so that when I click on it, it will do a script?Like:Case $GUICtrlCreateMenu1 MsgBox (0, "OK", "DEMO" )emm !!?? ! post a more explicit script please... make my day easy and i will try to solve your problem... Link to comment Share on other sites More sharing options...
AC130 Posted May 24, 2011 Author Share Posted May 24, 2011 (edited) Global $FileMenu6 = GUICtrlCreateMenu("&Options") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FileMenu6 MsgBox ( whatever ) EndSwitch WEnd Edited May 24, 2011 by AC130 Link to comment Share on other sites More sharing options...
monoscout999 Posted May 24, 2011 Share Posted May 24, 2011 (edited) Global $FileMenu6 = GUICtrlCreateMenu("&Options") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $FileMenu6 MsgBox ( whatever ) EndSwitch WEnd This is NOT Helpful... -.- post a working script please.... EDIT: This is a working script!! next time please make us to all easy!!!! #include <GUIConstantsEx.au3> $GUI = Guicreate("blabla") $FileMenu = GUICtrlCreateMenu("&Options") $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) Guisetstate() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Fileitem MsgBox (0,"","" ) EndSwitch WEnd Anyway.... ¿is this what you want? Edited May 24, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
AC130 Posted May 24, 2011 Author Share Posted May 24, 2011 (edited) How is that not helpful... I'm only asking to make it function as a button, so that I can press it. [#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\dad\desktop\software\form1.kxf $Form1 = GUICreate("Test", 300, 300, 300, 300) $FileMenu1 = GUICtrlCreateMenu("Options",) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit+ ; I want to add another case so that when i press $FileMenu1 it will do a script. EndSwitch WEnd Edited May 24, 2011 by AC130 Link to comment Share on other sites More sharing options...
monoscout999 Posted May 24, 2011 Share Posted May 24, 2011 (edited) How is that not helpful...is not helpfull because i have to write a new script... why dont you write the script is for you anywayI already answer you in the last post...Is mose pleaent help to someone who put some effor on the things... if you put an example script for us make sure that it works because is much easy copy and paste... is annoying do all the job for someone else.. to you is easy add a WORKING CODE not an prototype.. keep that in mind please Edited May 24, 2011 by monoscout999 Link to comment Share on other sites More sharing options...
AC130 Posted May 25, 2011 Author Share Posted May 25, 2011 expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $defaultstatus, $status, $filemenu, $fileitem, $helpmenu, $saveitem Local $infoitem, $exititem, $recentfilesmenu, $separator1, $viewmenu Local $viewstatusitem, $okbutton, $cancelbutton, $statuslabel, $msg, $file GUICreate("My GUI menu", 300, 200) Global $defaultstatus = "Ready" Global $status $filemenu = GUICtrlCreateMenu("&File") $fileitem = GUICtrlCreateMenuItem("Open", $filemenu) GUICtrlSetState(-1, $GUI_DEFBUTTON) $helpmenu = GUICtrlCreateMenu("?") $saveitem = GUICtrlCreateMenuItem("Save", $filemenu) GUICtrlSetState(-1, $GUI_DISABLE) $infoitem = GUICtrlCreateMenuItem("Info", $helpmenu) $exititem = GUICtrlCreateMenuItem("Exit", $filemenu) $recentfilesmenu = GUICtrlCreateMenu("Recent Files", $filemenu, 1) $separator1 = GUICtrlCreateMenuItem("", $filemenu, 2) ; create a separator line $viewmenu = GUICtrlCreateMenu("View", -1, 1) ; is created before "?" menu $viewstatusitem = GUICtrlCreateMenuItem("Statusbar", $viewmenu) GUICtrlSetState(-1, $GUI_CHECKED) $okbutton = GUICtrlCreateButton("OK", 50, 130, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) $cancelbutton = GUICtrlCreateButton("Cancel", 180, 130, 70, 20) $statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState() While 1 $msg = GUIGetMsg() If $msg = $fileitem Then $file = FileOpenDialog("Choose file...", @TempDir, "All (*.*)") If @error <> 1 Then GUICtrlCreateMenuItem($file, $recentfilesmenu) EndIf If $msg = $viewstatusitem Then If BitAND(GUICtrlRead($viewstatusitem), $GUI_CHECKED) = $GUI_CHECKED Then GUICtrlSetState($viewstatusitem, $GUI_UNCHECKED) GUICtrlSetState($statuslabel, $GUI_HIDE) Else GUICtrlSetState($viewstatusitem, $GUI_CHECKED) GUICtrlSetState($statuslabel, $GUI_SHOW) EndIf EndIf If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop If $msg = $infoitem Then MsgBox(0, "Info", "Only a test...") WEnd GUIDelete() EndFunc ;==>ExampleThis is the example code for the GUICtrlCreateMenuItem, and I'm wondering if there is a way to make GUICtrlCreateMenuItem to be a enable/disable option.So that when "file" is pressed it will enable/disable another code in my script? Link to comment Share on other sites More sharing options...
AC130 Posted May 25, 2011 Author Share Posted May 25, 2011 Also is there a way that when I press a button, it will show a seperate GUI other than my main GUI? I tried GUICreate but I can't get it working. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2011 Developers Share Posted May 25, 2011 Also is there a way that when I press a button, it will show a seperate GUI other than my main GUI? I tried GUICreate but I can't get it working.I see you are good in asking but not showing much effort yourself ... does that sound familiar? Believe you got some time off recently and I am not seeing much change ....What about you start studying the many examples in the Helpfile and posted code in the forum first?Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
AC130 Posted May 25, 2011 Author Share Posted May 25, 2011 ok well what about the other problem ... i got it so that when i press file it shows a msgbox, but instead of a msgbox, can it be enable/disable a script. Link to comment Share on other sites More sharing options...
Developers Jos Posted May 25, 2011 Developers Share Posted May 25, 2011 ok well what about the other problem ...i got it so that when i press file it shows a msgbox, but instead of a msgbox, can it be enable/disable a script.Have you even read what I wrote before you made the last post? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
AC130 Posted May 25, 2011 Author Share Posted May 25, 2011 ok expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=c:\users\dad\desktop\software\form1.kxf $Form1 = GUICreate("Demo", 300, 300, 100, 100) $MenuItem = _GUICtrlCreateMenuItemEx1("Test", -1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem $Form2 = GUICreate("About", 350, 250, 302, 218) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 124, 208, 75, 25, 0) $Input1 = GUICtrlCreateInput("Test", 37, 30, 169, 21, $ES_CENTER) GUISetState(@SW_SHOW) EndSwitch WEnd Func _GUICtrlCreateMenuItemEx1($sText, $iMenuID, $iMenuEntry=-1, $iMenuRadioItem=0) Local $nDummyMenu = GUICtrlCreateMenu("") Local $nDummyMenuItem = GUICtrlCreateMenuItem("", $nDummyMenu) Local $nMenuItem = GUICtrlCreateMenuItem($sText, $iMenuID, $iMenuEntry, $iMenuRadioItem) GUICtrlDelete($nDummyMenu) GUICtrlDelete($nDummyMenuItem) Return $nMenuItem EndFunc ok now whenver i press the test menuitem, i want it to bring up a new gui, and then input a number, and then when i press ok, i want it to save that number there, so that i can call a script using the entered number. oh and also whenever i close out the about box, the whole program exits. any fixes? thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 25, 2011 Moderators Share Posted May 25, 2011 AC130,One way to do what you want is to have another While...WEnd loop inside the Case $Button code like this:expandcollapse popup#include <GUIConstantsEx.au3> #include <EditConstants.au3> $Form1 = GUICreate("Demo", 300, 300, 100, 100) GUICtrlCreateMenu("") $MenuItem = GUICtrlCreateMenuItem("Test", -1) GUISetState(@SW_SHOW) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $MenuItem $Form2 = GUICreate("About", 350, 250, 302, 218) $GroupBox1 = GUICtrlCreateGroup("", 8, 8, 305, 185) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button1 = GUICtrlCreateButton("&OK", 124, 208, 75, 25, 0) $Input1 = GUICtrlCreateInput("Test", 37, 30, 169, 21, $ES_CENTER) GUISetState(@SW_SHOW) ; Disable the main GUI GUISetState(@SW_DISABLE, $Form1) ; Start a new loop to catch events from this GUI While 1 Switch GUIGetMsg() Case $Button1 ; Save the value from the input $sInput = GUICtrlRead($Input1) ; Display it to prove we did so MsgBox(0, "Input", $sInput) ; Carry on with the next case ContinueCase Case $GUI_EVENT_CLOSE ; Re-enable the main GUI GUISetState(@SW_ENABLE, $Form1) ; Delete the GUI GUIDelete($Form2) ; Exit the inner While...WEnd loop ExitLoop EndSwitch WEnd EndSwitch WEndNote that the main GUI must be disabled while the child is visible. To see why this is important, comment out those lines and click on the main GUI [X] while the child is visible. What you get is not what you expected to happen, I dare say! Another way you can go is to use the Advanced parameter with GUIGetMsg - look at the Managing Multiple GUIs tutorial in the Wiki to see how to make that work. Oh, and I also simplified the menu creation code a bit for you! 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...
monoscout999 Posted May 27, 2011 Share Posted May 27, 2011 (edited) about Menu click event i got it !!! #include <GUIConstantsEx.au3> #include <array.au3> #include <winapi.au3> #include <WindowsConstants.au3> $GUI = Guicreate("blabla") $FileMenu = GUICtrlCreateMenu("&Options") GUIRegisterMsg($WM_INITMENU,"_menuclick") Guisetstate() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case 3 MsgBox (0,"","" ) EndSwitch WEnd func _menuclick($hWndGUI, $MsgID, $WParam, $LParam) msgbox(0,"","") EndFunc But it is not perfect it shots the func when any menu is clicked... Edited May 27, 2011 by monoscout999 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