Jump to content

GUI/Tray Menu with icons and colors


Holger
 Share

Recommended Posts

Update: 21.03.2008

- Added: _TrayIconSetState() modes 4 and 8 for flashing and flashstopping of tray icons

If $nState > 2 And $nState < 1 Then Return 0 ; Only 1 and 2 are possible

It's very strange string! Do you think so?

_TrayIconDelete -This function don't destroy Icon in tray

Link to comment
Share on other sites

Thanks nickston for feedback :)

Yeah, I think more than 2 eyes are always see more than just 2 :)

Greets

Holger

P.S: next update I will add a small readme.txt with all of the possible commands.

Edited by Holger
Link to comment
Share on other sites

Thanks nickston for feedback :)

Yeah, I think more than 2 eyes are always see more than just 2 :)

Greets

Holger

P.S: next update I will add a small readme.txt with all of the possible commands.

In fact, I obtained all functions which I will need for my programm, they all work correctly. Big THANKS for YOU. And special Thanks for rebuild you script so quickly.

I have tested these functions:

_TrayIconCreate

_TrayCreateItem

_TrayItemSetIcon

_trayiconsetstate

_TrayIconSetToolTip

_TrayDeleteItem

_TrayIconDelete

Link to comment
Share on other sites

If $nState > 2 And $nState < 1 Then Return 0 ; Only 1 and 2 are possible

It's very strange string! Do you think so?

Should be «If $nState > 2 Or $nState < 1 Then ....» i guess?

@Holger

Thanks for the update.

I found a little bug too :) ...

This:

If @AutoitVersion <= "3.2.10.0" Then
    $bUnicode = @Unicode
Else
    $bUnicode = @AutoItUnicode
EndIf

doesn't work well (on 3.2.10.0), it should be something like this i think:

If Number(StringReplace(@AutoitVersion, ".", "")) <= 32100 Then
    $bUnicode = @Unicode
Else
    $bUnicode = @AutoItUnicode
EndIf

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Update 23.03.2008:

!!! Warning: Please update all your scripts and add after _TrayIconCreate() the command _TrayIconSetState() - otherwise you will not see any tray icons!!!

Also update your icon numbers like for GUI icons

- Fixed: some things (thanks to nickston)

- Changed: _TrayIconCreate() do not show automatically the icon

- Changed: icon behaviour now more similar to GUI icons (I hope)

- Added: command.txt

- Removed: unicode macro

P.S. if someone needs a Win95/98 version then please let me know (cause I removed the ANSI spport, it's only unicode now).

Edited by Holger
Link to comment
Share on other sites

Should be «If $nState > 2 Or $nState < 1 Then ....» i guess?

None, The Tray icon can have some more state (4 and 8 for flash and flashstopping of tray icons) but this string can only 1 or 2.

I found a little bug too :) ...

This:

If @AutoitVersion <= "3.2.10.0" Then
    $bUnicode = @Unicode
Else
    $bUnicode = @AutoItUnicode
EndIf

doesn't work well (on 3.2.10.0), it should be something like this i think:

If Number(StringReplace(@AutoitVersion, ".", "")) <= 32100 Then
    $bUnicode = @Unicode
Else
    $bUnicode = @AutoItUnicode
EndIf

What do you think about this: @AutoItUnicode- ERROR: undefined macro.

Link to comment
Share on other sites

Update 23.03.2008:

!!! Warning: Please update all your scripts and add after _TrayIconCreate() the command _TrayIconSetState() - otherwise you will not see any tray icons!!!

Also update your icon numbers like for GUI icons

- Fixed: some things (thanks to nickston)

- Changed: _TrayIconCreate() do not show automatically the icon

- Changed: icon behaviour now more similar to GUI icons (I hope)

- Added: command.txt

- Removed: unicode macro

Thanks to Holger.

Link to comment
Share on other sites

This is just FANTASTIC timing , Holger *Grinz* , I was just developing a tray application, when bang, you posted an update to your modern menu just today.

My hats off to you. Great Work :)

01000001 01110101 01110100 01101111 01001001 01110100 00100000
An immortal object must be copied, so that we get a mortal copy of it, since we try not to destroy immortal objects.
Link to comment
Share on other sites

What do you think about this: @AutoItUnicode- ERROR: undefined macro.

This macro was added in the latest beta. But strangly it doesn't mentioned in the changelog.

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The functions use BGR-values, so just modify your value to something like: 0x288CC8.

For the next version I will change that with an included command to change the color mode, which is by default in BGR-mode (to not break old scripts).

Link to comment
Share on other sites

if file of icons is "shell32.dll" and icon ids are 244 and 147 then now icon looks right

but 23 and -239 have stop working right, ealier it work. :)

Oops, It's my crude error, bad numbers which have work right with old ModernMenu, but MM is correct now and I must shall correcting my wrong numbers.
Link to comment
Share on other sites

I have been playing around with this and ran into a problem with the _TrayDeleteItem function. I'm not sure if it's a bug or just something dumb that I'm doing. The problem has to do with deleting a menu. I can delete items fine until I try to delete a menu. After deleting a menu the script will no longer be able to delete an item and I can no longer exit the tray menu by clicking on Exit. If you look at the section of code below you can see what I'm talking about. The entire sample script is also attached. Any help would be greatly appreciated.

Case $TrayDelete

; This order deletes the three objects but I can't exit the menu.

_TrayDeleteItem($TrayRun)

_TrayDeleteItem($TrayDelete)

_TrayDeleteItem($MenuMenu)

; This order deletes the "Menu" menu but not the other two and I can't exit the menu.

_TrayDeleteItem($MenuMenu)

_TrayDeleteItem($TrayRun)

