public PluginResult OnTriggered(PluginTriggerEventArgs e) { string dir = Path.Combine(Path.GetTempPath(), "FluffyApp"); Directory.CreateDirectory(dir); Type photoshopType = Type.GetTypeFromProgID("Photoshop.Application"); if (photoshopType != null) { object photoshop = Activator.CreateInstance(photoshopType); object activeDocument = photoshopType.InvokeMember("ActiveDocument", BindingFlags.GetProperty, null, photoshop, null); string activeFilename = (string)activeDocument.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, activeDocument, null); string savePath = Path.Combine(dir, Path.GetFileNameWithoutExtension(activeFilename) + ".png"); Type saveOptionsType = Type.GetTypeFromProgID("Photoshop.PNGSaveOptions"); object saveOptions = Activator.CreateInstance(saveOptionsType); activeDocument.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, activeDocument, new object[] { savePath, saveOptions, true, 2 // lowercase }); return PluginResult.FromPath(savePath); } return null; }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { string dir = Path.Combine(Path.GetTempPath(), "FluffyApp"); Directory.CreateDirectory(dir); Type photoshopType = Type.GetTypeFromProgID("Photoshop.Application"); if (photoshopType != null) { object photoshop = Activator.CreateInstance(photoshopType); object activeDocument = photoshopType.InvokeMember("ActiveDocument", BindingFlags.GetProperty, null, photoshop, null); string activeFilename = (string)activeDocument.GetType().InvokeMember("Name", BindingFlags.GetProperty, null, activeDocument, null); string savePath = Path.Combine(dir, Path.GetFileNameWithoutExtension(activeFilename) + ".png"); Type saveOptionsType = Type.GetTypeFromProgID("Photoshop.PNGSaveOptions"); object saveOptions = Activator.CreateInstance(saveOptionsType); activeDocument.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod, null, activeDocument, new object[] { savePath, saveOptions, true, 2 // lowercase }); return(PluginResult.FromPath(savePath)); } return(null); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { IntPtr ownerHandle = e.Handle; IntPtr tabHandle = FindWindowEx(ownerHandle, IntPtr.Zero, "Chrome_WidgetWin_0", null); IntPtr omniboxHandle = FindWindowEx(ownerHandle, IntPtr.Zero, "Chrome_OmniboxView", null); // The tab window's title gives the page's title - perfect! StringBuilder sbTitle = new StringBuilder(GetWindowTextLength(tabHandle) + 1); GetWindowText(tabHandle, sbTitle, sbTitle.Capacity); string tabTitle = sbTitle.ToString(); // Omnibox contents can be changed at any time, so it's *really* unreliable. But it's the only thing available. // Also, since GetWindowText won't work, we'll need to use SendMessage with WM_GETTEXT instead. StringBuilder sbUrl = new StringBuilder(256); SendMessage(omniboxHandle, WM_GETTEXT, (IntPtr)MAX_PATH, sbUrl); string omniboxText = sbUrl.ToString().Trim(new char[] { ' ', '\0', '\n' }); // The Omnibox drops "http://" off URLs if that's the protocol of the URL if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) { omniboxText = "http://" + omniboxText; if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) return null; } return PluginResult.FromUrl(omniboxText, tabTitle); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("Opera", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("URL", 1000); dde.Disconnect(); // Result string is in the format "url", "Opera - [title]", ... var parts = result.Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = Regex.Match(parts[1], @"Opera - \[(.*?)\]").Groups[1].Value.Replace("\\\"", "\""); return PluginResult.FromUrl(url, name); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("IExplore", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("0xFFFFFFFF,sURL,sTitle", 1000); dde.Disconnect(); // Result string is in the format "uri", "title"\0 var parts = result.Trim('\0').Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = parts[1].Replace("\\\"", "\""); return PluginResult.FromUrl(url, name); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("URL", 1000); dde.Disconnect(); // Result string is in the format "uri", "title", ... var parts = result.Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = parts[1].Replace("\\\"", "\""); return(PluginResult.FromUrl(url, name)); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { DdeClient dde = new DdeClient("Opera", "WWW_GetWindowInfo"); dde.Connect(); string result = dde.Request("URL", 1000); dde.Disconnect(); // Result string is in the format "url", "Opera - [title]", ... var parts = result.Trim('"').Split(new string[] { "\",\"" }, StringSplitOptions.None); string url = parts[0].Replace("\\\"", "\""); string name = Regex.Match(parts[1], @"Opera - \[(.*?)\]").Groups[1].Value.Replace("\\\"", "\""); return(PluginResult.FromUrl(url, name)); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { var windowElm = AutomationElement.FromHandle(e.Handle); var omniboxElm = windowElm.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar")); // Omnibox contents can be changed at any time, so it's not the most reliable. But it's the only thing available var omniboxValuePattern = (ValuePattern)omniboxElm.GetCurrentPattern(ValuePattern.Pattern); string omniboxText = omniboxValuePattern.Current.Value; // The Omnibox drops "http://" off URLs if that's the protocol of the URL if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) { omniboxText = "http://" + omniboxText; if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) { return(null); } } // The tab window's title gives the page's title // Chrome's automation stuff doesn't seem to give any indicators as to which one's active // so look for one that's a substring of the window title string windowTitle = (string)windowElm.GetCurrentPropertyValue(AutomationElement.NameProperty); var tabElms = windowElm.FindAll( TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem)); string currentTabTitle = omniboxText; foreach (var tabElm in tabElms.Cast <AutomationElement>()) { string tabTitle = (string)tabElm.GetCurrentPropertyValue(AutomationElement.NameProperty); if (windowTitle.Contains(tabTitle)) { currentTabTitle = tabTitle; } } return(PluginResult.FromUrl(omniboxText, currentTabTitle)); }
public PluginResult OnTriggered(PluginTriggerEventArgs e) { var windowElm = AutomationElement.FromHandle(e.Handle); var omniboxElm = windowElm.FindFirst( TreeScope.Descendants, new PropertyCondition(AutomationElement.NameProperty, "Address and search bar")); // Omnibox contents can be changed at any time, so it's not the most reliable. But it's the only thing available var omniboxValuePattern = (ValuePattern)omniboxElm.GetCurrentPattern(ValuePattern.Pattern); string omniboxText = omniboxValuePattern.Current.Value; // The Omnibox drops "http://" off URLs if that's the protocol of the URL if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) { omniboxText = "http://" + omniboxText; if (!Uri.IsWellFormedUriString(omniboxText, UriKind.Absolute)) return null; } // The tab window's title gives the page's title // Chrome's automation stuff doesn't seem to give any indicators as to which one's active // so look for one that's a substring of the window title string windowTitle = (string)windowElm.GetCurrentPropertyValue(AutomationElement.NameProperty); var tabElms = windowElm.FindAll( TreeScope.Descendants, new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem)); string currentTabTitle = omniboxText; foreach (var tabElm in tabElms.Cast<AutomationElement>()) { string tabTitle = (string)tabElm.GetCurrentPropertyValue(AutomationElement.NameProperty); if (windowTitle.Contains(tabTitle)) currentTabTitle = tabTitle; } return PluginResult.FromUrl(omniboxText, currentTabTitle); }