Jump to content

GUI with menu


 Share

Recommended Posts

Nooooo, it's not implemented yet.

I played a little bit around and found a good lesson about menu-programming...

Here is my first GUI with a menu :huh2:

At the moment it's more like "Hello world" you know...

Here is a sample:

http://www.autoitscript.com/fileman/users/public/Holger/guiwithmenu.jpg

BUT: don't think about it in the next few weeks, it takes some time to learn c++ (for me)...

Maybe YOU want to develope this new 'control' :D

I hope I'll find time to learn more about menu's...

Regards Holger

Edited by Holger
Link to comment
Share on other sites

Nooooo, it's not implemented yet.

I played a little bit around and found a good lesson about menu-programming...

Here is my first GUI with a menu   :huh2:

At the moment it's more like "Hello world" you know...

Here is a sample:

... image ...

BUT: don't think about it in the next few weeks, it takes some time to learn c++ (for me)...

Maybe YOU want to develope this new 'control'  :D

I hope I'll find time to learn more about menu's...

Regards Holger

Too bad... I was just about to say "Thank you".

I hope someone else figures this out.

I wanted this some time ago, but I forgot to post it in the "Ideas" section.

Edited by SlimShady
Link to comment
Share on other sites

@SlimShady:I would NOT say "Mission Impossible" but it takes time (I think) to realize that).

At the moment I know a little bit more about that, I use i.e. this code:

GUICreate("test",300,200)
$menu1 = GUISetMenu("menu","Menu1")
$menu2 = GUISetMenu("menu","Menu2")
$submenu1 = GUISetMenu("submenu","Submenu1",$menu1)
$item1 = GUISetMenu("item","Item1",$menu1)
$item2 = GUISetMenu("item","Item2",$menu2)
$item3 = GUISetMenu("item","Item3",$submenu1)
$buttonok = GUISetControl("button","OK",120,150,70,20)
GUISetControlNotify()
GUIShow()
While GUIMsg() <> 0
    $msg = GUIRead()
    Msgbox(0,"",$msg)
    If $msg = -3 Then ExitLoop
WENd
GUIDelete()
Exit

and it will bring up that:

http://www.autoitscript.com/fileman/users/public/Holger/guiwithsub.jpg

So the types can be: "menu", "item", "submenu" and "separator".

Now I try to change the GUIRead-function -> but it looks like that I have to use a complete/new/other function, i.e. "GUIReadMenu" cause the 'handling' in the most arrays and functions is for HWND-types and I have to use the type HMENU...

Maybe in the future I will create a equivalent function to "GUISetControlEx" and will call it "GUISetMenuEx". :D

With this you can also set the state of menus and menitems (like 'disabled', 'enabled', 'grayed out')...

So if nobody disagree with it I will post my realized new steps here you know

Regards Holger :huh2:

Edited by Holger
Link to comment
Share on other sites

I must have something diff ?

---------------------------

AutoIt Error

---------------------------

Line 3 (File "E:\Programs\AutoIt3\Examples\jul2\SetMenu.au3"):

$menu1 = GUISetMenu("menu","Menu1")

$menu1 = ^ ERROR

Error: Unknown function name.

Link to comment
Share on other sites

Just had a thought .. not sure if it's possible but could you not create a psudo menu by updating the number of buttons on the GUI?

I noticed that the last button defined on the list shows on top of others.. even when overlapping.. so in this way when you click your "menu" you could set a string of new buttons over top and when one was selected you could then reupdate the GUI to not have them anymore..

not sure if it's possible.. but it would be an interesting hack if anything :D

moo

Link to comment
Share on other sites

Hmmm...I don't know... :D

However...

I'm a little bit more in programming, so you could see a compiled script with GUIMenu-functions here:

http://www.autoitscript.com/fileman/users/public/Holger/guimenu.exe

That looks so:

http://www.autoitscript.com/fileman/users/public/Holger/guimenu.jpg

The script is a bit more complex than the 'normal' GUIScript, but I have no problems with it...

