SendKey.Send(变量)在其他计算机上不起作用

SendKey.Send(variable) does not work on other computers

有人告诉我他需要一个程序来在另一个应用程序的文本框中键入名称。我无法从应用程序中获得 API。他必须键入 excel 文件中列出的名称。在每个名字之后,他必须按 enter 来创建类似于 YouTube 或 Whosebug 中的标签的内容。 除非有任何我不知道的代码,否则除了这样做之外别无他法。这就是我寻求帮助的原因。 我考虑过看看这些,但没有答案是解决方案。
Why does SendKey.Send() only work once in a while? --> appsetting 添加到配置文件。
SendKey.Send() Not working --> 我必须输入变量

我成功创建了这个应用程序。我在笔记本电脑和台式机上都对其进行了测试。它适用于两者。 它也适用于家庭成员的笔记本电脑。这个家庭成员是一个普通的计算机用户,不会编写任何代码。

计划目标:
键入 excel 文件中列出的名称,并将它们与任何值分隔到另一个 application/site.

例如:
值:
琼斯
福尔摩斯
约翰逊
波特

分隔值=“;”

输出:
琼斯;福尔摩斯;约翰逊;波特

问题是:
该应用程序不适用于随机计算机(笔记本电脑和台式机)。该应用程序一直运行到它必须执行 SendKey.Send 命令为止。但几秒钟后,应用程序确认整个过程已执行。此确认在我的应用程序中使用消息框进行了硬编码。在确认之前,它只键入名字的第一个字符。

所有提到的计算机都是 windows 10。 我已经用 SendKeys.Send 和 SendKeys.Send 等等试过了。

在此先感谢您的帮助!


代码:(通过简单的按钮点击触发)

List<string> Values = new List<string>(); //These are set by another method --> it's not empty and works fine
string Split = string.Empty;
switch (strSplitValue)
{
    case "ENTER":
        Split = "";
    break;
    case "SPATIE":
        Split = " ";
    break;
    case ",":
        Split = ", ";
    break;
    case ";":
        Split = ";";
    break;
    case "/":
        Split = "/";
    break;
    case "\":
        Split = "\";
    break;
    default:
        Split = strSplitValue;
    break;
}
//A messagebox pops up here to clarify that the user has 8s to click with the mouse on the place where the application has to type its values. After pessed ok, it goes on.
//This messagebox always works. The program fails from the moment it executes SendKeys.Send
try {
        foreach (string x in Values)
        {
            string strSendkeys = x + Split;
            SendKeys.Send(strSendkeys);
        if (strSplitValue == "ENTER")
            {
                Thread.Sleep(1200);
                SendKeys.Send("{ENTER}");
                Thread.Sleep(200);
            }
    }
    MessageBox.Show("Task succeeded!", "Succeeded!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch {
    MessageBox.Show("Something went wrong.");
}

显然,我设法用 SendKeys.SendWait 完成了这项工作。 第一次尝试成功,然后再次尝试失败,后来它继续永久工作。