_TrayDeleteItem($TrayDelete)

Sample Tray With Icons-OnEvent (_TrayDeleteItem Problem).au3

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

#NoTrayIcon

Opt("GUIOnEventMode", 1)

$nTrayIcon1     = _TrayIconCreate("Tools", "shell32.dll", -13)
_TrayIconSetClick(-1, 16)
_TrayIconSetState()

$MenuMenu       = _TrayCreateMenu(-1, "Menu")
_TrayItemSetIcon(-1, "", 0)

_TrayCreateItem(-1, "")
_TrayItemSetIcon(-1, "", 0)

$TrayAdvanced   = _TrayCreateItem(-1, "Modern", $MenuMenu, -1, 1)
_TrayItemSetIcon(-1, "", 0)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetOnEvent(-1, "MenuEvents")

$TraySimple     = _TrayCreateItem(-1, "Classic", $MenuMenu, -1, 1)
_TrayItemSetIcon(-1, "", 0)
GUICtrlSetOnEvent(-1, "MenuEvents")

$MenuDrives     = _TrayCreateMenu(-1, "Driveinfo")
_TrayItemSetIcon(-1, "shell32.dll", -9)

_TrayCreateItem(-1, "")
_TrayItemSetIcon(-1, "", 0)

$MenuTools      = _TrayCreateMenu(-1, "Tools")
_TrayItemSetIcon(-1, "shell32.dll", -20)
_TrayItemSetSelIcon(-1, "shell32.dll", -44)

$TrayCalc       = _TrayCreateItem(-1, "Calculator", $MenuTools)
_TrayItemSetIcon(-1, "calc.exe", 0)
GUICtrlSetOnEvent(-1, "MenuEvents")

$TrayCMD        = _TrayCreateItem(-1, "CMD", $MenuTools)
_TrayItemSetIcon(-1, "cmd.exe", 0)
GUICtrlSetOnEvent(-1, "MenuEvents")

$TrayNotepad    = _TrayCreateItem(-1, "Notepad", $MenuTools)
_TrayItemSetIcon(-1, "notepad.exe", 0)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetOnEvent(-1, "MenuEvents")

$TrayRegedit    = _TrayCreateItem(-1, "Regedit", $MenuTools)
_TrayItemSetIcon(-1, "regedit.exe", 0)
GUICtrlSetOnEvent(-1, "MenuEvents")

_TrayCreateItem(-1, "")
_TrayItemSetIcon(-1, "", 0)

$TrayDelete     = _TrayCreateItem(-1, "Delete Menu and Run Items")
GUICtrlSetState(-1, $GUI_DEFBUTTON)
GUICtrlSetOnEvent(-1, "MenuEvents")
_TrayItemSetIcon(-1, "shell32.dll", -24)

$TrayRun        = _TrayCreateItem(-1, "Run...")
_TrayItemSetIcon(-1, "shell32.dll", -25)
GUICtrlSetOnEvent(-1, "MenuEvents")

_TrayCreateItem(-1, "")
_TrayItemSetIcon(-1, "", 0)

$TrayExit       = _TrayCreateItem(-1, "Exit")
_TrayItemSetIcon(-1, "shell32.dll", -28)
GUICtrlSetOnEvent(-1, "MenuEvents")

_TrayCreateItem(-1, "Free Space:", $MenuDrives)
_TrayCreateItem(-1, "", $MenuDrives)

$arDrives = DriveGetDrive("FIXED")
For $i = 1 To $arDrives[0]
    _TrayCreateItem(-1, StringUpper($arDrives[$i]) & " -> " & _
        StringFormat("%.2f GB", DriveSpaceFree($arDrives[$i])), $MenuDrives)
Next


While 1
    Sleep(10)   
WEnd


Exit


Func MenuEvents()
    Local $Msg = @GUI_CtrlID
    
    Switch $Msg
        Case $GUI_EVENT_CLOSE, $TrayExit
            _TrayIconDelete($nTrayIcon1)
            Exit
                
        Case $TrayAdvanced, $TraySimple
            If BitAnd(GUICtrlRead($TraySimple), $GUI_CHECKED) Then
                GUICtrlSetState($TraySimple, $GUI_UNCHECKED)
                GUICtrlSetState($TrayAdvanced, $GUI_CHECKED)
                $bUseAdvTrayMenu = TRUE
            Else
                GUICtrlSetState($TraySimple, $GUI_CHECKED)
                GUICtrlSetState($TrayAdvanced, $GUI_UNCHECKED)
                $bUseAdvTrayMenu = FALSE
            EndIf
            
        Case $TrayDelete
        ; This order deletes the three objects but I can't exit the menu.
            _TrayDeleteItem($TrayRun)
            _TrayDeleteItem($TrayDelete)
            _TrayDeleteItem($MenuMenu)
            
        ; This order deletes the "Menu" menu but not the other two and I can't exit the menu.
;           _TrayDeleteItem($MenuMenu)
;           _TrayDeleteItem($TrayRun)
;           _TrayDeleteItem($TrayDelete)
            
        Case $TrayCalc
            ShellExecute("calc.exe")
            
        Case $TrayCMD
            ShellExecute("cmd.exe")
            
        Case $TrayNotepad
            ShellExecute("notepad.exe")
            
        Case $TrayRegedit
            ShellExecute("regedit.exe")     

        Case $TrayRun
            Send("#r")      
    EndSwitch
EndFunc

Thanks in advance.

Link to comment
Share on other sites

There is a bigger problem in deleting items from a contextmenu/dropdown menu with using "GUICtrlDelete()" which I use internally in the script.

I think at the beginning of the GUI menu stuff and context menus I did a mistake :)

At the moment I'm still searching for this logical problem.

Holger

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