The errorchecking is only at the beginning and so on... but it grows :)

GUICreate("test",300,200)

$filemenu = GUISetMenu("menu","File")
$helpmenu = GUISetMenu("menu","?")
$fileitem = GUISetMenu("item","Open...",$filemenu)
$aboutitem = GUISetMenu("item","About",$helpmenu)
$exititem = GUISetMenu("item","Exit",$filemenu)
$recentfilesmenu = GUISetMenu("submenu","Recent Files",$filemenu,1)
$separator1 = GUISetMenu("separator","",$filemenu,2)

$okbutton = GUISetControl("button","OK",50,130,70,20)
GUISetControlNotify()

$cancelbutton = GUISetControl("button","Cancel",180,130,70,20)
GUISetControlNotify()

GUIShow()
While GUIMsg() <> 0
    $msg = GUIRead()
    If $msg = -3 Or $msg = $cancelbutton Then ExitLoop
    If $msg = $fileitem Then
  $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
  If @error <> 1 Then
  ;maybe in the future weeks
  ; GUIWriteMenu(....)
    GUISetMenu("item",$file,$recentfilesmenu)
  EndIf
    EndIf
    If $msg = $exititem Then ExitLoop
    If $msg = $aboutitem Then Msgbox(0,"About","Only a test...")
WENd
GUIDelete()
Exit

But for today it's enough... :huh2: have to go sleep...

Yeah that is fun :lol:

Regards Holger

P.S.:ahh..forgot...the exe is smaller than the normal Autoit3.exe cause I exluded most functions before compiling..

Edit: 05.07.2004: GUIReadMenu is not more needed :)

Edited by Holger
Link to comment
Share on other sites

I know you guys love gui

But all this is possible already using an hta vbs, javascript, dhtml, and autoitx

Rick

You could say the same thing about AutoIt itself :D

However, an open-source, self-contained, easy-to-use scripting language that can be compiled into stand-alone EXEs that work on Windows 9x/Me/NT/2000/XP/etc. has appeal.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

You could say the same thing about AutoIt itself :D

However, an open-source, self-contained, easy-to-use scripting language that can be compiled into stand-alone EXEs that work on Windows 9x/Me/NT/2000/XP/etc. has appeal.

Choice is a great thing

I like the HTAs with auoitx because I can incorporate everything that I can on a webpage and use run in autoitx to run compiled scripts

Great combo especially for this nonreal programmer

Rick

Link to comment
Share on other sites

However:

I add the menufunctions from GUIReadMenu to GUIRead so there will be only the known function GUIRead([ctrlref]) to read out the state or value from the menu(items)...

Next will be maybe GUISetMenuEx...we will see :D

Holger :huh2:

Link to comment
Share on other sites

However:

I add the menufunctions from GUIReadMenu to GUIRead so there will be only the known function GUIRead([ctrlref]) to read out the state or value from the menu(items)...

Next will be maybe GUISetMenuEx...we will see  :huh2:

Holger :)

Yeah....Why not? :)

Great, Holger. :lol:

(Is needed for GUI additions, like a Slider control too...) :D

Link to comment
Share on other sites

I'm a little bit busy the days, but I will send the changed source-code to JPM on lately saturday so he can modify it and make it better.

The last I worked on was "GUISetMenuEx" and it worked so far (a little bit).

The most problems I had with "WM_MENUSELECT".

So if you move the mouse over a menu(item) this message will send but here it will only send the 'right' if you click another time (so that menu closes).

