shEiD Posted July 4, 2013 Posted July 4, 2013 Hi, could anyone help me with a C# code to get info of icons in System Tray? I can accomplish this in AutoIt, but would very much prefer to be able to have this in c#. I use it daily, to fix some problems/bugs in another software to make it usable, which is in beta now, and until developers fix it, I need to resort to this thing. Crazy enough, there is no other way inbuilt to get the status of a program and what it's doing, except tray icon. No logging, anything at all. They say they are working on it, but until that time... Here's the AutoIt snippet: #include <GuiToolBar.au3> $hTray = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') $iconCount = _GUICtrlToolbar_ButtonCount($hTray) For $i = 0 To $iconCount - 1 $text = _GUICtrlToolbar_GetButtonText($hTray, $i) ConsoleWrite($text & @LF) Next The most important thing, is to get tray icon tool-tip. I would like to get more, if possible as well, but tool-tip is crucial. I'm a hobbyist and only learning programming (C#). I don't know c++, nor I know how to properly PInvoke in c#, and I'm not confident enough to mess with unmanaged code. I even tried to accomplish this in C# using AutoItX3_x64.dll, but could not figure it out. Any help would be much appreciated. Maybe at least someone could tell me, where else I could ask for help on this, if not here? Autoit is awesome, I use it daily, sadly this project is just too big and complicated to do it all in Autoit only. Main reason - I want to use WPF.
Richard Robertson Posted July 4, 2013 Posted July 4, 2013 It would be pretty easy to translate the functions to C#. I'll give it a stab later today after I take a nap.
shEiD Posted July 4, 2013 Author Posted July 4, 2013 Thank you in advance. I'm still too green to do that myself.
Richard Robertson Posted July 7, 2013 Posted July 7, 2013 Working on this right now (had few busy days with family due to holiday). I've got everything except the text reading function finished and it shouldn't be much longer.
Richard Robertson Posted July 7, 2013 Posted July 7, 2013 (edited) Ok, it's taking longer than expected. Gonna finish tomorrow. Started talking to girlfriend on the phone and I got distracted and now it's two in the morning. Edited July 7, 2013 by Richard Robertson
Richard Robertson Posted July 9, 2013 Posted July 9, 2013 (edited) https://dl.dropboxusercontent.com/u/22618541/ToolTipsHelper.cs https://dl.dropboxusercontent.com/u/22618541/Program.cs ToolTipsHelper.cs contains a class that has the functions you need. Program.cs shows how to call it, basically emulating the script fragment above. Sorry it took so long, but like I said, it was a busy weekend and the last function (that gets the text) was significantly more complex than the others. Edited July 9, 2013 by Richard Robertson
shEiD Posted July 29, 2013 Author Posted July 29, 2013 @Richard Robertson, Thank You so much. Sorry I haven't been back here for so long. I have asked this question someplace else, and another very helpful person wrote a wrapper dll for me, so I've been using that. But I will go though your solution and examine it and maybe use it. Anyway it will help me a lot as a learning example, so your hard work will not be wasted. Thank you again.
Richard Robertson Posted July 30, 2013 Posted July 30, 2013 Well make sure you get those files and save them somewhere because I'll probably remove them from my Dropbox next time I clean up.
rahoolm Posted February 3, 2014 Posted February 3, 2014 Thanks for the solution! Is there any way to Display a balloon like ToolTip on screen similar to AutoIt ToolTip in C#? I have used the AutoItX.ToolTip for C# but it is not showing the ToolTip on my windows 8 machine. Also, it has no option for balloon like tips. My intention is to show a tooltip near an IE DOM Element using the x, y position, I am working on WatiN Web UI Automation framework. Thanks for your help.
Richard Robertson Posted February 4, 2014 Posted February 4, 2014 If you are automating a web page, it might be easier to actually insert jQuery and use the tooltip widget here http://api.jqueryui.com/tooltip/
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