-
-
Save M3mbrillo/b3667e8b91577b46106a9464d5e85e63 to your computer and use it in GitHub Desktop.
bot comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
using System.Windows.Input; | |
namespace macro_maid | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Hello World!"); | |
//WindowHook.sendKeystroke(65); | |
System.Threading.Thread.Sleep(3000); | |
for (int i = 0; i < 2000; i++) | |
{ | |
var message = $"comment {i} $"; | |
foreach (var @char in message) | |
{ | |
WindowHook.sendKeystroke( | |
WindowHook.VkKeyScan(@char) | |
); | |
} | |
WindowHook.sendKeystroke(0x0D); //enter | |
System.Threading.Thread.Sleep(3000); | |
} | |
} | |
} | |
class WindowHook | |
{ | |
[DllImport("user32.dll")] | |
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); | |
[DllImport("user32.dll")] | |
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); | |
[DllImport("user32.dll")] | |
public static extern IntPtr PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); | |
[DllImport("user32.dll")] | |
public static extern short VkKeyScan(char ch); | |
//public static Keys ConvertCharToVirtualKey(char ch) | |
//{ | |
// short vkey = VkKeyScan(ch); | |
// Keys retval = (Keys)(vkey & 0xff); | |
// int modifiers = vkey >> 8; | |
// if ((modifiers & 1) != 0) retval |= Keys.Shift; | |
// if ((modifiers & 2) != 0) retval |= Keys.Control; | |
// if ((modifiers & 4) != 0) retval |= Keys.Alt; | |
// return retval; | |
//} | |
public static void sendKeystroke(short key_code) | |
{ | |
const uint WM_KEYDOWN = 0x100; | |
const uint WM_CHAR = 0x102; | |
const uint WM_KEYUP = 0x101; | |
// puntero a una ventana de widows, con SPY++ podes sacar cual es el puntero del navegador | |
IntPtr WindowToFind = new IntPtr(0x209A4); // FindWindow(null, "Untitled-2 - Visual Studio Code"); | |
PostMessage(WindowToFind, WM_KEYDOWN, new IntPtr(key_code), new IntPtr(0xE001)); | |
//PostMessage(WindowToFind, WM_KEYDOWN, new IntPtr(0x43), new IntPtr(0xE001)); | |
//PostMessage(WindowToFind, WM_CHAR, new IntPtr(0x63), new IntPtr(0xE001)); | |
//PostMessage(WindowToFind, WM_KEYUP, new IntPtr(0x43), new IntPtr(0xC02E001)); | |
//IntPtr result3 = SendMessage(WindowToFind, WM_KEYUP, ((IntPtr)c), (IntPtr)0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment