Jump to content

GUI/Tray Menu with icons and colors


Holger
 Share

Recommended Posts

Hi again Holger.

I was wondering, is that would be possible to make two more functions:

1) _SetTraySideImage($sImage) -> It will set an image for the tray menu, like this one have (here the DAEMON Tools Pro is the side image):

Posted Image

Can this be done? I would love to see this as an option in future versions of this UDF!

My .02 cents

GoogleDude

Link to comment
Share on other sites

  • 2 weeks later...

There is a bug in _GUICtrlODMenuItemSetText() and _TrayItemSetText()...

It's just removes all(?) states from the items :)

Example:

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

#NoTrayIcon

$hMainGUI = GUICreate("Sample Menu")

$Menu = GUICtrlCreateMenu("Menu")
$Item = _GUICtrlCreateODMenuItem("Menu Item", $Menu)
GUICtrlSetState(-1, BitOR($GUI_CHECKED, $GUI_DISABLE))

;Uncomment next line, and you will see that the item is no more disabled and it's not checked
;_GUICtrlODMenuItemSetText($Item, "New Item Text")

GUISetState()


$TrayIcon = _TrayIconCreate("Test", "shell32.dll", 130)

$TrayItem = _TrayCreateItem(-1, "Tray Item", 0, -1, 1)
GUICtrlSetState(-1, BitOR($GUI_CHECKED, $GUI_DISABLE))

;Uncomment next line, and you will see that the item is no more disabled and it's not checked
;_TrayItemSetText(-1, "New Tray Item Text")


While 1
    $Msg = GUIGetMsg()
    
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            _TrayIconDelete($TrayIcon)
            Exit
    EndSwitch
WEnd

 

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

Ok, Here is a fix:

;********************************************************************
; Set the text of an menu item
;********************************************************************
Func _TrayItemSetText($nMenuID, $sText)
    If $nMenuID = -1 Then $nMenuID = $MENULASTITEM
    If $nMenuID <= 0 Then Return 0
    
    Local $i, $nItem_State
    
    For $i = 1 To $arMenuItems[0][0]
        If $arMenuItems[$i][0] = $nMenuID Then
            $arMenuItems[$i][1] = $sText
            $nItem_State = GUICtrlRead($nMenuID)
            _SetOwnerDrawn($arMenuItems[$i][3], $nMenuID, $sText, FALSE)
            GUICtrlSetData($nMenuID, $sText)
            _SetOwnerDrawn($arMenuItems[$i][3], $nMenuID, $sText)
            GUICtrlSetState($nMenuID, $nItem_State)
            Return 1
        EndIf
    Next
    
    Return 0
EndFunc

;********************************************************************
; Set the text of an menu item
;********************************************************************
Func _GUICtrlODMenuItemSetText($nMenuID, $sText)
    If $nMenuID = -1 Then $nMenuID = $MENULASTITEM
    If $nMenuID <= 0 Then Return 0
    
    Local $i, $nItem_State
    
    For $i = 1 To $arMenuItems[0][0]
        If $arMenuItems[$i][0] = $nMenuID Then
            $arMenuItems[$i][1] = $sText
            $nItem_State = GUICtrlRead($nMenuID)
            _SetOwnerDrawn($arMenuItems[$i][3], $nMenuID, $sText, FALSE)
            GUICtrlSetData($nMenuID, $sText)
            _SetOwnerDrawn($arMenuItems[$i][3], $nMenuID, $sText)
            GUICtrlSetState($nMenuID, $nItem_State)
            Return 1
        EndIf
    Next
EndFunc

I think/hope that the fix is correct :)

 

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

  • 2 weeks later...

Hi again Holger.

1) _SetTraySideImage($sImage) -> It will set an image for the tray menu, like this one have (here the DAEMON Tools Pro is the side image):

Posted Image

Any news on this function?

Thanks in advance

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

Will it be included in the standard UDFs ?

It hasn't been in the 2+ years that it's been around so don't hold your breath while you're waiting.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hi,

Maybe try this ...

; CTRL+ALT+M
HotKeySet('+!m', 'MenuOnHotKey')

$nTrayIcon = _TrayIconCreate('My TrayIcon')
_TrayIconSetClick(-1, 16)

; etc, etc ...


Func MenuOnHotKey()
    
    
    _SysTray_ClickItem('My TrayIcon', "right", 1)
    
EndFunc

