jasonpang / Interceptor

C# wrapper for a Windows keyboard driver. Can simulate keystrokes and mouse clicks in protected areas like the Windows logon screen (and yes, even in games). Wrapping http://oblita.com/Interception
MIT License
286 stars 84 forks source link

how to use it into button1_click and timer #2

Closed nicely closed 4 years ago

nicely commented 9 years ago

using Interceptor; 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;

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

    private void button1_Click(object sender, EventArgs e)
    {

        timer1.Enabled = true;
        timer1.Interval = 1000;

    }

    private void timer1_Tick(object sender, EventArgs e)
    {
        Input input = new Input();

        // Be sure to set your keyboard filter to be able to capture key presses and simulate key presses
        // KeyboardFilterMode.All captures all events; 'Down' only captures presses for non-special keys; 'Up' only captures releases for non-special keys; 'E0' and 'E1' capture presses/releases for special keys
        input.KeyboardFilterMode = KeyboardFilterMode.All;
        // You can set a MouseFilterMode as well, but you don't need to set a MouseFilterMode to simulate mouse clicks

        // Finally, load the driver
        input.Load();

        input.SendKeys(Interceptor.Keys.Enter);
        input.SendText("hello, I am typing!");
        input.Unload();
    }
}

}

it is not working , any suggestion please ? (on windows 8)