【问题标题】:unable to send a string to an application which run on citrix无法将字符串发送到在 citrix 上运行的应用程序
【发布时间】:2015-04-27 14:52:15
【问题描述】:

我需要将输入值(string)发送到另一个在 Citrix 上运行的应用程序,该应用程序当前在前台(活动窗口)

我已尝试以下链接

  1. How do I get the title of the current active window using c#?

  2. How to send a string to other application including Microsoft Word

  3. I can't understand how to use SendMessage or PostMessage calls

  4. 复制和粘贴选项-但这也不起作用

    Send clipboard text or key stroke to current active window

  5. 试过输入模拟器

    SendKeys alternative that works on Citrix

在第 5 个选项中,第 2 个建议的答案声明更新/修改 Inputsimulator 应用程序类,但我在我的应用程序中添加了一个 nuget 包。那么,我该如何相应地更新它。

下面是使用输入模拟器的代码

 string co = "This is a test° This is a test° This is a test° This is a test°This is a test°This is a test°";
 WindowsInput.InputSimulator cc = new WindowsInput.InputSimulator();
 cc.Keyboard.TextEntry(co);

如何向 citrix 应用程序发送字符串?

【问题讨论】:

  • 每次尝试失败的原因是什么?对于 1) f.e.,您在调用 GetActiveWindowTitle() 时得到了什么?
  • 我正在获取活动窗口的标题,但错误是发送值 sendInput 、 sendMessage 、 sendKeys 和 Keyboard.textentry 所有这些都在活动窗口中插入一些随机数。
  • 好吧,我建议您更具体地了解期望、观察结果以及您试图提高获得答案的概率的内容。无论如何,关于 nuget 包,这是一个不同的问题,可以/应该被拆分,我只是忍受痛苦,摆脱已安装的 nuget 包 ref,获取 Inputsimulator 的源,自己编译并添加新的编译的程序集作为对您项目的引用,以便您可以正确地对其进行测试和修改。

标签: c# sendkeys citrix virtual-keyboard


【解决方案1】:

我在设计的应用程序中遇到了类似的问题,我使用 SendKey Events 解决了这个问题,它工作得很好。当我使用 Sendkeys 时,它从未正常工作,但是当我使用 SendKey 事件时,它解决了问题。我知道 sendkey 事件用于发送表示测试不能像向下翻页等内容的代码,但我也将它用于所有文本发送。

这里是一个 C# 代码示例,供您发送发送键事件

// Clicking Button1 causes a message box to appear.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    MessageBox.Show("Click here!");
}


// Use the SendKeys.Send method to raise the Button1 click event 
// and display the message box.
private void Form1_DoubleClick(object sender, System.EventArgs e)
{

    // Send the enter key; since the tab stop of Button1 is 0, this
    // will trigger the click event.


    SendKeys.Send("{ENTER}");
    // try putting your text in here and see if something like this solves your issue
}

如果您认为您可能需要它,请尝试访问此Reference 以进一步了解 SendKey 事件并祝您好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-22
    • 1970-01-01
    相关资源
    最近更新 更多