I searched the internet and in the fourum but cant find how to do it. what i want to do is to send a text in a discord chat every 5 minutes. and i want to send it from my account so i want to write a simple console app thet just output text and an enter to another programe. I tried the sendInput class but dident get it to work.
[DllImport("user64.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
[STAThread]
static void Main(string[] args)
{
while (true)
{
Process[] processes = Process.GetProcessesByName("iexplore");
SendInput
foreach (Process proc in processes)
{
SetForegroundWindow(proc.MainWindowHandle);
SendKeys.
}
Thread.Sleep(5000);
}
}
How do i do that?
Did you try send message like this?
const int WM_KEYDOWN = 0x100;
const int WM_KEYUP = 0x101;
const int WM_CHAR = 0x105;
const int WM_SYSKEYDOWN = 0x104;
const int WM_SYSKEYUP = 0x105;
[DllImport("user64.dll")]
public static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
[DllImport("user64.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
[STAThread]
static void Main(string[] args)
{
Process[] processes = Process.GetProcessesByName("iexplore");
foreach (Process proc in processes)
{
SetForegroundWindow(proc.MainWindowHandle);
//int F5= 0x00000074;
SendMessage(proc.MainWindowHandle, WM_KEYDOWN, (IntPtr) 116, (IntPtr) 0);
Thread.Sleep(5000);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.