Skip to content

Commit af546f3

Browse files
committed
Support live windows (games, video, animation, etc.)
1 parent 41362be commit af546f3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+830
-417
lines changed

WindowTextExtractor/Extensions/AutomationElementExtensions.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.ComponentModel;
55
using System.Windows.Automation;
66
using WindowTextExtractor.Native;
7+
using WindowTextExtractor.Native.Structs;
78

89
namespace WindowTextExtractor.Extensions
910
{
@@ -32,21 +33,21 @@ public static string GetTextFromConsole(this AutomationElement element)
3233
{
3334
try
3435
{
35-
NativeMethods.FreeConsole();
36-
var result = NativeMethods.AttachConsole(element.Current.ProcessId);
36+
Kernel32.FreeConsole();
37+
var result = Kernel32.AttachConsole(element.Current.ProcessId);
3738
if (!result)
3839
{
3940
var error = Marshal.GetLastWin32Error();
4041
throw new Win32Exception(error);
4142
}
42-
var handle = NativeMethods.GetStdHandle(NativeConstants.STD_OUTPUT_HANDLE);
43+
var handle = Kernel32.GetStdHandle(Constants.STD_OUTPUT_HANDLE);
4344
if (handle == IntPtr.Zero)
4445
{
4546
var error = Marshal.GetLastWin32Error();
4647
throw new Win32Exception(error);
4748
}
4849
ConsoleScreenBufferInfo binfo;
49-
result = NativeMethods.GetConsoleScreenBufferInfo(handle, out binfo);
50+
result = Kernel32.GetConsoleScreenBufferInfo(handle, out binfo);
5051
if (!result)
5152
{
5253
var error = Marshal.GetLastWin32Error();
@@ -58,7 +59,7 @@ public static string GetTextFromConsole(this AutomationElement element)
5859
for (var i = 0; i < binfo.dwSize.Y; i++)
5960
{
6061
uint numberOfCharsRead;
61-
if (NativeMethods.ReadConsoleOutputCharacter(handle, buffer, (uint)buffer.Length, new Coord(0, (short)i), out numberOfCharsRead))
62+
if (Kernel32.ReadConsoleOutputCharacter(handle, buffer, (uint)buffer.Length, new Coord(0, (short)i), out numberOfCharsRead))
6263
{
6364
textBuilder.AppendLine(new string(buffer));
6465
}
@@ -69,7 +70,7 @@ public static string GetTextFromConsole(this AutomationElement element)
6970
}
7071
catch
7172
{
72-
NativeMethods.FreeConsole();
73+
Kernel32.FreeConsole();
7374
return null;
7475
}
7576
}

WindowTextExtractor/Extensions/ProcessExtensions.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
using System.Diagnostics;
33
using System.Runtime.InteropServices;
44
using WindowTextExtractor.Native;
5+
using WindowTextExtractor.Native.Enums;
6+
using WindowTextExtractor.Native.Structs;
57

68
namespace WindowTextExtractor.Extensions
79
{
@@ -12,7 +14,7 @@ public static bool IsWow64Process(this Process process)
1214
if ((Environment.OSVersion.Version.Major > 5) || ((Environment.OSVersion.Version.Major == 5) && (Environment.OSVersion.Version.Minor >= 1)))
1315
{
1416
bool retVal;
15-
return NativeMethods.IsWow64Process(process.Handle, out retVal) && retVal;
17+
return Kernel32.IsWow64Process(process.Handle, out retVal) && retVal;
1618
}
1719

1820
return false;
@@ -22,7 +24,7 @@ public static Process GetParentProcess(this Process process)
2224
{
2325
var pbi = new PROCESS_BASIC_INFORMATION();
2426
int returnLength;
25-
var status = NativeMethods.NtQueryInformationProcess(process.Handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength);
27+
var status = Ntdll.NtQueryInformationProcess(process.Handle, 0, ref pbi, Marshal.SizeOf(pbi), out returnLength);
2628
if (status != 0)
2729
{
2830
return null;
@@ -40,7 +42,7 @@ public static Process GetParentProcess(this Process process)
4042

4143
public static Priority GetProcessPriority(this Process process)
4244
{
43-
var priorityClass = NativeMethods.GetPriorityClass(process.Handle);
45+
var priorityClass = Kernel32.GetPriorityClass(process.Handle);
4446
switch (priorityClass)
4547
{
4648
case PriorityClass.REALTIME_PRIORITY_CLASS: return Priority.RealTime;

WindowTextExtractor/Forms/AboutForm.Designer.cs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WindowTextExtractor/Forms/MainForm.Designer.cs

Lines changed: 78 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)