Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Added input.postMessage
Browse files Browse the repository at this point in the history
JTinkers committed Jul 15, 2018
1 parent f9ee551 commit b8c4135
Showing 3 changed files with 34 additions and 421 deletions.
9 changes: 9 additions & 0 deletions ScribeBot/Engine/Wrappers/InputWrapper.cs
Original file line number Diff line number Diff line change
@@ -15,6 +15,15 @@ namespace ScribeBot.Engine.Wrappers
[MoonSharpUserData]
static class InputWrapper
{
/// <summary>
/// Post WinAPI message directly to the window.
/// </summary>
/// <param name="title"></param>
/// <param name="message"></param>
/// <param name="param1"></param>
/// <param name="param2"></param>
public static void PostMessage(string title, uint message, int param1, int param2) => Native.API.PostMessage(title, message, param1, param2);

/// <summary>
/// Get whether a key is down or not.
/// </summary>
21 changes: 21 additions & 0 deletions ScribeBot/Native/API.cs
Original file line number Diff line number Diff line change
@@ -32,6 +32,14 @@ private static IntPtr GetWindowHandleByTitle(string title)
return IntPtr.Zero;
}

/// <summary>
/// Generate a bitmap from screen portion.
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="w"></param>
/// <param name="h"></param>
/// <returns></returns>
public static Bitmap CopyScreenArea( int x, int y, int w = 1, int h = 1 )
{
var container = new Bitmap(w, h);
@@ -50,6 +58,19 @@ public static Bitmap CopyScreenArea( int x, int y, int w = 1, int h = 1 )
return container;
}

/// <summary>
/// Post WinAPI message directly to the window.
/// </summary>
/// <param name="title"></param>
/// <param name="message"></param>
/// <param name="param1"></param>
/// <param name="param2"></param>
public static void PostMessage(string title, uint message, int param1, int param2) => Native.PostMessage(GetWindowHandleByTitle(title), message, param1, param2);

/// <summary>
/// Get an array containing titles of all visible windows.
/// </summary>
/// <returns>An array of strings with window titles.</returns>
public static string[] GetWindowTitles()
{
var processes = Process.GetProcesses().Where(x => !String.IsNullOrEmpty(x.MainWindowTitle));
425 changes: 4 additions & 421 deletions ScribeBot/Native/Native.cs

Large diffs are not rendered by default.

0 comments on commit b8c4135

Please sign in to comment.