g52 Posted April 25, 2017 Share Posted April 25, 2017 Hi, Will anyone advise how to set the icon or image for each item? Local $idDisplay = TrayCreateItem("Display") Local $idPrinter = TrayCreateItem("Printer") Thank you very much for your help Link to comment Share on other sites More sharing options...
g52 Posted April 25, 2017 Author Share Posted April 25, 2017 I tried, but it does not work GuiCtrlSetImage ( $ idDisplay , "shell32.dll" , 4 ) TrayItemSetState ( $ idDisplay , "shell32.dll" , 4 ) Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted April 25, 2017 Moderators Share Posted April 25, 2017 Moved to the appropriate forum, as the DEV forum clearly states Quote Do not create AutoIt-related topics here, use the AutoIt General Help and Support "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
g52 Posted January 31, 2021 Author Share Posted January 31, 2021 Really no one will help? Link to comment Share on other sites More sharing options...
TheXman Posted January 31, 2021 Share Posted January 31, 2021 (edited) You mean like this? The example uses embedded icons but can easily be changed to use external icons (like from shell32.dll). Edited February 1, 2021 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
Nine Posted February 1, 2021 Share Posted February 1, 2021 3 hours ago, g52 said: Really no one will help? After almost 4 years ? Are you for real ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
spudw2k Posted February 1, 2021 Share Posted February 1, 2021 At least it was the OP who resurrected it. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
g52 Posted February 1, 2021 Author Share Posted February 1, 2021 (edited) #NoTrayIcon #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> Opt("TrayMenuMode", 3) Example() Func Example() Local $iSettings = TrayCreateMenu("Settings") Local $iDisplay = TrayCreateItem("Display", $iSettings) _TrayItemSetIcon(-1,"shell32.dll", 14) Local $iPrinter = TrayCreateItem("Printer", $iSettings) _TrayItemSetIcon(-1,"shell32.dll", 14) TrayCreateItem("") Local $idAbout = TrayCreateItem("About") TrayCreateItem("") Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) While 1 Switch TrayGetMsg() Case $idAbout MsgBox($MB_SYSTEMMODAL, "", "AutoIt tray menu example." & @CRLF & @CRLF & _ "Version: " & @AutoItVersion & @CRLF & _ "Install Path: " & StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1)) ; Find the folder of a full path. Case $iDisplay, $iPrinter MsgBox($MB_SYSTEMMODAL, "", "A sub menu item was selected from the tray menu.") Case $idExit ExitLoop EndSwitch WEnd EndFunc Here is all my code, it still doesn't work 😞 Can anyone help me to fix it please? Edited February 1, 2021 by g52 Link to comment Share on other sites More sharing options...
Nine Posted February 1, 2021 Share Posted February 1, 2021 Do not mix native with UDF. Study examples in : “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Developers Jos Posted February 1, 2021 Developers Share Posted February 1, 2021 On 4/26/2017 at 12:26 AM, g52 said: I tried, but it does not work GuiCtrlSetImage ( $ idDisplay , "shell32.dll" , 4 ) TrayItemSetState ( $ idDisplay , "shell32.dll" , 4 ) 14 hours ago, g52 said: Really no one will help? funny ... a bump after 3+ years .... that must be a first! SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
pixelsearch Posted February 1, 2021 Share Posted February 1, 2021 Hi everybody I would like to add a (long, as usual) comment to what has been said before, hoping it may help @g52 in the future in his methodology, when he'll try to solve an issue by himself. Until today, I never used any script concerning tray menus and this thread made me start digging, after I discovered g52's code ("Here is all my code, it still doesn't work") and before Nine replied to him. When I ran g52's code, I had this error : ==> Unknown function name : _TrayItemSetIcon(-1,"shell32.dll", 14) So I googled on "AutoIt" "_TrayItemSetIcon" and it quickly led me to Holger's thread : I needed the include file "ModernMenuRaw.au3" to have g52's script running. If I may give an advice now : when you see that OP's 1st post (Holger) and his download link are dated 2008, just have a quick look at all the replies found in his thread, maybe you'll find another known user who uploaded a reworked version of the script, or more examples, or maybe a version compatible with new AutoIt releases etc... This happens in Holger's thread, because @AZJIO on page 15, immediately followed by @LarsJ also on page 15, both of them make it easier for us, AZJIO by giving detailed examples and LarsJ by reworking a new version (2015) of Holger script. So, based on AZJIO's example : _TrayCreateMenu.au3 And based on the simple way Holger checks events with the same repeated line after each tray menu item creation : GUICtrlSetOnEvent(-1, "MenuEvents") ...then it is easy to end with something like this, quickly done, with only 2 events checked for "About..." and "SubItem => Restart" expandcollapse popup#include "ModernMenuRaw.au3" #NoTrayIcon Opt("GUIOnEventMode", 1) Opt("TrayMenuMode", 7) $nTrayIcon = _TrayIconCreate("My program", "shell32.dll", -209) _TrayCreateContextMenu() $bUseAdvTrayMenu = False ; True would display selected items differently $hMenu = _TrayCreateMenu('Menu') _TrayItemSetIcon(-1, "shell32.dll", -5) _TrayCreateItem("") _TrayCreateItem('Open', $hMenu) _TrayItemSetIcon(-1, "shell32.dll", -5) _TrayCreateItem("", $hMenu) For $i = 1 To 10 _TrayCreateItem('Item ' & $i, $hMenu) _TrayItemSetIcon(-1, "shell32.dll", -$i) Next $action = _TrayCreateMenu('Subitem') _TrayItemSetIcon(-1, "shell32.dll", -177) $nUpd = _TrayCreateItem('Restart', $action) _TrayItemSetIcon(-1, "shell32.dll", -147) GUICtrlSetOnEvent(-1, "MenuEvents") $nSave = _TrayCreateItem('Save', $action) _TrayItemSetIcon(-1, "shell32.dll", -195) GUICtrlSetOnEvent(-1, "MenuEvents") $nClose = _TrayCreateItem('Close', $action) _TrayItemSetIcon(-1, "shell32.dll", -110) GUICtrlSetOnEvent(-1, "MenuEvents") $nAdd = _TrayCreateItem('Add', $action) _TrayItemSetIcon(-1, "shell32.dll", -5) GUICtrlSetOnEvent(-1, "MenuEvents") $nFolder = _TrayCreateItem('Folder', $action) _TrayItemSetIcon(-1, "shell32.dll", -4) GUICtrlSetOnEvent(-1, "MenuEvents") $nSet = _TrayCreateItem('Option', $action) _TrayItemSetIcon(-1, "shell32.dll", -91) GUICtrlSetOnEvent(-1, "MenuEvents") $nAbout = _TrayCreateItem('About') _TrayItemSetIcon(-1, "shell32.dll", -222) GUICtrlSetOnEvent(-1, "MenuEvents") $nExit = _TrayCreateItem('Exit') _TrayItemSetIcon(-1, "shell32.dll", -216) GUICtrlSetOnEvent(-1, "MenuEvents") _TrayIconSetState() While 1 Sleep(10) WEnd Func MenuEvents() Local $Msg = @GUI_CtrlID ; great one ! Switch $Msg Case $nExit _TrayIconDelete($nTrayIcon) Exit Case $nAbout Msgbox(64, "About", "About text here") Case $nUpd Msgbox(64, "Restart", "Restart text there") ; Case ... EndSwitch EndFunc Now if you don't want to script with Opt("GUIOnEventMode", 1) but with While... Wend loop mode, it's doable (see Holger's examples in LarsJ download link, which includes 4 subfolders, one per each contributor) but it seems simpler to script it like above. Concerning the very same kind of script, @Melba23 helped a user in this link, indicating him that OnEvent mode and TrayGetMsg in a loop won't work together A last recommandation : when you see that your script "doesn't work", try to add some debug lines to your code, it's often a big help. 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