0

I've spent much of the last two days trying to figure out how to send a Ctrl-Space to an app running on Citrix. My script is Python-based, and I have tried various solutions from SendKeys through Pywin32 and SendInput(), as well as solutions outlined in these posts among others I have long since closed: Generate Keyboard events in python SendInput

The issue is these all seem to be sending text or simulated keypresses, which Citrix is not recognizing. What it seems like I need to do is emulate the hardware keypress rather than sending directly to the app. Many of the solutions are in C (or similar), with which I am unacquainted.

Does anyone have a Python-based solution for this? Or a way to include C or VB.NET code in Python? There was a VB solution listed here that may or may not work, but I'm not sure how to import its functionality into my Python-based script.

Any suggestions are appreciated!

EDIT: To underscore the need for direct hardware manipulation rather than simulated keypresses, I sent the following commands to the Citrix app:

        SendInput(Keyboard(VK_RETURN))
        SendInput(Keyboard(VK_RETURN, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_CAPITAL))
        SendInput(Keyboard(KEY_L))
        SendInput(Keyboard(KEY_L, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_CAPITAL, KEYEVENTF_KEYUP))
        SendInput(Keyboard(KEY_0))
        SendInput(Keyboard(KEY_0, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_SPACE))
        SendInput(Keyboard(VK_SPACE, KEYEVENTF_KEYUP))
        SendInput(Keyboard(KEY_A))
        SendInput(Keyboard(KEY_A, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_BACK))
        SendInput(Keyboard(VK_BACK, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_CONTROL))
        SendInput(Keyboard(KEY_A))
        SendInput(Keyboard(KEY_A, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_CONTROL, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_LCONTROL))
        SendInput(Keyboard(KEY_V))
        SendInput(Keyboard(KEY_V, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_CONTROL, KEYEVENTF_KEYUP))
        SendInput(Keyboard(VK_RETURN))
        SendInput(Keyboard(VK_RETURN, KEYEVENTF_KEYUP))

And I got the following output in the app: =tbd7w\=

ipenguin67
  • 1,483
  • 5
  • 22
  • 39

1 Answers1

1

I finally found something that worked: Keyboard

This successfully sent keystrokes, including modifiers, to a Citrix application. To send CTRL-SPACE as described above is as easy as Keyboard.send('ctrl-space'). Hope this helps someone!

Developer Guy
  • 2,318
  • 6
  • 19
  • 37
ipenguin67
  • 1,483
  • 5
  • 22
  • 39