Jump to content
Sign in to follow this  
AppTux

Read a menu

Recommended Posts

AppTux

I´ve got a script with a menu used ModernMenuRaw.au3. http://www.autoitscript.com/forum/index.php?showtopic=20967

I want to read a menuitem.

There´s no function added. I tried GUICtrlRead(), but that doesn't work.

How can I read these?

#include <GUIConstants.au3>
#include <ModernMenuRaw.au3>

#NoTrayIcon

$GUI = GUICreate("My GUI")

$Menu1 = GUICtrlCreateMenu("MyMenu1")

$MenuItem1 = _GUICtrlCreateODMenuItem("Number 1",$Menu1,"",0,1) ;Create a menu Item with a radio
GUICtrlSetState($MenuItem1,$GUI_CHECKED)
$MenuItem2 = _GUICtrlCreateODMenuItem("Number 2",$Menu1,"",0,1)
SetColors()

$Button1 = GUICtrlCreateButton("Click Me!",40,100,200,50)

GUISetState()
While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button1
        $Item1Inf = GUICtrlRead($MenuItem1)
        $Item2Inf = GUICtrlRead($MenuItem2)
        
        If $Item1Inf = 1 Then
            MsgBox(0,"Information","$MenuItem1 is checked")
        ElseIf $Item2Inf = 0 Then
            MsgBox(0,"Information","$MenuItem2 is checked")
        Else
            MsgBox(16,"Information","Nothing is checked!!!")
        EndIf
    Case $MenuItem1
        GUICtrlSetState($MenuItem1,$GUI_CHECKED)
        GUICtrlSetState($MenuItem2,$GUI_UNCHECKED)
    Case $MenuItem2
        GUICtrlSetState($MenuItem2,$GUI_CHECKED)
        GUICtrlSetState($MenuItem1,$GUI_UNCHECKED)
    EndSwitch
WEnd

Func SetColors()
    _SetMenuBkColor(0xFFFFFF)
    _SetMenuIconBkColor(0xFFEFE3)
    _SetMenuIconBkGrdColor(0xE4AD87)
    _SetMenuSelectBkColor(0xC2EEFF)
    _SetMenuSelectRectColor(0x800000)
    _SetMenuSelectTextColor(0x000000)
    _SetMenuTextColor(0x000000)
EndFunc

PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

Share this post


Link to post
Share on other sites
AppTux

I've found by my own a solution.

Now I use vars like this:

#include <GUIConstants.au3>
#include <ModernMenuRaw.au3>

#NoTrayIcon

$Item1Inf = 1 ;Item 1 is checked
$Item2Inf = 0 ;Item 2 is checked

$GUI = GUICreate("My GUI")

$Menu1 = GUICtrlCreateMenu("MyMenu1")

$MenuItem1 = _GUICtrlCreateODMenuItem("Number 1",$Menu1,"",0,1) ;Create a menu Item with a radio
GUICtrlSetState($MenuItem1,$GUI_CHECKED)
$MenuItem2 = _GUICtrlCreateODMenuItem("Number 2",$Menu1,"",0,1)
SetColors()

$Button1 = GUICtrlCreateButton("Click Me!",40,100,200,50)

GUISetState()
While 1
    Switch GUIGetMsg()
    Case $GUI_EVENT_CLOSE
        Exit
    Case $Button1
        If $Item1Inf = 1 Then
            MsgBox(0,"Information","$MenuItem1 is checked")
        ElseIf $Item2Inf = 1 Then
            MsgBox(0,"Information","$MenuItem2 is checked")
        Else
            MsgBox(16,"Information","Nothing is checked!!!")
        EndIf
    Case $MenuItem1
        $Item1Inf = 1
        $Item2Inf = 0
        GUICtrlSetState($MenuItem1,$GUI_CHECKED)
        GUICtrlSetState($MenuItem2,$GUI_UNCHECKED)
    Case $MenuItem2
        $Item1Inf = 0
        $Item2Inf = 1
        GUICtrlSetState($MenuItem2,$GUI_CHECKED)
        GUICtrlSetState($MenuItem1,$GUI_UNCHECKED)
    EndSwitch
WEnd

Func SetColors()
    _SetMenuBkColor(0xFFFFFF)
    _SetMenuIconBkColor(0xFFEFE3)
    _SetMenuIconBkGrdColor(0xE4AD87)
    _SetMenuSelectBkColor(0xC2EEFF)
    _SetMenuSelectRectColor(0x800000)
    _SetMenuSelectTextColor(0x000000)
    _SetMenuTextColor(0x000000)
EndFunc

Sorry for that unnecessary topic. :D

I'll try to look first good at my script and find a solution before I start a topic. :huggles:


PowerSlide2UnlockiPhone look-a-like program you can use to lock your pc, you can't access your desktop again until the password is entered and the slider slided to the right. (really proud of it)-- After a time AutoIt and Windows, I switched to Mac. Don't expect me to answer anymore.

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  

×