Tankbuster Posted June 17, 2010 Share Posted June 17, 2010 (edited) Hello, I searched this forum for a guide to display with one exe/au3 more than one tray icon. I found a old post, but in this post (multiple tray icons) the poster was misunderstood (so I guess, because to the others it was not clear why) So to avoid confusion I will explain what I want: As you know in Windows7 and Server2008 the services run in a isolated session 0. This session is not able to display dialogues and icons. The several services (my own programs) sometimes want to inform the logged in user about their state by displaying icons and sometimes a user gui for more complex messages (with autolose). To achieve this I thought about this solution: My services write to the eventlog. and now the EventReader reads the eventlog and checks for messages about my services. For a small example lets say two services write to the eventlog, now to not run a instance for each service I want my script to display a tray Icon for each service. So the question is: Is there a option to display and change multiple tray icon based on a handle? If not I will start a instance for each service. If I was not clear in explaining, just ask, I will try to give you a better answer. //edit: Ah, I forgot: Multi Icons from one exe at the same time. Edited June 17, 2010 by Tankbuster Link to comment Share on other sites More sharing options...
Yashied Posted June 17, 2010 Share Posted June 17, 2010 Look at _WinAPI_ShellNotifyIcon() from WinAPIEx.au3.#Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $hWnd = WinGetHandle(AutoItWinGetTitle()) Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA) OnAutoItExitRegister('OnAutoItExit') DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA)) DllStructSetData($tNOTIFYICONDATA, 'hWnd', WinGetHandle(AutoItWinGetTitle())) DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON) DllStructSetData($tNOTIFYICONDATA, 'ID', 2) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', 166, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', 130, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) While 1 Sleep(1000) WEnd Func OnAutoItExit() DllStructSetData($tNOTIFYICONDATA, 'ID', 2) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) EndFunc ;==>OnAutoItExit My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
Tankbuster Posted June 17, 2010 Author Share Posted June 17, 2010 Thank you very much. I just downloaded your WinAPI. But it looks like you saved my day. I will now read your original post to get the complete picture. Link to comment Share on other sites More sharing options...
Tankbuster Posted June 18, 2010 Author Share Posted June 18, 2010 .....sorry, I have to ask a second (and third) question......I want to set also the TOOL TIP, so I tried:expandcollapse popup#Include <WinAPIEx.au3> Opt('MustDeclareVars', 1) Global $hWnd = WinGetHandle(AutoItWinGetTitle()) Global $tNOTIFYICONDATA = DllStructCreate($tagNOTIFYICONDATA) OnAutoItExitRegister('OnAutoItExit') DllStructSetData($tNOTIFYICONDATA, 'Size', DllStructGetSize($tNOTIFYICONDATA)) DllStructSetData($tNOTIFYICONDATA, 'hWnd', WinGetHandle(AutoItWinGetTitle())) DllStructSetData($tNOTIFYICONDATA, 'Flags', $NIF_ICON) DllStructSetData($tNOTIFYICONDATA, 'ID', 2) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', 166, 16, 16)) DllStructSetData($tNOTIFYICONDATA, 'Tip', "huhu") _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', 130, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_ADD, $tNOTIFYICONDATA) While 1 for $n = 100 to 150 Sleep(100) DllStructSetData($tNOTIFYICONDATA, 'ID', 2) DllStructSetData($tNOTIFYICONDATA, 'Tip', "Hello World "&$n) DllStructSetData($tNOTIFYICONDATA, 'hIcon', _WinAPI_ShellExtractIcons(@SystemDir & '\shell32.dll', $n, 16, 16)) _WinAPI_ShellNotifyIcon($NIM_MODIFY, $tNOTIFYICONDATA) next WEnd Func OnAutoItExit() DllStructSetData($tNOTIFYICONDATA, 'ID', 2) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) DllStructSetData($tNOTIFYICONDATA, 'ID', 3) _WinAPI_ShellNotifyIcon($NIM_DELETE, $tNOTIFYICONDATA) EndFunc ;==>OnAutoItExitLINE 27: DllStructSetData($tNOTIFYICONDATA, 'Tip', "Hello World "&$n)But that does not work. Do I have to set also the CallBackMessage? (how?) How does NIF_TIP is related to this? Questions:1) How do I set the ToolTipText of a tray icon created with the WinAPIx?2) How to change the text? (NIM_MODIFY? NIF_TIP?)3) Is there also an example for a callbackfunction eg to create a tray menu item like the TrayCreateItem and how to proceed the callback function calls ? WM_MOUSEDOWN/ClickI read your support post here (and I tried even the Russian autoit forum http://autoit-script.ru/index.php/topic,47.0.html - with no luck). I already understood that I have to "learn" your APIx, because it looks like there are a lot of functions I could get a bonus for my apps. (BTW: Simply for the .CHM file you should get 5 stars !)As you already know, I'm not much experienced in this kind of area...sorry to bother you again. Link to comment Share on other sites More sharing options...
Tankbuster Posted June 21, 2010 Author Share Posted June 21, 2010 Just to mentioned: I solved the thing for myself by taking a close look to WinAPIx and ModernMenu. 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