mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 21:13:23 -07:00
Fix for firefox URL retrieval, this still only loads the URL for the visible and active tab.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2553 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
c8b1481a18
commit
cfdaa220ab
1 changed files with 24 additions and 28 deletions
|
@ -111,36 +111,32 @@ namespace GreenshotConfluencePlugin {
|
||||||
HashSet<string> urls = new HashSet<string>();
|
HashSet<string> urls = new HashSet<string>();
|
||||||
|
|
||||||
// FireFox
|
// FireFox
|
||||||
foreach(Process firefox in Process.GetProcessesByName("firefox")) {
|
foreach (WindowDetails window in WindowDetails.GetAllWindows("MozillaWindowClass")) {
|
||||||
LOG.DebugFormat("Checking process {0}", firefox.Id);
|
if (window.Text.Length == 0) {
|
||||||
foreach(AutomationElement rootElement in AutomationElement.RootElement.FindAll(TreeScope.Children, new PropertyCondition(AutomationElement.ProcessIdProperty, firefox.Id))) {
|
continue;
|
||||||
Condition condCustomControl = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom);
|
}
|
||||||
//AutomationElement rootElement = AutomationElement.FromHandle(firefox.MainWindowHandle);
|
AutomationElement currentElement = AutomationElement.FromHandle(window.Handle);
|
||||||
var collection = rootElement.FindAll(TreeScope.Children, condCustomControl);
|
Condition conditionCustom = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Custom), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
|
||||||
if (collection == null || collection.Count == 0) {
|
for (int i = 5; i > 0 && currentElement != null; i--) {
|
||||||
|
currentElement = currentElement.FindFirst(TreeScope.Children, conditionCustom);
|
||||||
|
}
|
||||||
|
if (currentElement == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Condition conditionDocument = new AndCondition(new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document), new PropertyCondition(AutomationElement.IsOffscreenProperty, false));
|
||||||
|
AutomationElement docElement = currentElement.FindFirst(TreeScope.Children, conditionDocument);
|
||||||
|
if (docElement == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (AutomationPattern pattern in docElement.GetSupportedPatterns()) {
|
||||||
|
if (pattern.ProgrammaticName != "ValuePatternIdentifiers.Pattern") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AutomationElement firstCustomControl = collection[collection.Count - 1];
|
string url = (docElement.GetCurrentPattern(pattern) as ValuePattern).Current.Value.ToString();
|
||||||
if (firstCustomControl == null) {
|
if (!string.IsNullOrEmpty(url)) {
|
||||||
continue;
|
urls.Add(url);
|
||||||
}
|
break;
|
||||||
AutomationElement secondCustomControl = firstCustomControl.FindFirst(TreeScope.Children, condCustomControl);
|
|
||||||
if (secondCustomControl == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
foreach (AutomationElement thirdElement in secondCustomControl.FindAll(TreeScope.Children, condCustomControl)) {
|
|
||||||
foreach (AutomationElement fourthElement in thirdElement.FindAll(TreeScope.Children, condCustomControl)) {
|
|
||||||
Condition condDocument = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);
|
|
||||||
AutomationElement docElement = fourthElement.FindFirst(TreeScope.Children, condDocument);
|
|
||||||
if (docElement != null) {
|
|
||||||
foreach (AutomationPattern pattern in docElement.GetSupportedPatterns()) {
|
|
||||||
if (docElement.GetCurrentPattern(pattern) is ValuePattern) {
|
|
||||||
string url = (docElement.GetCurrentPattern(pattern) as ValuePattern).Current.Value.ToString();
|
|
||||||
urls.Add(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue