newbiescripter Posted February 20, 2008 Share Posted February 20, 2008 Hello I've now tryied so many things an doesn't now what to do anymore. so I hoped that you could help I want to call a part of the script when for example pressing $MenuItem3 look at the examples below: First I tried with getmsg: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\Form1.kxf $Form1 = GUICreate("Form1", 286, 113, 193, 125) $MenuItem1 = GUICtrlCreateMenu("MenuItem1") $MenuItem2 = GUICtrlCreateMenu("MenuItem2") $MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem3 #include <msg.au3> ;in msg.au3 : MsgBox(0,"status","Hello") EndSwitch WEnd And here it wouldn't work even if it's a very simple example :/ it gives me the error: C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\CompInfo.au3(53,1) : ERROR: syntax error Func ^ so I tried with onEvent: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\Form1.kxf $Form1 = GUICreate("Form1", 286, 113, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $MenuItem1 = GUICtrlCreateMenu("MenuItem1") GUICtrlSetOnEvent(-1, "MenuItem1Click") $MenuItem2 = GUICtrlCreateMenu("MenuItem2") GUICtrlSetOnEvent(-1, "MenuItem2Click") $MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2) GUICtrlSetOnEvent(-1, "MenuItem3Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func MenuItem1Click() EndFunc Func MenuItem2Click() #include <msg.au3> ;in msg.au3: MsgBox(0,"1","1") EndFunc Func MenuItem3Click() #include <ComputerID.au3> EndFunc Here it works with the simple example msg.au3, but doesn't with the part I want to include, ComputerID.au3 it gives me an error: C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\CompInfo.au3(53,1) : ERROR: syntax error Func ^ Hope you can help me, if I should explain more specific then please ask Regards Link to comment Share on other sites More sharing options...
Swift Posted February 21, 2008 Share Posted February 21, 2008 Hello I've now tryied so many things an doesn't now what to do anymore. so I hoped that you could help I want to call a part of the script when for example pressing $MenuItem3 look at the examples below: First I tried with getmsg: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\Form1.kxf $Form1 = GUICreate("Form1", 286, 113, 193, 125) $MenuItem1 = GUICtrlCreateMenu("MenuItem1") $MenuItem2 = GUICtrlCreateMenu("MenuItem2") $MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem3 #include <msg.au3> ;in msg.au3 : MsgBox(0,"status","Hello") EndSwitch WEnd And here it wouldn't work even if it's a very simple example :/ it gives me the error: C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\CompInfo.au3(53,1) : ERROR: syntax error Func ^ so I tried with onEvent: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form=C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\Form1.kxf $Form1 = GUICreate("Form1", 286, 113, 193, 125) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize") GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize") GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore") $MenuItem1 = GUICtrlCreateMenu("MenuItem1") GUICtrlSetOnEvent(-1, "MenuItem1Click") $MenuItem2 = GUICtrlCreateMenu("MenuItem2") GUICtrlSetOnEvent(-1, "MenuItem2Click") $MenuItem3 = GUICtrlCreateMenuItem("MenuItem3", $MenuItem2) GUICtrlSetOnEvent(-1, "MenuItem3Click") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() EndFunc Func Form1Maximize() EndFunc Func Form1Minimize() EndFunc Func Form1Restore() EndFunc Func MenuItem1Click() EndFunc Func MenuItem2Click() #include <msg.au3> ;in msg.au3: MsgBox(0,"1","1") EndFunc Func MenuItem3Click() #include <ComputerID.au3> EndFunc Here it works with the simple example msg.au3, but doesn't with the part I want to include, ComputerID.au3 it gives me an error: C:\Documents and Settings\FARCRY\Skrivebord\test eksempel\CompInfo.au3(53,1) : ERROR: syntax error Func ^ Hope you can help me, if I should explain more specific then please ask Regards Run(@ScriptDir & "\msg.au3") you cant #include it..becuase it will run the whole time. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2008 Moderators Share Posted February 21, 2008 Run(@ScriptDir & "\msg.au3")you cant #include it..becuase it will run the whole time.Are you kidding?@OP#include statements are not conditional options.It doesn't matter where you put it in your script, it's going to be included regardless (providing that it is actually in the \AutoIt3\Include directory) .If the #include script is in the same directory as your main script, you'd just put this at the top of your script:#include "msg.au3"or#include "Complete_Path_To_My_AU3.au3" Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Swift Posted February 21, 2008 Share Posted February 21, 2008 Got the wrong idea there Smoke_N...I meant that...you dont want to #include you file...at least I dont...I run them...but he can do whatever Link to comment Share on other sites More sharing options...
newbiescripter Posted February 21, 2008 Author Share Posted February 21, 2008 (edited) The problem is when I #include <msg.au3> in the top of my script then it just run msg.au3 at the beginning of the script. I only want it to run, when you press on $MenuItem3 for example. Can I include it without nothing happens and then call the function in it for a later time ? Edited February 21, 2008 by newbiescripter Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 21, 2008 Moderators Share Posted February 21, 2008 The problem is when I #include <msg.au3> in the top of my script then it just run msg.au3 at the beginning of the script. I only want it to run, when you press on $MenuItem3 for example.Can I include it without nothing happens and then call the function in it for a later time ?I have no idea what msg.au3 is, but maybe you should make them just functions... that way you can call any of them when you want to... otherwise, it's more than likely not going to work correctly. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
newbiescripter Posted February 21, 2008 Author Share Posted February 21, 2008 I find the solution. Thanks for your help. I just make for example msg.au3 to one function. I did the same before but I were including an extra .au3 file in the function and that cause the error, so now i just include that and then call the function.. Hope you understand but now it works.. Thanks Link to comment Share on other sites More sharing options...
newbiescripter Posted February 21, 2008 Author Share Posted February 21, 2008 (edited) I have one question more. Is it possible to create a button like the following: #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> $Menu = GUICreate("MENU", 374, 203, 456, 204) $MenuItem1 = GUICtrlCreateMenu("Homepage") GUISetState(@SW_SHOW) While 1 WEnd Which I can click and then something happens without I have to create a submenu?. Edited February 21, 2008 by newbiescripter Link to comment Share on other sites More sharing options...
newbiescripter Posted February 22, 2008 Author Share Posted February 22, 2008 Is it really impossible? Do I really have to make a subcontrol by GUICtrlCreateMenuItem?. Is there some way to make a button in the menu with out making a submenu with the control ? 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