mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Small changes, which get the title of the document for displaying it in the IE capture list.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1998 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
0ee25e8cac
commit
846f423e6b
1 changed files with 53 additions and 28 deletions
|
@ -129,13 +129,25 @@ namespace Greenshot.Helpers {
|
||||||
foreach (WindowDetails ieWindow in GetIEWindows()) {
|
foreach (WindowDetails ieWindow in GetIEWindows()) {
|
||||||
try {
|
try {
|
||||||
if (!ieHandleList.Contains(ieWindow.Handle)) {
|
if (!ieHandleList.Contains(ieWindow.Handle)) {
|
||||||
WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow);
|
if ("IEFrame".Equals(ieWindow.ClassName)) {
|
||||||
if (directUIWD != null) {
|
WindowDetails directUIWD = IEHelper.GetDirectUI(ieWindow);
|
||||||
Accessible accessible = new Accessible(directUIWD.Handle);
|
if (directUIWD != null) {
|
||||||
browserWindows.Add(ieWindow, accessible.IETabCaptions);
|
Accessible accessible = new Accessible(directUIWD.Handle);
|
||||||
|
browserWindows.Add(ieWindow, accessible.IETabCaptions);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
List<string> singleWindowText = new List<string>();
|
List<string> singleWindowText = new List<string>();
|
||||||
singleWindowText.Add(ieWindow.Text);
|
try {
|
||||||
|
IHTMLDocument2 document2 = getDocument(ieWindow);
|
||||||
|
string title = document2.title;
|
||||||
|
if (string.IsNullOrEmpty(title)) {
|
||||||
|
singleWindowText.Add(ieWindow.Text);
|
||||||
|
} else {
|
||||||
|
singleWindowText.Add(ieWindow.Text + " - " + title);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
singleWindowText.Add(ieWindow.Text);
|
||||||
|
}
|
||||||
browserWindows.Add(ieWindow, singleWindowText);
|
browserWindows.Add(ieWindow, singleWindowText);
|
||||||
}
|
}
|
||||||
ieHandleList.Add(ieWindow.Handle);
|
ieHandleList.Add(ieWindow.Handle);
|
||||||
|
@ -154,6 +166,40 @@ namespace Greenshot.Helpers {
|
||||||
return returnList;
|
return returnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper Method to get the IHTMLDocument2
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mainWindow"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static IHTMLDocument2 getDocument(WindowDetails mainWindow) {
|
||||||
|
IHTMLDocument2 document2 = null;
|
||||||
|
uint windowMessage = User32.RegisterWindowMessage("WM_HTML_GETOBJECT");
|
||||||
|
if (windowMessage == 0) {
|
||||||
|
LOG.WarnFormat("Couldn't register WM_HTML_GETOBJECT");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowDetails ieServer = mainWindow.GetChild("Internet Explorer_Server");
|
||||||
|
if (ieServer == null) {
|
||||||
|
LOG.WarnFormat("No Internet Explorer_Server for {0}", mainWindow.Text);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
LOG.DebugFormat("Trying WM_HTML_GETOBJECT on {0}", ieServer.ClassName);
|
||||||
|
UIntPtr response;
|
||||||
|
User32.SendMessageTimeout(ieServer.Handle, windowMessage, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 5000, out response);
|
||||||
|
if (response != UIntPtr.Zero) {
|
||||||
|
document2 = (IHTMLDocument2)Accessible.ObjectFromLresult(response, typeof(IHTMLDocument).GUID, IntPtr.Zero);
|
||||||
|
if (document2 == null) {
|
||||||
|
LOG.Error("No IHTMLDocument2 found");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG.Error("No answer on WM_HTML_GETOBJECT.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return document2;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method which will retrieve the IHTMLDocument2 for the supplied window,
|
/// Helper method which will retrieve the IHTMLDocument2 for the supplied window,
|
||||||
/// or return the first if none is supplied.
|
/// or return the first if none is supplied.
|
||||||
|
@ -189,29 +235,8 @@ namespace Greenshot.Helpers {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get the Document
|
// Get the Document
|
||||||
IHTMLDocument2 document2 = null;
|
IHTMLDocument2 document2 = getDocument(ieWindow);
|
||||||
uint windowMessage = User32.RegisterWindowMessage("WM_HTML_GETOBJECT");
|
if (document2 == null) {
|
||||||
if (windowMessage == 0) {
|
|
||||||
LOG.WarnFormat("Couldn't register WM_HTML_GETOBJECT");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
WindowDetails ieServer= ieWindow.GetChild("Internet Explorer_Server");
|
|
||||||
if (ieServer == null) {
|
|
||||||
LOG.WarnFormat("No Internet Explorer_Server for {0}", ieWindow.Text);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LOG.DebugFormat("Trying WM_HTML_GETOBJECT on {0}", ieServer.ClassName);
|
|
||||||
UIntPtr response;
|
|
||||||
User32.SendMessageTimeout(ieServer.Handle, windowMessage, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.SMTO_NORMAL, 5000, out response);
|
|
||||||
if (response != UIntPtr.Zero) {
|
|
||||||
document2 = (IHTMLDocument2)Accessible.ObjectFromLresult(response, typeof(IHTMLDocument).GUID, IntPtr.Zero);
|
|
||||||
if (document2 == null) {
|
|
||||||
LOG.Error("No IHTMLDocument2 found");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOG.Error("No answer on WM_HTML_GETOBJECT.");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue