Sign in to follow this  
Followers 0
MrCreatoR

TrayItemCreate() Limit?

11 posts in this topic

Hi all,

I have notice that when you create more then 510 tray items dinamicly, the event of the last item (wich is Exit in my case) is called...

Check this example...

HotKeySet("^i", "Input")
Opt("TrayMenuMode", 1)

Global $OptionsArray[4]
Global $DefaultNumber = 1

$ChooseOption = TrayCreateItem("Set Number of Tray items..")

For $i = 1 To UBound($OptionsArray)-1
    $OptionsArray[$i] = TrayCreateItem("Item " & $i)
Next

$Seperator = TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")

While 1
    $TrayMsg = TrayGetMsg()
    Select
        Case $TrayMsg = $ChooseOption
            Input()
        Case $TrayMsg = $ExitItem 
            Exit 1
    EndSelect 
WEnd

Func Input()
    $Ubound = UBound($OptionsArray)
    
    While 1
        $Var = InputBox("", "Type number of Tray Items:", $DefaultNumber)
        If @error Then Return
        
        If StringRegExpReplace($Var, '[^0-9]', '') = '' Then
            MsgBox(48, "Attention!", "Typed an incorrect number" & @LF & "Please type again..", 5)
            ContinueLoop
        EndIf
        ExitLoop
    WEnd
    
    If $Var = $Ubound-1 Then Return
    
    TrayItemDelete($Seperator)
    TrayItemDelete($ExitItem)
    
    If $Var > $Ubound-1 Then
        ReDim $OptionsArray[$Var+1]
        For $i = $Ubound To $Var
            $OptionsArray[$i] = TrayCreateItem("Item " & $i)
        Next
    Else
        For $i = $Var+1 To $Ubound-1
            TrayItemDelete($OptionsArray[$i])
        Next
        ReDim $OptionsArray[$Var+1]
    EndIf
    
    $DefaultNumber = $Var
    
    $Seperator = TrayCreateItem("")
    $ExitItem = TrayCreateItem("Exit")
EndFunc

Press Ctrl I (or select item "Set Number of Tray items.." from the tray menu), type there number 510, then script is exiting (i mean exiting by event, check it using 1 after Exit command).

If you type a lower number then 510, then everything is ok, the script is not exit...

When i change it to events mode (Opt("TrayOnEventMode", 1)), this problem not exists (after few tunings), but i can not understand what the problem here with standard mode?

I guesing that this is because the TrayGetMsg() return always zero if there is no messages, but when i delete the Tray Item and recreate it again, variavble of this item become to be zero as well (the Exit Item) - Maybe this is a bug of TrayCreateItem()?


 

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

Share this post


Link to post
Share on other sites



HotKeySet("^i", "Input")
Opt("TrayMenuMode", 1)

Global $OptionsArray[4]
Global $DefaultNumber = 1

$ChooseOption = TrayCreateItem("Set Number of Tray items..")

For $i = 1 To UBound($OptionsArray)-1
    $OptionsArray[$i] = TrayCreateItem("Item " & $i)
Next

$Seperator = TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")

While 1
    $TrayMsg = TrayGetMsg()
    Select
        Case $TrayMsg = $ChooseOption
            Input()
        Case $TrayMsg = $ExitItem
            Exit 1
    EndSelect 
WEnd

Func Input()
    $Ubound = UBound($OptionsArray)
    
    While 1
        $Var = InputBox("", "Type number of Tray Items:", $DefaultNumber)
        If @error Then Return
        
        If StringRegExpReplace($Var, '[^0-9]', '') = '' Then
            MsgBox(48, "Attention!", "Typed an incorrect number" & @LF & "Please type again..", 5)
            ContinueLoop
        EndIf
        ExitLoop
    WEnd
    
    If $Var = $Ubound-1 Then Return
    
;~     TrayItemDelete($Seperator)
;~     TrayItemDelete($ExitItem)
    
    If $Var > $Ubound-1 Then
        ReDim $OptionsArray[$Var+1]
        For $i = $Ubound To $Var
            $OptionsArray[$i] = TrayCreateItem("Item " & $i, -1, $i)
        Next
    Else
        For $i = $Var+1 To $Ubound-1
            TrayItemDelete($OptionsArray[$i])
        Next
        ReDim $OptionsArray[$Var+1]
    EndIf
    
    $DefaultNumber = $Var
    
;~     $Seperator = TrayCreateItem("")
;~     $ExitItem = TrayCreateItem("Exit")
EndFunc


"be smart, drink your wine"

Share this post


Link to post
Share on other sites

According to the help file the limit is 505 items although it runs in my mind (easily wrong) that it didn't crash for me until I was close to 700


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!"

Share this post


Link to post
Share on other sites

Do 510 tray items even fit on the screen?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Fact is you don't need to delete that separator and Exit control to insert items.

And it works fine with more than 65535+ controls on my WinXP.

The limit documentation is probably for Win95 support, as usual.

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Thanks Siao, i forgout about the aditional paramters...

But why it's happend with my example? i mean, why when i create 510 items the $ExitItem is = 0?

Oh i see now, because the limit, last item is not created, this why it returns 0... it seems that you beat the limit Siao :) - Maybe we should report about it (for doc clarification).

Edited by MsCreatoR

 

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Oh i see now, because the limit, last item is not created, this why it returns 0... it seems that you beat the limit Siao :) - Maybe we should report about it (for doc clarification).

Yea, it would seem that specifying menuentry parameter makes AutoIt skip that silly max items check...

otherwise the last possible controlID is 518 and then it resets to 0

Edited by Siao

"be smart, drink your wine"

Share this post


Link to post
Share on other sites

Yea, it would seem that specifying menuentry parameter makes AutoIt skip that silly max items check...

Probably right. When I last wrote a major tray app (about 2 years ago) we didn't have the parameter.

@Richard Robertson

Do 510 tray items even fit on the screen?

No. They scroll just like a long menu.

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!"

Share this post


Link to post
Share on other sites

@Siao

it works fine with more than 65535+ controls on my WinXP

Are you sure? i mean, there is really that much item created? you can check it if you move the mouse over the toppest item (when you click on the tray icon), and press Up key on the keyboard.

Because i can't get it work, it create only 513 items :P (if i use no second parameter, then only 511).


 

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

Share this post


Link to post
Share on other sites

@Siao

Are you sure? i mean, there is really that much item created? you can check it if you move the mouse over the toppest item (when you click on the tray icon), and press Up key on the keyboard.

Because i can't get it work, it create only 513 items :P (if i use no second parameter, then only 511).

Perhaps there is a difference in what's beng created here? Try using TrayCreateMenu() for the first 510 and then see if you can create 510 MenuItems for each of those.

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!"

Share this post


Link to post
Share on other sites

Try using TrayCreateMenu() for the first 510 and then see if you can create 510 MenuItems for each of those

Yes, but i thought that Siao has created that mutch items in one menu :P

 

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

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