1

I need some applications running overnight on Citrix. I don't wish to stay awake all night for that. The Session will timeout and application will be closed. I would not convince the administrator to change the Citrix configuration for this application.

I am trying to create application which will periodically send mouse or keyboard events to the Citrix window. I already have a simple solution which is clicking the mouse.

I wish to have a better solution where everything will be done on background and events would be send just to the Citrix window. Any ideas how to achieve that?

I am using Windows and C# with .NET.

Thank you for any help.

Update #1

I am trying to use Citrix Live Monitoring API as it appears to be a best option. I end up with this:

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

Unfortunately this returns an error message saying:

Live monitoring is disabled

According to documentation it requires following registry keys to be set to 1:

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

Problem is that I was unable to find Citrix key in "HKLM\Software\" and it also don't work if I created this keys and values. How do I enable Live Monitoring API?

1 Answers1

0

I have played around with sending input to other windows in the past. I used something like the following:

    [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);
        }
    }

So to make this work you need to inject coordinates that fall within the Citrix Receiver window. I can't recall whether you get any focus/activation issues - I believe the click injection should bring the window into focus. I never did anything particularly serious with this code so no guarantees.

donovan
  • 1,442
  • 9
  • 18
  • This is the current solution and I am looking for better one. Solution which would not require citrix window to have focus. – Ondřej Fitzek Feb 07 '14 at 09:25