Tried to get chrome to the front again
This commit is contained in:
@@ -1,33 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using IronOcr;
|
using IronOcr;
|
||||||
using IronOcr.Languages;
|
|
||||||
|
|
||||||
namespace TypeRacer_cheat {
|
namespace TypeRacer_cheat {
|
||||||
class Program {
|
class Program {
|
||||||
static void Main(string[] args) {
|
static void Main(string[] args) {
|
||||||
/* AdvancedOcr ocr = new AdvancedOcr() {
|
Run();
|
||||||
CleanBackgroundNoise = true,
|
|
||||||
EnhanceContrast = true,
|
|
||||||
EnhanceResolution = true,
|
|
||||||
Language = IronOcr.Languages.English.OcrLanguagePack,
|
|
||||||
Strategy = IronOcr.AdvancedOcr.OcrStrategy.Advanced,
|
|
||||||
ColorSpace = AdvancedOcr.OcrColorSpace.Color,
|
|
||||||
DetectWhiteTextOnDarkBackgrounds = true,
|
|
||||||
InputImageType = AdvancedOcr.InputTypes.AutoDetect,
|
|
||||||
RotateAndStraighten = true,
|
|
||||||
ReadBarCodes = true,
|
|
||||||
ColorDepth = 4
|
|
||||||
}; */
|
|
||||||
|
|
||||||
AutoOcr ocr = new AutoOcr();
|
AutoOcr ocr = new AutoOcr();
|
||||||
|
|
||||||
string testImage = @"C:/Users/Ben/Desktop/Programming/Examples/C#/TypeRacer cheat/TypeRacer cheat/bin/Debug/Hey.png";
|
string testImage = @"C:/Users/Ben/Desktop/Programming/Examples/C#/TypeRacer cheat/TypeRacer cheat/bin/Debug/Hey.png";
|
||||||
@@ -37,37 +19,28 @@ namespace TypeRacer_cheat {
|
|||||||
Console.WriteLine("Reading image...");
|
Console.WriteLine("Reading image...");
|
||||||
var Results = ocr.Read(image);
|
var Results = ocr.Read(image);
|
||||||
Console.WriteLine("OCR OUTPUT: {0}", Results.Text);
|
Console.WriteLine("OCR OUTPUT: {0}", Results.Text);
|
||||||
|
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run() {
|
static void Run() {
|
||||||
Process[] procs = Process.GetProcessesByName("chrome");
|
Console.WriteLine("Getting chrome processes");
|
||||||
|
Process[] ChromeProcs = Process.GetProcessesByName("chrome");
|
||||||
|
|
||||||
foreach (Process process in procs) {
|
Console.WriteLine("Testing BringWindowToTop");
|
||||||
Console.WriteLine(process);
|
foreach (Process ChromeProc in ChromeProcs) {
|
||||||
|
bool Success = BringWindowToTop(ChromeProc.MainWindowHandle);
|
||||||
|
if (!Success)
|
||||||
|
Console.WriteLine($"Method fail: {new Win32Exception(Marshal.GetLastWin32Error()).Message}");
|
||||||
|
else
|
||||||
|
Console.WriteLine("Method success");
|
||||||
}
|
}
|
||||||
|
Console.WriteLine("Finished");
|
||||||
if (procs.Length > 0) {
|
Console.ReadLine();
|
||||||
Console.WriteLine("Bringing chrome forward");
|
|
||||||
var handle = procs[0].MainWindowHandle;
|
|
||||||
Console.WriteLine(SetForegroundWindow(handle));
|
|
||||||
Console.WriteLine(BringWindowToTop(handle));
|
|
||||||
Console.WriteLine(ShowWindow(handle, 9));
|
|
||||||
|
|
||||||
Console.WriteLine("Capturing screen");
|
|
||||||
Capture.CaptureScreen();
|
|
||||||
} else {
|
|
||||||
Console.WriteLine("Could not find chrome...");
|
|
||||||
}
|
|
||||||
Console.ReadKey();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("User32.dll")]
|
[DllImport("User32.dll")]
|
||||||
private static extern bool BringWindowToTop(IntPtr hWnd);
|
private static extern bool BringWindowToTop(IntPtr hWnd);
|
||||||
[DllImport("User32.dll")]
|
|
||||||
private static extern bool ShowWindow(IntPtr handle, int nCmdShow);
|
|
||||||
[DllImport("user32.dll")]
|
|
||||||
private static extern bool SetForegroundWindow(IntPtr hWnd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class KeyPress {
|
class KeyPress {
|
||||||
|
|||||||
Reference in New Issue
Block a user