And I have no idea why...hmmm... :(

Maybe JPM will find something about that point.

You know this using - if you click on a menu then in many programs on the statusbar will be displayed i.e. an info about this item...

Another thing is to create radio-menu-items.

But normal check-menu-items work. :ph34r:

I changed a few days ago the code a little bit, so if you would use:

$filemenu = GUISetMenu("menu","File")

you can append an item with:

$fileitem = GUISetMenu("item","Open...",$filemenu)

or

$fileitem = GUISetMenu("item","Open...")

And if you can change the position, i.e:

$menu1 = GUISetMenu("menu","menu1")

$menu2 = GUISetMenu("menu","menu2")

$menu3 = GUISetMenu("menu","menu3",1)

That will bring the menu3 to position 1.

!!! You have to know that the positions in menus are only begin with "0" - like in arrays you know...

Ok, so long...

RU (read you) and regards

Holger :lol:

Edited by Holger
Link to comment
Share on other sites

So...I'm sending now JPM the changed things so he can take a look and make/add the right lines :ph34r:

At the moment GUISetMenuEx works so far you know.

Here is what I mean:

http://www.autoitscript.com/fileman/users/public/Holger/guiwithsetmenuex.jpg

I have updated the sample that you could see a little bit more.

You can now i.e. change the view of the statusline...

http://www.autoitscript.com/fileman/users/public/Holger/guimenu.exe

And here is the (possible) AutoIt3-script to do this:

#include "GUIConstants.au3"
Global $defaultstatus = "Ready"

GUICreate("test",300,200)
$filemenu = GUISetMenu("menu","&File")
$fileitem = GUISetMenu("item","Open",$filemenu)
GUISetMenuEx(-1,$GUI_DEFBUTTON)
$helpmenu = GUISetMenu("menu","?")
$saveitem = GUISetMenu("item","Save",$filemenu)
GUISetMenuEx(-1,$GUI_DISABLE)
$infoitem = GUISetMenu("item","Info",$helpmenu)
GUISetMenuNotify()
;$exititem = GUISetMenu("item","E&xit\tAlt+F4",$filemenu)
;still have problems with accelerators -> will not right read to internal function
$exititem = GUISetMenu("item","Exit",$filemenu)
$recentfilesmenu = GUISetMenu("submenu","Recent Files",$filemenu,1)
$separator1 = GUISetMenu("separator","",$filemenu,3)

$viewmenu = GUISetMenu("menu","View",1)
$viewstatusitem = GUISetMenu("item","Statusbar",$viewmenu)
GUISetMenuEx(-1,$GUI_CHECKED)

$okbutton = GUISetControl("button","OK",50,130,70,20)
GUISetControlNotify()
GUISetControlEx(-1,$GUI_FOCUS)
$cancelbutton = GUISetControl("button","Cancel",180,130,70,20)

$statuslabel = GUISetControl("label",$defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

GUIShow()
While 1
    $msg = GUIMsg()
;Msgbox(0,"GUIMsg_ID",$msg)
    If $msg = $fileitem Then
  $file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
  If @error <> 1 Then GUISetMenu("item",$file,$recentfilesmenu)
    EndIf 
    If $msg = $viewstatusitem Then
  If BitAnd(GUIRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
     GUISetMenuEx($viewstatusitem,$GUI_UNCHECKED)
     GUISetControlEx($statuslabel,$GUI_HIDE)
  Else
     GUISetMenuEx($viewstatusitem,$GUI_CHECKED)
     GUISetControlEx($statuslabel,$GUI_SHOW)
  EndIf
    EndIf
    If $msg = -3 Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
    If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")
WEnd
GUIDelete()
Exit

We will see what the future brings and what JPM maybe says next week...:lol:

Regards and a nice weekend :(

Holger

Link to comment
Share on other sites

  • 4 weeks later...

Ok, then I think I will look for a workaround. I saw a VB application on Planet sourcecode which let's you add menu's to any programs (all you have to know is program windows name or handle). I think I could make a C application that adds menus to my AutoITGUI scripts since I can get the handle from the script. I'm not sure if I can react to menu messages that way, but let's see...

Link to comment
Share on other sites

Ok, now I have an application I can use to add menus to my AutoIT3 GUI scripts. The problem is that I can't catch messages from menuitems.

I have added an identifier to my menuitems, say '9801' or something. Then when I try to catch a menuitem click like this:

if $msg = "9801" Then ...

It won't work. Holger, do you have any ideas? Maybe this can't be done then?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...