示例#1
0
        protected override void Execute(NativeActivityContext context)
        {
            var closeall = CloseAll.Get(context);
            var browser  = Browser.Get(context);
            var timeout  = TimeSpan.FromSeconds(3);

            if (browser != "chrome" && browser != "ff" && browser != "edge")
            {
                browser = "chrome";
            }
            NMHook.enumtabs();
            if (closeall)
            {
                NMHook.CloseAllTabs(browser);
            }
            else
            {
                if (browser == "chrome")
                {
                    if (NMHook.CurrentChromeTab != null)
                    {
                        NMHook.CloseTab(browser, NMHook.CurrentChromeTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
                if (browser == "ff")
                {
                    if (NMHook.CurrentFFTab != null)
                    {
                        NMHook.CloseTab(browser, NMHook.CurrentFFTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
                if (browser == "edge")
                {
                    if (NMHook.CurrentEdgeTab != null)
                    {
                        NMHook.CloseTab(browser, NMHook.CurrentEdgeTab.id);
                    }
                    else
                    {
                        Log.Warning("No active tab found for " + browser);
                    }
                }
            }
        }