sam ghost Posted December 4, 2007 Share Posted December 4, 2007 hi, is it possible to create a trayicon on which i have a first menue by clicking the icon with the left mouse button and to have another menue by clicking the icon with the right mouse button? i tried to make this with the TraySetClick function but that works not. can anyone help me? thx so long sam Link to comment Share on other sites More sharing options...
GEOSoft Posted December 4, 2007 Share Posted December 4, 2007 In the Example scripts forum there is a System Time setting script. (Read On) It uses a sliding window just above the system tray. You could use that as an example to create 2 sliding windows in the correct position. Which window you have open will depend on which mouse button you use when you click on the tray icon. I use a similar method in that when one of my apps is minimized it minimizes to the system tray. Left click on the tray icon restores the window and right click closes the app. There may also be a method where you could create 3 trays. The first with no Menus at all. It is only used to create?destroy The Other two trays depending on which button is clicked. Too early in the morning to work that out. 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 More sharing options...
smashly Posted December 4, 2007 Share Posted December 4, 2007 Hi, expandcollapse popup#include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetClick(18) Global $Tray[11], $state = 2 TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TrayEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "TrayMenuLeftClick") TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, "TrayMenuRightClick") TraySetState() While 1 Sleep(100) WEnd Func TrayMenuLeftClick() If $state = 0 Or $state = 2 Then $state = 1 For $i = 6 to 10 TrayItemDelete($Tray[$i]) Next For $i = 1 to 5 $Tray[$i] = TrayCreateItem("1st Menu Item - " & $i, -1, $i -1 ) TrayItemSetOnEvent(-1, "TrayEvent") Next EndIf EndFunc Func TrayMenuRightClick() If $state = 1 Or $state = 2 Then $state = 0 For $i = 1 to 5 TrayItemDelete($Tray[$i]) Next For $i = 6 to 10 $Tray[$i] = TrayCreateItem("2nd Menu Item - " & $i - 5, -1, $i - 6) TrayItemSetOnEvent(-1, "TrayEvent") Next EndIf EndFunc Func TrayEvent() MsgBox(0, "", TrayItemGetText(@TRAY_ID)) If TrayItemGetText(@TRAY_ID) = "Exit" Then Exit EndFunc Cheers Jacov 1 Link to comment Share on other sites More sharing options...
Valuater Posted December 4, 2007 Share Posted December 4, 2007 Nice one Smashly! 8) Link to comment Share on other sites More sharing options...
sam ghost Posted December 4, 2007 Author Share Posted December 4, 2007 hi, thank you @ geosoft for the fast answer .... i searched for 'the Example scripts forum there is a System Time setting script' but i didn't found it ... thank you @ smashly ... your script works very fine ... perfect ... by the way: in the german autoit forum 'progandy' had the idea to create an invisible gui for the 'left menue', that also works fine: CODE#Include <Constants.au3> #include <GUIConstants.au3> Opt("GUIOnEventMode",1) Opt("TrayOnEventMode",1) TraySetClick(8) $PrimaryContextgui = GUICreate("My GUI Context Menu", 1, 1,@DesktopWidth+1,@DesktopHeight+1,$WS_POPUP,$WS_EX_TRANSPARENT+$WS_EX_TOOLWINDOW) $contextmenu = GUICtrlCreateContextMenu () $newsubmenu = GUICtrlCreateMenu ("new", $contextmenu) $textitem = GUICtrlCreateMenuitem ("text", $newsubmenu) $fileitem = GUICtrlCreateMenuitem ("Open", $contextmenu) $saveitem = GUICtrlCreateMenuitem ("Save", $contextmenu) GUICtrlCreateMenuitem ("", $contextmenu) ; separator $infoitem = GUICtrlCreateMenuitem ("Info", $contextmenu) GUICtrlSetOnEvent(-1,"ABOUT") GUISetState () Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN,"PRIMARY") $prefsitem = TrayCreateItem("Preferences") TrayItemSetOnEvent(-1,"PREF") TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayItemSetOnEvent(-1,"ABOUT") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TrayItemSetOnEvent(-1,"CLOSE") TraySetState() While 1 Sleep(100) WEnd Func ABOUT() Msgbox(64, "about:", "AutoIt3-Tray-sample.") EndFunc Func PRIMARY() ControlClick($PrimaryContextgui,"","","right") EndFunc Func PREF() Msgbox(64, "Preferences:", "OS:" & @OSVersion) EndFunc Func CLOSE() Exit EndFunc thx @ all so long sam Link to comment Share on other sites More sharing options...
Jacov Posted December 13, 2023 Share Posted December 13, 2023 On 12/4/2007 at 6:49 PM, smashly said: Hi, expandcollapse popup#include <Constants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetClick(18) Global $Tray[11], $state = 2 TrayCreateItem("") TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "TrayEvent") TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "TrayMenuLeftClick") TraySetOnEvent($TRAY_EVENT_SECONDARYDOWN, "TrayMenuRightClick") TraySetState() While 1 Sleep(100) WEnd Func TrayMenuLeftClick() If $state = 0 Or $state = 2 Then $state = 1 For $i = 6 to 10 TrayItemDelete($Tray[$i]) Next For $i = 1 to 5 $Tray[$i] = TrayCreateItem("1st Menu Item - " & $i, -1, $i -1 ) TrayItemSetOnEvent(-1, "TrayEvent") Next EndIf EndFunc Func TrayMenuRightClick() If $state = 1 Or $state = 2 Then $state = 0 For $i = 1 to 5 TrayItemDelete($Tray[$i]) Next For $i = 6 to 10 $Tray[$i] = TrayCreateItem("2nd Menu Item - " & $i - 5, -1, $i - 6) TrayItemSetOnEvent(-1, "TrayEvent") Next EndIf EndFunc Func TrayEvent() MsgBox(0, "", TrayItemGetText(@TRAY_ID)) If TrayItemGetText(@TRAY_ID) = "Exit" Then Exit EndFunc Cheers I try it and after I press other button in 1st time I get previous last menu.... press left : get menu 1. press right : get menu 1. press right again: get menu 2 press left: get menu 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now