阻止Citrix会话超时

时间:2014-02-06 14:00:35

标签: c# citrix

我需要一些在Citrix上运行一夜的应用程序。我不想整夜保持清醒。会话将超时,应用程序将关闭。我不会说服管理员更改此应用程序的Citrix配置。

我正在尝试创建应用程序,该应用程序会定期将鼠标或键盘事件发送到Citrix窗口。我已经有一个简单的解决方案,点击鼠标。

我希望有一个更好的解决方案,一切都将在后台完成,事件将只发送到Citrix窗口。任何想法如何实现?

我正在使用Windows和C#with .NET。

感谢您的帮助。

更新#1

我正在尝试使用Citrix Live Monitoring API,因为它似乎是最佳选择。我最终得到了这个:

WFICALib.ICAClient ico = new WFICALib.ICAClient();
int enumHandle = ico.EnumerateCCMSessions();            
Console.WriteLine(ico.GetErrorMessage(ico.GetLastError()));

不幸的是,这会返回一条错误消息:

  

禁用实时监控

根据文档,它要求将以下注册表项设置为1:

" HKLM \ Software \ Citrix \ ICA Client \ CCM \ AllowLiveMonitoring(REG_DWORD)"

问题是我无法在" HKLM \ Software \"中找到Citrix密钥。如果我创建了这个键和值,它也无法工作。如何启用Live Monitoring API?

1 个答案:

答案 0 :(得分:0)

我过去常常将输入发送到其他窗口。我使用了以下内容:

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    static extern bool SetCursorPos(int x, int y);

    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);

    private const int MOUSEEVENTF_LEFTDOWN = 0x02;

    private const int MOUSEEVENTF_LEFTUP = 0x04;

    private static void LeftMouseClick(Point point)
    {
        int xpos = (int)point.X;
        int ypos = (int)point.Y;
        if (SetCursorPos(xpos, ypos))
        {
            mouse_event(MOUSEEVENTF_LEFTDOWN, xpos, ypos, 0, 0);
            mouse_event(MOUSEEVENTF_LEFTUP, xpos, ypos, 0, 0);
        }
    }

因此,为了完成这项工作,您需要注入属于Citrix Receiver窗口的坐标。我不记得你是否得到任何焦点/激活问题 - 我相信点击注入应该使窗口成为焦点。我从来没有对这段代码做过任何特别严肃的事情,所以没有保证。

相关问题