Sign in to follow this  
Followers 0
newbiescripter

GUI problems, when try #include <msg.au3>

9 posts in this topic

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:

#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

Share this post


Link to post
Share on other sites



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:

#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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 by newbiescripter

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by newbiescripter

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0