I created an IE extension from this source:
How to get started with developing Internet Explorer extensions?
And it work great. But i want to change
int IOleCommandTarget.Exec(IntPtr pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
var form = new HighlighterOptionsForm();
form.InputText = TextToHighlight;
if (form.ShowDialog() != DialogResult.Cancel)
{
TextToHighlight = form.InputText;
SaveOptions();
}
return 0;
}
to this:
int IOleCommandTarget.Exec(IntPtr pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
{
HTMLDocument document = (HTMLDocument)browser.Document;
IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
document.all.tags("head")).item(null, 0);
IHTMLScriptElement scriptObject =
(IHTMLScriptElement)document.createElement("script");
scriptObject.type = #"text/javascript";
var text = #"alert('hello') ";
scriptObject.text = "(function(){" + text + "})()";
((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
return 0;
}
But when i build it, and click on the button. I doesn't give me an alert message.
I want just only inject a script. Any idea or trick... to fix this problem
It is not working because script tags added to the document are not evaluated automatically.
You must eval the script manually, like the following:
var document = browser.Document as IHTMLDocument2;
var window = document.parentWindow;
window.execScript(#"(function(){ alert('hello') })()");
Also, you don't need to add the script tag at all... just execute the script using window.execScript.
Related
I'd like to open a local HTML file navigated to a specific headline with an ID.
string url = "file:///C:/myFile.html#myHeading"
If I paste the URL in the browser directly, it correctly navigates to the desired heading.
But when I try to have the system handle the URL, it omits the hash entirely.
ProcessStartInfo si = new ProcessStartInfo(url);
si.UseShellExecute = true;
Process.Start(si);
will simply open file:///C:/myFile.html.
Is there a way I can make this work?
Sadly, I don't know where this stripping happens, so my research so far turned up empty.
I tried replacing the hash symbol with its escaped form %23, which of course didn't work (could not find the file specified).
A work-around I'm using in the meantime:
From here, I wrote an extension which tells me the path to the executable set as the default app for opening files with a given extension.
public static string getDefaultAssociation(string extension)
{
if (extension.Substring(0, 1) != ".")
{
int os = extension.IndexOf('.');
if (os > 0)
{
extension = extension.Substring(os);
}
else
{
extension = "." + extension;
}
}
const int S_OK = 0;
const int S_FALSE = 1;
uint length = 0;
uint ret = AssocQueryString(AssocF.None, AssocStr.Executable, extension, null, null, ref length);
if (ret != S_FALSE)
{
//throw new InvalidOperationException("Could not determine associated string");
WriteLog("Could not determine associated string");
return "";
}
var sb = new StringBuilder((int)length); // (length-1) will probably work too as the marshaller adds null termination
ret = AssocQueryString(AssocF.None, AssocStr.Executable, extension, null, sb, ref length);
if (ret != S_OK)
{
//throw new InvalidOperationException("Could not determine associated string");
WriteLog("Could not determine associated string");
return "";
}
return sb.ToString();
}
[DllImport("Shlwapi.dll", CharSet = CharSet.Unicode)]
public static extern uint AssocQueryString(
AssocF flags,
AssocStr str,
string pszAssoc,
string pszExtra,
[Out] StringBuilder pszOut,
ref uint pcchOut
);
[Flags]
public enum AssocF
{
None = 0,
Init_NoRemapCLSID = 0x1,
Init_ByExeName = 0x2,
Open_ByExeName = 0x2,
Init_DefaultToStar = 0x4,
Init_DefaultToFolder = 0x8,
NoUserSettings = 0x10,
NoTruncate = 0x20,
Verify = 0x40,
RemapRunDll = 0x80,
NoFixUps = 0x100,
IgnoreBaseClass = 0x200,
Init_IgnoreUnknown = 0x400,
Init_Fixed_ProgId = 0x800,
Is_Protocol = 0x1000,
Init_For_File = 0x2000
}
public enum AssocStr
{
Command = 1,
Executable,
FriendlyDocName,
FriendlyAppName,
NoOpen,
ShellNewValue,
DDECommand,
DDEIfExec,
DDEApplication,
DDETopic,
InfoTip,
QuickTip,
TileInfo,
ContentType,
DefaultIcon,
ShellExtension,
DropTarget,
DelegateExecute,
Supported_Uri_Protocols,
ProgID,
AppID,
AppPublisher,
AppIconReference,
Max
}
So I can use
string def = getDefaultAssociation("html");
ProcessStartInfo si = new ProcessStartInfo(def);
si.Arguments = url;
si.UseShellExecute = true;
Process.Start(si);
to directly tell my default browser to go to the file URL, INCLUDING the ID hash.
File scheme (file://) just doesn't support anchors or actually any parameters, according to RFC. So query string, anchors or anything else besides path to file can be ignored by whatever processes url with this scheme, which is what happens here. If you try file:///C:/myFile.html?x=1 - query string will also be stripped. If on the other hand you'll try http://google.com?x=1#test then it will open exactly this url in browser, because other scheme.
So I'd say it works as expected and your workaround is fine.
I have a FixedDocument that I allow the user to preview in a WPF GUI and then print to paper without showing any Windows printing dialogue, like so:
private void Print()
{
PrintQueueCollection printQueues;
using (var printServer = new PrintServer())
{
var flags = new[] { EnumeratedPrintQueueTypes.Local };
printQueues = printServer.GetPrintQueues(flags);
}
//SelectedPrinter.FullName can be something like "Microsoft Print to PDF"
var selectedQueue = printQueues.SingleOrDefault(pq => pq.FullName == SelectedPrinter.FullName);
if (selectedQueue != null)
{
var myTicket = new PrintTicket
{
CopyCount = 1,
PageOrientation = PageOrientation.Portrait,
OutputColor = OutputColor.Color,
PageMediaSize = new PageMediaSize(PageMediaSizeName.ISOA4)
};
var mergeTicketResult = selectedQueue.MergeAndValidatePrintTicket(selectedQueue.DefaultPrintTicket, myTicket);
var printTicket = mergeTicketResult.ValidatedPrintTicket;
// TODO: Make sure merge was OK
// Calling GetPrintCapabilities with our ticket allows us to use
// the OrientedPageMediaHeight/OrientedPageMediaWidth properties
// and the PageImageableArea property to calculate the minimum
// document margins supported by the printer. Very important!
var printCapabilities = queue.GetPrintCapabilities(myTicket);
var fixedDocument = GenerateFixedDocument(printCapabilities);
var dlg = new PrintDialog
{
PrintTicket = printTicket,
PrintQueue = selectedQueue
};
dlg.PrintDocument(fixedDocument.DocumentPaginator, "test document");
}
}
The problem is that I want to also support virtual/file printers, namely PDF printing, by giving the file destination path and not showing any Windows dialogues, but that doesn't seem to work with the PrintDialog.
I would really like to avoid 3rd party libraries as much as possible, so at least for now, using something like PdfSharp to convert an XPS to PDF is not something I want to do. Correction: It seems like XPS conversion support was removed from the latest version of PdfSharp.
After doing some research, it seems the only way to print straight to a file is to use a PrintDocument where it's possible to set PrintFileName and PrintToFile in the PrinterSettings object, but there is no way to give the actual document contents, rather we need to subscribe to the PrintPage event and do some System.Drawing.Graphics manipulation where the document is created.
Here's the code I tried:
var printDoc = new PrintDocument
{
PrinterSettings =
{
PrinterName = SelectedPrinter.FullName,
PrintFileName = destinationFilePath,
PrintToFile = true
},
PrintController = new StandardPrintController()
};
printDoc.PrintPage += OnPrintPage; // Without this line, we get a blank PDF
printDoc.Print();
Then the handler for PrintPage where we need to build the document:
private void OnPrintPage(object sender, PrintPageEventArgs e)
{
// What to do here?
}
Other things that I thought could work are using the System.Windows.Forms.PrintDialog class instead, but that also expects a PrintDocument. I was able to create an XPS file easily like so:
var pkg = Package.Open(destinationFilePath, FileMode.Create);
var doc = new XpsDocument(pkg);
var writer = XpsDocument.CreateXpsDocumentWriter(doc);
writer.Write(PreviewDocument.DocumentPaginator);
pkg.Flush();
pkg.Close();
But it's not a PDF, and there seems to be no way to convert it to PDF without a 3rd party library.
Is it possible to maybe do a hack that automatically fills the filename then clicks save on the PrintDialog?
Thank you!
EDIT: It's possible to print directly to PDF from Word documents using Microsoft.Office.Interop.Word, but there seems to be no easy way of converting from XPS/FixedDocument to Word.
EDIT: It seems so far the best way is to grab the old XPS to PDF conversion code that was present in PdfSharp 1.31. I grabbed the source code and built it, imported the DLL's, and it works. Credit goes to Nathan Jones, check out his blog post about this here.
Solved! After googling around I was inspired by the P/Invoke method of directly calling Windows printers.
So the solution is to use the Print Spooler API functions to directly call the Microsoft Print to PDF printer available in Windows (make sure the feature is installed though!) and giving the WritePrinter function the bytes of an XPS file.
I believe this works because the Microsoft PDF printer driver understands the XPS page description language. This can be checked by inspecting the IsXpsDevice property of the print queue.
The "Microsoft Print to PDF" feature must be installed in Windows for this to work!
Here's the code:
using System;
using System.Linq;
using System.Printing;
using System.Runtime.InteropServices;
public static class PdfFilePrinter
{
private const string PdfPrinterDriveName = "Microsoft Print To PDF";
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
private class DOCINFOA
{
[MarshalAs(UnmanagedType.LPStr)]
public string pDocName;
[MarshalAs(UnmanagedType.LPStr)]
public string pOutputFile;
[MarshalAs(UnmanagedType.LPStr)]
public string pDataType;
}
[DllImport("winspool.drv", EntryPoint = "OpenPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool OpenPrinter([MarshalAs(UnmanagedType.LPStr)] string szPrinter, out IntPtr hPrinter, IntPtr pd);
[DllImport("winspool.drv", EntryPoint = "ClosePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool ClosePrinter(IntPtr hPrinter);
[DllImport("winspool.drv", EntryPoint = "StartDocPrinterA", SetLastError = true, CharSet = CharSet.Ansi, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern int StartDocPrinter(IntPtr hPrinter, int level, [In, MarshalAs(UnmanagedType.LPStruct)] DOCINFOA di);
[DllImport("winspool.drv", EntryPoint = "EndDocPrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool EndDocPrinter(IntPtr hPrinter);
[DllImport("winspool.drv", EntryPoint = "StartPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool StartPagePrinter(IntPtr hPrinter);
[DllImport("winspool.drv", EntryPoint = "EndPagePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool EndPagePrinter(IntPtr hPrinter);
[DllImport("winspool.drv", EntryPoint = "WritePrinter", SetLastError = true, ExactSpelling = true, CallingConvention = CallingConvention.StdCall)]
private static extern bool WritePrinter(IntPtr hPrinter, IntPtr pBytes, int dwCount, out int dwWritten);
public static void PrintXpsToPdf(byte[] bytes, string outputFilePath, string documentTitle)
{
// Get Microsoft Print to PDF print queue
var pdfPrintQueue = GetMicrosoftPdfPrintQueue();
// Copy byte array to unmanaged pointer
var ptrUnmanagedBytes = Marshal.AllocCoTaskMem(bytes.Length);
Marshal.Copy(bytes, 0, ptrUnmanagedBytes, bytes.Length);
// Prepare document info
var di = new DOCINFOA
{
pDocName = documentTitle,
pOutputFile = outputFilePath,
pDataType = "RAW"
};
// Print to PDF
var errorCode = SendBytesToPrinter(pdfPrintQueue.Name, ptrUnmanagedBytes, bytes.Length, di, out var jobId);
// Free unmanaged memory
Marshal.FreeCoTaskMem(ptrUnmanagedBytes);
// Check if job in error state (for example not enough disk space)
var jobFailed = false;
try
{
var pdfPrintJob = pdfPrintQueue.GetJob(jobId);
if (pdfPrintJob.IsInError)
{
jobFailed = true;
pdfPrintJob.Cancel();
}
}
catch
{
// If job succeeds, GetJob will throw an exception. Ignore it.
}
finally
{
pdfPrintQueue.Dispose();
}
if (errorCode > 0 || jobFailed)
{
try
{
if (File.Exists(outputFilePath))
{
File.Delete(outputFilePath);
}
}
catch
{
// ignored
}
}
if (errorCode > 0)
{
throw new Exception($"Printing to PDF failed. Error code: {errorCode}.");
}
if (jobFailed)
{
throw new Exception("PDF Print job failed.");
}
}
private static int SendBytesToPrinter(string szPrinterName, IntPtr pBytes, int dwCount, DOCINFOA documentInfo, out int jobId)
{
jobId = 0;
var dwWritten = 0;
var success = false;
if (OpenPrinter(szPrinterName.Normalize(), out var hPrinter, IntPtr.Zero))
{
jobId = StartDocPrinter(hPrinter, 1, documentInfo);
if (jobId > 0)
{
if (StartPagePrinter(hPrinter))
{
success = WritePrinter(hPrinter, pBytes, dwCount, out dwWritten);
EndPagePrinter(hPrinter);
}
EndDocPrinter(hPrinter);
}
ClosePrinter(hPrinter);
}
// TODO: The other methods such as OpenPrinter also have return values. Check those?
if (success == false)
{
return Marshal.GetLastWin32Error();
}
return 0;
}
private static PrintQueue GetMicrosoftPdfPrintQueue()
{
PrintQueue pdfPrintQueue = null;
try
{
using (var printServer = new PrintServer())
{
var flags = new[] { EnumeratedPrintQueueTypes.Local };
// FirstOrDefault because it's possible for there to be multiple PDF printers with the same driver name (though unusual)
// To get a specific printer, search by FullName property instead (note that in Windows, queue name can be changed)
pdfPrintQueue = printServer.GetPrintQueues(flags).FirstOrDefault(lq => lq.QueueDriver.Name == PdfPrinterDriveName);
}
if (pdfPrintQueue == null)
{
throw new Exception($"Could not find printer with driver name: {PdfPrinterDriveName}");
}
if (!pdfPrintQueue.IsXpsDevice)
{
throw new Exception($"PrintQueue '{pdfPrintQueue.Name}' does not understand XPS page description language.");
}
return pdfPrintQueue;
}
catch
{
pdfPrintQueue?.Dispose();
throw;
}
}
}
Usage:
public static void FixedDocument2Pdf(FixedDocument fd)
{
// Convert FixedDocument to XPS file in memory
var ms = new MemoryStream();
var package = Package.Open(ms, FileMode.Create);
var doc = new XpsDocument(package);
var writer = XpsDocument.CreateXpsDocumentWriter(doc);
writer.Write(fd.DocumentPaginator);
doc.Close();
package.Close();
// Get XPS file bytes
var bytes = ms.ToArray();
ms.Dispose();
// Print to PDF
var outputFilePath = #"C:\tmp\test.pdf";
PdfFilePrinter.PrintXpsToPdf(bytes, outputFilePath, "Document Title");
}
In the code above, instead of directly giving the printer name, I get the name by finding the print queue using the driver name because I believe it's constant while the printer name can actually be changed in Windows, also I don't know if it's affected by localization so this way is safer.
Note: It's a good idea to check available disk space size before starting the printing operation, because I couldn't find a way to reliably find out if the error was insufficient disk space. One idea is to multiply the XPS byte array length by a magic number like 3 and then check if we have that much space on disk. Also, giving an empty byte array or one with bogus data does not fail anywhere, but produces a corrupt PDF file.
Note from comments:
Simply reading an XPS file using FileStream will not work. We have to create an XpsDocument from a Package in memory, then read the bytes from the MemomryStream like this:
public static void PrintFile(string xpsSourcePath, string pdfOutputPath)
{
// Write XPS file to memory stream
var ms = new MemoryStream();
var package = Package.Open(ms, FileMode.Create);
var doc = new XpsDocument(package);
var writer = XpsDocument.CreateXpsDocumentWriter(doc);
writer.Write(xpsSourcePath);
doc.Close();
package.Close();
// Get XPS file bytes
var bytes = ms.ToArray();
ms.Dispose();
// Print to PDF
PdfPrinter.PrintXpsToPdf(bytes, pdfOutputPath, "Document title");
}
I want to use c # write a UI Automation program, but I can't find some elements with "Inspect.exe", Can't find pictures of text labels(eg. image1), why?
image1: https://i.stack.imgur.com/NqpKA.png
image2: https://i.stack.imgur.com/2PIuj.png
Code sample:
var desktop = AutomationElement.RootElement;
var condition = new PropertyCondition(AutomationElement.NameProperty, "Customer Register");
var window = desktop.FindFirst(System.Windows.Automation.TreeScope.Children, condition);
The code you posted for getting the elements is correct from what I can see in your screen shot from inspect. I have a feeling that the UI Automation is not getting the name back because of the text encoding. Unless you have access to the source and can mess with how it gets and sets text for those labels it won't be possible to retrieve the text through UI Automation.
You could use the code you have and use the native window handle for the window with the win32 api to get the text.
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, [Out] StringBuilder lParam);
public static string GetWindowTextRaw(IntPtr hwnd)
{
// Allocate correct string length first
int length = (int)SendMessage(hwnd, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero);
StringBuilder sb = new StringBuilder(length + 1);
SendMessage(hwnd, WM_GETTEXT, (IntPtr)sb.Capacity, sb);
return sb.ToString();
}
public static void YourMethod()
{
var desktop = AutomationElement.RootElement;
var process = Process.Start("Path/To/Your/Process.exe");
var condition = new PropertyCondition(AutomationElement.ProcessId, process.Id);
var window = desktop.FindFirst(System.Windows.Automation.TreeScope.Children, condition);
var windowTitle = GetWindowTextRaw(window.NativeWindowHandle)
}
Sources:
GetWindowText
SendMessage
I have a C# form (WPF/XAML) that triggers a new process to open a file using a 3rd party application (SAS JMP) by the default file association:
System.Diagnostics.Process myProcess = new System.Diagnostics.Process();
myProcess.StartInfo.FileName = #"C:\temp\test.jsl";
myProcess.Start();
I'm looking for a way to report back to my application that the process has started and the file has finished opening, or at least, the application window for the new process has appeared.
I tried to wait for myProcess.Responding to return true, but that happens instantly before I even see the application window appear.
Solution based on input from Marcos Vqz de Rdz:
bool alreadyOpen = Process.GetProcesses().Where(p => p.MainWindowHandle != IntPtr.Zero && p.ProcessName == "jmp").Count() > 0;
Process myProcess = new Process();
myProcess.StartInfo.FileName = #"C:\temp\test.jsl";
myProcess.Start();
if (!alreadyOpen)
{
bool wait = true, timeout = false;
DateTime start = DateTime.Now;
while (!timeout && wait)
{
timeout = (DateTime.Now - start).TotalSeconds > 10;
var window = Process.GetProcesses().Where(p => p.Id == myProcess.Id).FirstOrDefault();
if (window != null)
wait = string.IsNullOrEmpty(window.MainWindowTitle);
}
}
Have you tried using Process.WaitForInputIdle Method?
myProcess.WaitForInputIdle();
UPDATE
OK, the only thing I can think of right now, is search for the new application window to show up.
You can find something useful here.
UPDATE
Found this:
var openWindowProcesses = System.Diagnostics.Process.GetProcesses().Where(p => p.MainWindowHandle != IntPtr.Zero);
Use that with a timer right before you start the process to wait for the 3rd party app window to show up.
UPDATE
foreach (var item in openWindowProcesses)
{
Console.WriteLine(GetWindowTitle(item.MainWindowHandle));
}
[System.Runtime.InteropServices.DllImport("user32.dll", CharSet = System.Runtime.InteropServices.CharSet.Auto, SetLastError = true)]
public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult);
private static string GetWindowTitle(IntPtr windowHandle)
{
uint SMTO_ABORTIFHUNG = 0x0002;
uint WM_GETTEXT = 0xD;
int MAX_STRING_SIZE = 32768;
IntPtr result;
string title = string.Empty;
IntPtr memoryHandle = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(MAX_STRING_SIZE);
System.Runtime.InteropServices.Marshal.Copy(title.ToCharArray(), 0, memoryHandle, title.Length);
SendMessageTimeout(windowHandle, WM_GETTEXT, (IntPtr)MAX_STRING_SIZE, memoryHandle, SMTO_ABORTIFHUNG, (uint)1000, out result);
title = System.Runtime.InteropServices.Marshal.PtrToStringAuto(memoryHandle);
System.Runtime.InteropServices.Marshal.FreeCoTaskMem(memoryHandle);
return title;
}
Source: c# Get process window titles
I am trying to get the active window's name as shown in the task manager app list (using c#).
I had the same issue as described here.
I tried to do as they described but I have issue while the focused application is the picture library I get exception.
I also tried this, but nothing gives me the results I expect.
For now I use:
IntPtr handle = IntPtr.Zero;
handle = GetForegroundWindow();
const int nChars = 256;
StringBuilder Buff = new StringBuilder(nChars);
if (GetWindowText(handle, Buff, nChars) > 0)
{
windowText = Buff.ToString();
}
and delete what is not relevant based on a table I created for most common apps, but I don't like this workaround.
Is there a way to get the app name as it is in the task manager for all running app?
After reading a lot, I separated my code into two cases, for metro application and all other applications.
My solution handle the exception I got for metro applications and exceptions I got regarding the platform.
This is the code that finally worked:
[DllImport("user32.dll")]
public static extern IntPtr GetForegroundWindow();
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId);
public string GetActiveWindowTitle()
{
var handle = GetForegroundWindow();
string fileName = "";
string name = "";
uint pid = 0;
GetWindowThreadProcessId(handle, out pid);
Process p = Process.GetProcessById((int)pid);
var processname = p.ProcessName;
switch (processname)
{
case "explorer": //metro processes
case "WWAHost":
name = GetTitle(handle);
return name;
default:
break;
}
string wmiQuery = string.Format("SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId LIKE '{0}'", pid.ToString());
var pro = new ManagementObjectSearcher(wmiQuery).Get().Cast<ManagementObject>().FirstOrDefault();
fileName = (string)pro["ExecutablePath"];
// Get the file version
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(fileName);
// Get the file description
name = myFileVersionInfo.FileDescription;
if (name == "")
name = GetTitle(handle);
return name;
}
public string GetTitle(IntPtr handle)
{
string windowText = "";
const int nChars = 256;
StringBuilder Buff = new StringBuilder(nChars);
if (GetWindowText(handle, Buff, nChars) > 0)
{
windowText = Buff.ToString();
}
return windowText;
}
It sounds like you need to go through each top level window (direct children of the desktop window, use EnumWindows via pinvoke http://msdn.microsoft.com/en-us/library/windows/desktop/ms633497(v=vs.85).aspx) and then call your GetWindowText pinvoke function.
EnumWindows will 'Enumerates all top-level windows on the screen by passing the handle to each window, in turn, to an application-defined callback function.'