如何发送消息选项卡和向上箭头发送到winform?C#


using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
public class Program
{
//include FindWindowEx
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, int lParam);
//include SendMessage
[DllImport("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
//this is a constant indicating the window that we want to send a text message
const int WM_SETTEXT = 0X000C;
const int WM_KEYDOWN = 0x0100;
const int WM_KEYUP = 0x0101;
static void Main(string[] args)
{
//getting notepad's process | at least one instance of notepad must be running
Process notepadProccess = Process.GetProcessesByName("Codns3")[0];
//getting notepad's textbox handle from the main window's handle
//the textbox is called 'Edit'
IntPtr notepadTextbox = FindWindowEx(notepadProccess.MainWindowHandle, IntPtr.Zero, "Edit", null);//창핸들
IntPtr codnsButton = FindWindowEx(notepadProccess.MainWindowHandle, IntPtr.Zero, "#32770", null);//창핸들
//sending the message to the textbox 0x26
//SendMessage(codnsButton, WM_KEYDOWN, 0x26, 0x26);
//SendMessage(codnsButton, WM_KEYUP, 0x26, 0x26);
SendMessage((System.IntPtr)00430350, 0021, 00430350, 02010001);
SendMessage(notepadTextbox, WM_SETTEXT, 0, "172846200035");
}
}

当实际传递字符串时,它会被传递给编辑类。在此之前,程序启动uparrow -> enter -> string to edit class之后就像这样。但目前uparrow和enter键没有被传递。问题出在哪里?我附上我的代码。

基本上,在运行程序时,第一个表单有两个复选框,其中复选框位于底部。在这里,如果在单击程序窗口后单击向上箭头,复选框按钮将从底部移动到顶部。

之后,按Enter键,将显示第二个表单。在第二个表单上点击选项卡两次后,输入所需数字您需要再次按Enter键登录。

你应该每天重新启动计算机来尝试这个过程。我通过谷歌铃声找到的是输入想要的号码这将自己跳过第一个表单,并执行我在第二个表单中找到的源,并将其输入到第一个文本框中。所以我所需要做的就是按下制表键和箭头键上方的箭头键。

你必须想办法。我现在能做的是在第一个焦点文本框中输入数字、简单字母等。

最新更新