views:

252

answers:

4

I have a code that triggers PASTING to any 3rd party application by sending ctrl+v (see below), but this does not seem to work with CITRIX. is there any other method to trigger ctrl+v than keyb simulation?

keybd_event(VK_CONTROL, Lo(MapVirtualKey(VK_CONTROL,0)), 0,0);
keybd_event(86, Lo(MapVirtualKey(86,0)), 0,0);
keybd_event(86, Lo(MapVirtualKey(86,0)), KEYEVENTF_KEYUP,0);
+3  A: 

Maybe, you can send a WM_PASTE message to the application?

Gamecat
A: 

You can try PostKeyEx32

I Wrote a article in Portuguese, but you can read the code, it is simple.

http://www.cesarromero.com.br/simulando-keypress-com-postkeyex32/

You can send CTRL + Vm like this:

PostKeyEx32(Ord('V'), [ssCtrl], False);
Cesar Romero
A: 

I think the critical statement here is -- with CITRIX.

My experience with inter-communication with citrix applications is that many things which work fine on a normal desktop, fail when run in a citrix environment. I would first try to send a WM_PASTE message as Gamecat suggested, and if that fails you might want to make sure that your clients are running your application thru a citrix desktop, NOT by running the applications directly from a shortcut on their desktop. When a citrix application is launched from an external shortcut, it gets a different session than when it is launched from an internal shortcut on the citrix desktop.

skamradt
+1  A: 

Ah, the nice problems with Citrix!

  1. I would 1st check on the receiving application side that you actually have something in the clipboard. Try to paste manually there. If it's empty, it's not an automation/keyboard hook problem.
  2. If the clipboard content is indeed available, I would then try different ways to communicate with the receiving application: sending windows messages (WM_PASTE, but also others in case of failure to see if any can go through), but also look if you can do DDE.
François