hooovahh Posted November 20, 2009 Report Share Posted November 20, 2009 Ok so I got another goodie that I've been working on. I don't know why, but lately I've had a slight obsession with the Windows system tray. I don't know why just do. I wanted an easy semi-universal way of making system tray icons. I wanted some thing native but instead I went with what works, and I may end up changing it down the road. Right now it uses AutoIt3 (another obsession lately). But you don't need to install AutoIt, Windows should already contain all the run time engines needed. Included in this zip is two AutoIt EXEs. CreateTrayIcon.exe is the main work horse. It is a command line program, so applying the /? switch will give you some information about what parameters are needed. It needs a command to exit on, a tip strip text, a path to a config file (which contains all the items to appear when you right click one item per line), a path to the icon to use (it supports using .dlls or .exe files with an icon index or .ico file) and a icon index which can be blank or 0 if not used. The second EXE is RemoveUnusedTrayIcons.exe. If you kill the icon using the LabVIEW VI it will just run taskkill on the application. This normally leaves the icon in the system tray until you mouse over it and then it disappears. This program searches for all icons that don't have a handler and removes them. The source for both EXEs are included. What VIs are included? There is a create icon VI, get click VI (what did the user click on) and kill icon VI with an example VI named Tray Example.vi. There is also a Global used for passing data around, but it's not important. Another feature I included is the minimize to tray VI. This will take a VI and minimize it to the tray, then wait for the user to double click it or restore it to bring it back. I also created an example for this. Here's a screen shot but it's not very exciting. I was thinking of adding support for more complicated tray items, like bolding items, adding checkmarks, I saw a way to implement radio buttons, and even nested items. Are these the kinds of features that would be useful? Also if you didn't notice since the autoit programs are command line programs, any programming language that has File I/O can use this to create tray icons. I just included LabVIEW VIs as a sort of API to make it easier to use. BTW all of these VIs are written in 7.1 for the most compatibility. Create Tray Icon.zip Quote Link to comment
Norm Kirchner Posted November 21, 2009 Report Share Posted November 21, 2009 How different is what your working on compared to the one on the NI site? http://zone.ni.com/devzone/cda/epd/p/id/3915 Quote Link to comment
hooovahh Posted November 21, 2009 Author Report Share Posted November 21, 2009 How different is what your working on compared to the one on the NI site? http://zone.ni.com/d...a/epd/p/id/3915 ...well mine has less features... To be honest I didn't know NI had developed a tray icon tool. When I searched ni.com and their forums I searched for "System tray" or "tray icon". All I found was old articles saying it was possible with some shell32 calls, and how to do it with LabWindows. There's also a company out there that developed a product for making system tray icons in LabVIEW. Because of this I assumed there wasn't a free open source way to do it. I can't look at NI's tool right now (on the wife's netbook) so I can't say what all the differences are, but I can say that mine doesn't require .Net 2.0. And my tool is can also be used in any programming language that is supported in Windows and has file I/O tools. That being said it sounds like NI's tool is much more feature complete. Quote Link to comment
hugo_fr Posted June 8, 2010 Report Share Posted June 8, 2010 Hi, There is another NotifyIcon library (based on .NET) that could be merged with the NI library... The example is interesting too NotifyIcon.zip MouseCircle-20070302.zip Quote Link to comment
hooovahh Posted June 8, 2010 Author Report Share Posted June 8, 2010 Hi, There is another NotifyIcon library (based on .NET) that could be merged with the NI library... The example is interesting too That example is crazy. Did you develop this or did you find it? I ask because I noticed some of the front panel controls would be a strange string of characters like "ƒCƒxƒ“ƒg“o˜^Refnum" and even the error clusters have some odd labels. Does this kind of thing happen when developing in a different language? I think I understand how all the pieces work. The only thing is with this design I don't like is you need to have a callback VI for each item in the tray right? What if we needed to populate the list of items to appear when you right click? You could have the same call back VI for several events, but when when an event occurs there is no way to know what the user clicked on if because the only distinguishing part is between items is the VI that is called. I'm also a little confused on what happens if you have more than 5 items when you right click. It seems you are registering all the events at the same time, so you need to know how many events there are, and there is a case structure in the SetMenu.vi that at the moment only goes to 5 items. It would be a pain to have to set that to the maximum number of items you expect to ever have in a tray. I also didn't see a way to add a horizontal bar to separate items. Maybe BarBreak? or Break in the MenuItem property node. Quote Link to comment
hugo_fr Posted June 21, 2010 Report Share Posted June 21, 2010 That example is crazy. Did you develop this or did you find it? I ask because I noticed some of the front panel controls would be a strange string of characters like "ƒCƒxƒ“ƒg“o˜^Refnum" and even the error clusters have some odd labels. Does this kind of thing happen when developing in a different language? I think I understand how all the pieces work. The only thing is with this design I don't like is you need to have a callback VI for each item in the tray right? What if we needed to populate the list of items to appear when you right click? You could have the same call back VI for several events, but when when an event occurs there is no way to know what the user clicked on if because the only distinguishing part is between items is the VI that is called. I'm also a little confused on what happens if you have more than 5 items when you right click. It seems you are registering all the events at the same time, so you need to know how many events there are, and there is a case structure in the SetMenu.vi that at the moment only goes to 5 items. It would be a pain to have to set that to the maximum number of items you expect to ever have in a tray. I also didn't see a way to add a horizontal bar to separate items. Maybe BarBreak? or Break in the MenuItem property node. I find it some years ago, on LAVA 1.0, I have the same bug (ƒCƒxƒ“ƒg“o˜) on clusters... You are right for the registering process, a little bit frustrating .... i don't know another way, NI Library uses the same registering node. If you put the string '-' for the name, you can add an horizontal BreakBar, (as for Ring) You can distinguish items with the 'NotifyIcon Ref' property : 'Text' I hope it helps. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.