Barkered
Barkered

Reputation: 67

On-Screen Keyboard hide and run within excel instance to use functionality

To give a brief backstory to bring things up to my current position / reason for my question:

I originally wanted to use sendkeys to send keyboard presses to a Citrix Xenapp Remote Terminal Application (VT320 Emulator).

After some investigation it became apparent that this has been a reasonably common issue.

I eventually found a work-around that involved opening the windows 'On-Screen Keyboard' application and sending mouseclicks using VBA to the OSK app itself. The key transmissions would be successfully received in the remote terminal application.

This solution is a rather awkward and not very practical solution as it relies on many factors e.g. screen resolution, co-ordinates / current position of the OSK etc.

With the above in mind, I am looking to achieve a more full proof method and here's my thoughts:

I'm aware that Sendkeys has its limitations so I have also tried using SendInput via a Keyb_Event and this also didn't work.

To any half experienced expert, I'm clearly a beginner so I'm suffering from a lack of knowledge here perhaps.

Many thanks.

EDIT

I've looked into this a little more and found this post:

Finding the class name of the On-Screen Keyboard?

Which would suggest that if I know the class of the on screen keyboard, I could use its commands within excel VBA?

So hopefully my question is a little easier to answer?

Can I use the class name of the on-screen keyboard app / declare an API function that will allow me to send simulated key functions as if it's the OSK app being clicked by the mouse?

Hopefully someone can help!!

Upvotes: 0

Views: 1265

Answers (1)

donovan
donovan

Reputation: 1472

Trying to automate apps locally can be quite fiddly. Doing it through a Citrix HDX connection is just painful.

Do you have any say over the Citrix environment? If so I'd try writing an automation app that actually runs on the Citrix server in the same session as the published app you're trying to automate. This has the advantage that you're effectively automating a local app which would make life easier.

Depending on how your automation works you may need to communicate between your automation app running in the Citrix session and your client. You could use WCF to bridge the two together.

So that's how I would try and do, as regarding your specific question I've provided some thoughts below...

OSK automation thoughts

I've done some limited automation of the OSK. There are actually two OSKs if you're using Win8. Osk.exe is the old one which has been around a while. TabTip.exe is the new Win8 specific OSK.

One problem to keep in mind is that both of these processes run as high integrity processes which means normal (medium) integrity processes have very limited abilities to automate them. So while I could automate some stuff, many messages would just get ignored. So this maybe why you are finding the OSK is not responding like you expect.

You can work around this by running your automation app as a high integrity process, but this generally means you need local admin (or local system) privilege to start the high integrity process. I never looked into the specifics of how you create high integrity processes. I know there's a command line tool you can use to force a process to run at a certain level (icacls.exe), e.g.

https://msdn.microsoft.com/en-us/library/bb625960.aspx

I imagine there would be APIs to do this as well.

Upvotes: 1

Related Questions