;====================================================================================
;
;Function Name:    _SysTray_ClickItem()
;Description:      Click on item in Windows system tray by any substring in the title
;Parameters:       $iTitle - The title of the item in Windows system tray (you can see the title of the item when mouse cursor hovered on item).
;                  $iButton - [optional] The button to click, "left" or "right". Default is the left button.
;                  $iClick - [optional] The number of times to click the mouse. Default is 2
;                 
;Return Value(s):  None
;Requirement(s):   AutoIt 3.2.10.0
;
;
;Autor(s):        R.Gilman (a.k.a rasim); Siao (Thanks for idea smile.gif)
;
;====================================================================================
Func _SysTray_ClickItem($iTitle, $iButton = "left", $iClick = 2)
    Local $hToolbar, $iButCount, $aRect, $i
   
    If Not $iTitle Then
        MsgBox(16, "Error", "Please indicate title")
        Return 0
    EndIf
   
    $hToolbar = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
    If @error Then
        MsgBox(16, "Error", "System tray not found")
        Return 0
    EndIf
   
    $iButCount = _GUICtrlToolbar_ButtonCount($hToolbar)
    If $iButCount = 0 Then
        MsgBox(16, "Error", "Not found item in system tray")
        Return
    EndIf
   
    For $i = 0 To $iButCount - 1
        $cID = _GUICtrlToolbar_IndexToCommand($hToolBar, $i)
        If StringInStr(_GUICtrlToolbar_GetButtonText($hToolBar, $i), $iTitle) Then
            $aRect = _GUICtrlToolbar_GetButtonRect($hToolBar, $i)
            ControlClick("[Class:Shell_TrayWnd]", "", "ToolbarWindow321", $iButton, $iClick, $aRect[0], 5)
            $aRect = 0
            Return 1
        EndIf
    Next
    MsgBox(48, "Fail", "Required item not found")
EndFunc

Greetz

Greenhorn

Link to comment
Share on other sites

How can i make something extra happen when the tray is open ok ill rephrase that how do i know if this tray is opened by the corresponding button set by _TrayIconSetClick

Bottom line how can i check or induce tray menu showing

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

I need a way to detect if the tray menu created with modernmenu library is open because it creates a separate tray icon and not the original one so i need a way to be absolutely sured when this exact one menu that was created by the library is open

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

Ok lost a few hairs and still going strong. if somebody can plz for the sake of me not spending cash on demoxinyl. which value goes true or false or 1 or 0 or whatever when the blasted tray menu is on or off

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

i dont know im getting really frustrated either im dead stupid and im not seeing something thats in front of my eyes or im asking a hard @ss question :D

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

anybody? {scooby voice} reeeeelp {/scooby voice}

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

I cant believe that nobody can help me with this problem. Is it possible that nobody uses this library? Ill try to explain my situation. Ok so when the menu opens i want something to happen I tried the wingetpos-ish approach using the class 32768 (but all trays are that class) so i need something to narrow it down. If I could be directed to a var or array function or anything that either gives me the handle of the menu (note that every time you open the menu its handle changes slightly) or it gives me a value of the new trays state (opened state)

thanks in advance

EDIT: Excuse me Holger I didnt notice that you have posted. Please excuse me for my impulsive behaviour but this is really getting to my nerve ive been probing your script and i didnt find anything that could lead me to my answer or even near it. If you could point me to the function that actually opens the tray when the button set with _TrayIconSetClick I would be very grateful. PM'd

Edited by C2C

----------------------------------90% of teens today would die if Myspace,Bebo + FaceBook had a system failure and was completely destroyed. If you are one of the 10% that would be laughing, copy and paste this to your signature.----------------------------------Code to win, 'till you die, 'till the compiler dies from your linesCode to win, take it all, just keep coding till you fallDay by day, codin' all the way, I'm not cavin' inLet another App begin, code to win

Link to comment
Share on other sites

EDIT: Excuse me Holger I didnt notice that you have posted. Please excuse me for my impulsive behaviour but this is really getting to my nerve ive been probing your script and i didnt find anything that could lead me to my answer or even near it. If you could point me to the function that actually opens the tray when the button set with _TrayIconSetClick I would be very grateful. PM'd

You have your answer from Holger (who wrote those functions) so you will have to do some further searching.

BTW; many people, including me, seldom reply to PM's from people who want private assistance. Don't be surprised if it takes a while to get a reply.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Just for info: there is something already implemented (I just forgot).

If you 'create' one tray icon just use the additional option which is also shown in the sample files and in the 'commands.txt' in the ZIP:

_TrayIconCreate(Tooltip, IconFile, IconID, CallBack-function)oÝ÷ Ùú+{-jw)¶¬jëh×6$TrayIcon1 = _TrayIconCreate("My tooltip", "shell32.dll", -14, "MyTrayCallBack")
...
Func MyTrayCallback($nID, $nMsg)
   Switch $nID
      Case $nTrayIcon1
         If $nMsg = $WM_RBUTTONUP Then ...do your stuff here
   EndSwitch
EndFunc

But you just also have to notice that if you are moving your mouse while 'doing your stuff here' then the tray context menu maybe will be shown on another posistion!

Holger

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