1
votes

I have been trying (with limited resources) to use VBScript and VBA commands to send keyboard functions to a remote citrix terminal. - This, as I've discovered is a known restriction and I've found various articles which give an alternative method via C++ and scancodes to overcome the restriction.

The main issue is, I don't have access to C++.

  • Is there a solution that will allow this with VBScripts and/or VBA?

I've considered many options, including using the windows virtual keyboard (this didn't work) and installing a virtual keyboard driver in windows (well out of my depth).

Here is one of the articles which discuses the scancodes, using C++:

http://www.codeproject.com/Tips/310817/SendKeys-using-ScanCodes-to-Citrix

I am at a loss and anyone who can help would be a super hero...If a super heroes' main appeal was to be a geek god. :)

Any help is appreciated!!!

Cheers.

****UPDATE****

Hello,

I've done a little more digging...

...The Citrix ICA Client terminal window isn't receiving the VBScript sendkeys commands but if I manually press alt in the terminal after executing the script (with a 2 second pause), for example:

*Set objShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 2000
objShell.SendKeys ("e")
objShell.SendKeys "(P)"*

The above can access the 'file', 'edit', etc menu options on the tool bar within the terminal window.

This to me suggests that the issue isn't a privilege issue and I'd think that there is perhaps hope yet for the sendkeys method?

Having looked further into this, there is some documentation re: ini file settings on the Citrix site with regards to Citrix ICA clients.

One of the articles can be found below:

http://support.citrix.com/article/CTX129166

I've had a play around and there does seem to be a few ini files which list keyboard mappings, DLL files, virtual key passthrough as well?

One of the sections of the 'module' ini file contained the following:

[KeyboardLayout]
(User Profile)=0x00000000
(Server Default)=0xFFFFFFFF

There were other codes, including various languages, British, US-International etc.

This was then followed by a list of DLL codes e.g:

kbduk.dll=0x00000809

And finally, Language IDs, e.g:

eng=0x00000809

I am guessing (hoping) that there would be a way to amend the ini settings that will allow for the sendkeys to be received in the terminal fields and not just the toolbar menus.

As before, any help is appreciated....I am slowly going insane over this one!!!

Cheers!

1
you might want to look for OLE (oBject linking and embedding) solutions as a vbscript alternative.Paul Bastide
The only time I've played with input injection i used this library for .NET: inputsimulator.codeplex.com Can you use PowerShell scripting instead? PS allows you to call .NET components.donovan
Hi, thanks for getting back to me. - This sounds promising but I'm not sure re: powershell. Isn't powershell Windows 7 based? (We're due to upgrade from XP but still in the dark ages at present). I certainly have the .Net components installed though...Barkered
Yeah if you're stuck with VBA I run out of ideas pretty quickly. If you were using C/C++ there's a whole bunch of stuff you could do like telling another Window to come into focus and posting messages to other windows. Do you have any way to simulate a mouse click over the ICA window to give it focus?donovan
Thanks for your response. - I've solved this (sort of) by fudging it. In a nutshell: OSK (on screen keyboard) + a combination of VBA script to move the mouse and 'hover' over the OSK and VBS to control which VBA command is used, I can set screen co-ordinates to enable me to 'send' the keypresses via the OSK app...This works! :) - It ain't pretty, but it works and I'm happy with that. I have another question re: how do I open the OSK and move it to a specific set of co-ordinates but I'll raise this separately. :) Cheers!Barkered

1 Answers

1
votes

Bullet pointed solution

What is required:

On screen keyboard (OSK.EXE) windows app VBScript (not essential but preferred by me as controling script) VBA (to move the mouse)

  1. Set OSK to receive 'hover' commands
  2. Set VBA code to move mouse to specific co-ordinates
  3. Use VBScript to control when specific subs from the VBA XLS file are run. - This can be set to run in the background without the requirement for manual opening of the file etc.
  4. Set Citrix Xenapp terminal as active window and key presses should send!

Cheers all!