ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > FARR Plugins and Aliases

FARR C# SDK and Documentation V2 (19/10/2008)

<< < (9/11) > >>

skajfes:
If I put it in GetActionsCount it doesn't work. That's ok though. However, on executing a result, it does nothing except hide FARR. I have a simple MessageBox.Show() string printed at the moment (in Execute()), but the MessageBox doesn't show?
-joshuawood (January 10, 2009, 02:05 AM)
--- End quote ---

Try setting the path value of every item in the result list. It doesn't matter what it is, and results wont execute unless it is set. (at least from what I have seen)

joshuawood:
Thanks skajfes, you're right about the PathItem needing to be set. It also appears that it needs to be unique. I just it to the same fixed string for each result, and it would only display 1 result. Change it to a result unique string and it lists all results.

Could you please explain what GetActionsCount does more? Do I need to use it? I currently do nothing with it, and don't appear to need to.

Further, I'm trying to remove all files in a set folder when my plugin is called. I have this code in a few places, but it only appears to be called when FARR is first loaded (and hence the plugin). I would have thought having it in the ActionList constructor would mean it got called everytime to the plugin got called, but doesn't appear to do so:


--- ---static string m_TempPath = null;

        public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {
            m_TempPath = Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetCallingAssembly().Location), "Temp");
            Directory.CreateDirectory(m_TempPath);
            string[] Files = Directory.GetFiles(m_TempPath);
            foreach (string FileName in Files)
            {
                File.Delete(FileName);
            }
           
            EnumTray.GetTrayData(out buttonData);       // populate tray data

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }
        }

Edit: On further testing, it appears that FARR creates an instance of this plugin at runtime only. So using the above code, it is only called once, and hence my results list is not dynamic. How do I make the results list update each time the plugin is executed by it's regex? Is that what I need to use GetActionsCount for?

Edit again: I'm not sure if the above edit comment is actually correct. In some strange cases my first plugin call will not pickup the FARR tray icon, but sometimes after a while it does. But not another program loaded after FARR has started. It's a bit strange.

What I want to do is call

--- ---EnumTray.GetTrayData(out buttonData);

            foreach (TrayIconData trayData in buttonData)
            {
                if (trayData.button.fsState != 8)     // only add if button is not invisible
                    SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                //if (this.Count > 10)
                //  break;
            }each time I execute the plugin by typing in it's regex.

skajfes:
I think you should add your code that is supposed to execute every time the plugin is called in the GetActionsCount method (that's what I did). Maybe the Farr icon is not loaded because when farr is started(and your plugin with it) your plugin picks up the icon list just before FARR puts its icon in the tray.

So, every time the plugin is activated Farr calls GetActionsCount to get the number of results your plugin has to offer, so I think it is the best time to fill in the results.

Hope it helps
skajfes

joshuawood:
That's what I think GetActionsCount does also - gets called everytime; but it doesn't appear to work for me. I will investigate further.

joshuawood:
Ok, still don't get why it doesn't work for me. Here is what I have:

--- ---    class FARRTrayList : ActionsList
    {
        private TrayIconData[] buttonData = null;
        static string m_TempPath = null;

        public FARRTrayList(FARRCSharpPluginBase pluginBase)
            : base(pluginBase, "^tray")
        {
            m_TempPath = Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Temp");
            Directory.CreateDirectory(m_TempPath);

            //SourceList.Add(new Actions.FARRTrayAction(null, m_TempPath));
            //SourceList.Add(new Actions.FARRTrayAction(this.PluginBase));
        }

        public override int GetActionsCount(string KeyKeywords)
        {
            MessageBox.Show("In GAC, m_TempPath = " + m_TempPath);
            string[] Files = Directory.GetFiles(m_TempPath);
            MessageBox.Show(Files.Length.ToString());
            foreach (string FileName in Files)
            {
                MessageBox.Show("Deleting file: " + FileName.ToString());
                File.Delete(FileName);
            }

            EnumTray.GetTrayData(out buttonData);       // populate tray data

            if (buttonData != null)
            {
                foreach (TrayIconData trayData in buttonData)
                {
                    if (trayData.button.fsState != 8)
                    {    // only add if button is not invisible
                        MessageBox.Show("Found tray app: " + trayData.Text);
                        SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                    }
                    if (SourceList.Count > 10)
                        break;
                }
                MessageBox.Show("IN GAC, with data count: " + SourceList.Count);
                return SourceList.Count;
            }

            else
            {
                MessageBox.Show("IN GAC, with no data count");
                return 0;
            }
        }
    }

It appears to work ok, but something is still not quite right. The msgboxes get called correctly. Each time the msgbox will display each tray icon's name, and count them correctly (ie, they've been added to the SourceList). If I re-execute my plugin again after loading a new tray app, it is correctly enumerated, so it is now dynamic as desired. However, still no results show, even though it is getting the data correctly. It correctly deletes any existing icons.

Edit: I should mention that this section of code:

--- ---            EnumTray.GetTrayData(out buttonData);       // populate tray data

            if (buttonData != null)
            {
                foreach (TrayIconData trayData in buttonData)
                {
                    if (trayData.button.fsState != 8)
                    {    // only add if button is not invisible
                        MessageBox.Show("Found tray app: " + trayData.Text);
                        SourceList.Add(new Actions.FARRTrayAction(trayData, m_TempPath));
                    }
                    if (SourceList.Count > 10)
                        break;
                }
                MessageBox.Show("IN GAC, with data count: " + SourceList.Count);
                return SourceList.Count;
            }
without the msgboxes of course, does work as expect when placed in the constructor, except then it is not dynamic. The results will show however, unlike when in GAC. Hopefully I'm just missing something very simple.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version