3mustgetbeers Posted February 12, 2011 Share Posted February 12, 2011 (edited) Hello again! Hope you're all well OK, I am writing a script to show from the system tray. To be honest, at the moment, gettin started, I am massively ripping off the brilliant work by I only want a system tray icon, with the ability to right click it and select a menu option. So far, after bludgeoning one of Holgers examples, I have:expandcollapse popup#include <GUIConstants.au3> #include "ModernMenuRaw.au3" #NoTrayIcon Opt("GUIOnEventMode", 1) ; This is for both - GUI and Tray ownerdrawn menu items ;Create the tray icon $TrayGUI = _TrayIconCreate("Tools", "shell32.dll", -13) _TrayIconSetClick(-1, 16) _TrayIconSetState() ; Show the tray icon ; *** Create the tray context menu *** $nTrayMenu1 = _TrayCreateContextMenu() $nSideItem3 = _CreateSideMenu($nTrayMenu1) _SetSideMenuText($nSideItem3, "Home Group") _SetSideMenuColor($nSideItem3) ; _SetSideMenuColor($nSideItem3, !!HEX Colour Here!!) _SetSideMenuBkColor($nSideItem3, 0x000000) _SetSideMenuBkGradColor($nSideItem3, 0xffffff) $MenuMenu = _TrayCreateMenu("Menu") _TrayCreateItem("") _TrayItemSetIcon(-1, "", 0) $MenuDrives = _TrayCreateMenu("Driveinfo") _TrayCreateItem("") _TrayItemSetIcon(-1, "", 0); Force changing to ownerdrawn sometimes needed, i.e. in mixed menu $MenuTools = _TrayCreateMenu("Tools") _TrayCreateItem("") _TrayItemSetIcon(-1, "", 0) $TrayHelp = _TrayCreateItem("Help") $TrayRun = _TrayCreateItem("Run...") _TrayCreateItem("") _TrayItemSetIcon(-1, "", 0) $TrayExit = _TrayCreateItem("Exit") _TrayItemSetIcon($MenuMenu, "", 0) _TrayItemSetIcon($MenuDrives, "shell32.dll", -9) _TrayItemSetIcon($MenuTools, "shell32.dll", -20) _TrayItemSetSelIcon($MenuTools, "shell32.dll", -44) _TrayItemSetIcon($TrayHelp, "shell32.dll", -24) _TrayItemSetIcon($TrayRun, "shell32.dll", -25) _TrayItemSetIcon($TrayExit, "shell32.dll", -28) GUICtrlSetState($TrayHelp, $GUI_DEFBUTTON) ; *** Sub menu items *** $TrayCalc = _TrayCreateItem("Calculator", $MenuTools) $TrayCMD = _TrayCreateItem("CMD", $MenuTools) $TrayNotepad = _TrayCreateItem("Notepad", $MenuTools) $TrayRegedit = _TrayCreateItem("Regedit", $MenuTools) _TrayItemSetIcon($TrayCalc, "calc.exe", 0) _TrayItemSetIcon($TrayCMD, "cmd.exe", 0) _TrayItemSetIcon($TrayNotepad, "notepad.exe", 0) _TrayItemSetIcon($TrayRegedit, "regedit.exe", 0) _TrayCreateItem("Free Space:", $MenuDrives) _TrayCreateItem("", $MenuDrives) ExitI have two questions to really get me started, and to a stage I think I could run with it. Firstly, the icons; they are set with lines such as:_TrayItemSetIcon($MenuDrives, "shell32.dll", -9)I'm not sure what this means? I GUESS the icon is set from the windows directory (windows api??) somewhere and the '-9' parameter is an offset value as to which icon to choose? just a guess, maybe well off(?) could anyone shed some light on this?Also how in Gods name do I get the buttons to function!? I have tried adding and editing the While statement from the help file --While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aboutitem Msgbox(64,"about:","AutoIt3-Tray-sample") Case $msg = $exititem ExitLoop EndSelect WEndBut I'm failing; epically Thanks alot for any answers guys!3mgb Edited February 12, 2011 by 3mustgetbeers Link to comment Share on other sites More sharing options...
3mustgetbeers Posted February 12, 2011 Author Share Posted February 12, 2011 (edited) I can get it to work fine using the help file example as a template: #Include <Constants.au3> #NoTrayIcon Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. $settingsitem = TrayCreateMenu("Settings") $displayitem = TrayCreateItem("Display", $settingsitem) $printeritem = TrayCreateItem("Printer", $settingsitem) TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aboutitem Msgbox(64,"about:","AutoIt3-Tray-sample") Case $msg = $exititem ExitLoop EndSelect WEnd Exit But... I love the appearance and functionality added in Holgers script - much more appealing when customised to match its purpose, so ideally I would love to use something like that Edit: When I say I can get it to work fine; i mean that I can use the above (from the help menu) to achieve the desired effect, however I would love to be able to use the functionality of Holgers tool Edited February 12, 2011 by 3mustgetbeers Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 12, 2011 Moderators Share Posted February 12, 2011 mustgetbeers, the icon is set from the windows directory (windows api??) somewhere and the '-9' parameter is an offset value as to which icon to chooseSpot on! shell32.dll is stuffed with icons and the -9 is used to index the one you want - just use something like ResHacker to look inside and see what is in there. Do not ask me why they are negative indices - they just are! how [...] do I get the buttons to function!?You have set OnEvent mode with this line: Opt("GUIOnEventMode", 1) ; This is for both - GUI and Tray ownerdrawn menu items so polling TrayGetMsg in a loop is not likely to help. I have never used this UDF myself, but looking at the examples in the "sampleGUIandTray-OnEvent" example from the ModernMenu download it looks as if you need to define event functions for each menu item. You got the OnEventMode line from there - you just needed to keep going a bit deeper. Try that and see if it works. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
3mustgetbeers Posted February 14, 2011 Author Share Posted February 14, 2011 Cheers again M23 - got it working over the weekend 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