JamesMenetrey / MemorySharp

A C# based memory editing library targeting Windows applications, offering various functions to extract and inject data and codes into remote processes to allow interoperability.
Other
631 stars 134 forks source link

Keyboard press and write does not work. #14

Closed gKreator closed 6 years ago

gKreator commented 6 years ago

It seems like the Keyboard press and write does not work. I tried this with both Notepad and Notepad++. Does anyone know of a fix for this? Thanks!

Using Version 1.2 of MemorySharp. Windows 10 x64 VS2017

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Binarysharp.MemoryManagement; using System.Diagnostics;

namespace memsharp_test_1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void Form1_Load(object sender, EventArgs e)
    {
        var sharp = new MemorySharp(Process.GetCurrentProcess());

        var tlsPtr = sharp.Threads.MainThread.Teb.Tls;

        Console.WriteLine(tlsPtr.ToString());

        var wh = sharp.Windows.GetWindowsByTitleContains("Notepad").FirstOrDefault();

        Console.WriteLine(wh.ToString());

        wh.Keyboard.Press(Binarysharp.MemoryManagement.Native.Keys.A); // does nothing
        wh.Keyboard.PressRelease(Binarysharp.MemoryManagement.Native.Keys.A); // does nothing

        wh.Width = 800; // works
        wh.Height = 600; // works

        wh.Keyboard.Write("test 123"); // does nothing

    }
}

}

madebyvince commented 6 years ago

Hi, I'm having the exact same issue and haven't been able to find a solution so far... Is there anyone who can help??? Thanks.

JamesMenetrey commented 6 years ago

Hey dudes !

You have the exact code to send keys to Notepad++ in the README of the project. 🙄

Look at the section called Query/interact with windows. To send inputs, you need to target Window. In the instance of Notepad++, you need to select the component Scintilla.

Cheers, ZenLulz