OSK is a very special process since it can be used to inject input into other applications and is a potential security weakness. One of the consequences of the security measures that the OS puts around it are that it cannot easily be started by a WOW64 process. To deal with this you need to create a simple x64 executable that starts OSK. Then from your x86 process running under WOW64, start that intermediary executable whenever you need to start OSK. Obviously you should only do this from a WOW64 process. If you are running on a 32 bit system, then you must not attempt to start a 64 bit executable.
Note that the answers at this question (Unable to launch onscreen keyboard (osk.exe) from a 32-bit process on Win7 x64) suggest disabling file system redirection while you launch OSK. However, disabling file system redirection, even for a short period of time, is a very dangerous act and I would not recommend doing so. Whilst it might seem messy to spin up another process just so that you can start yet another process, I regard that to be the best solution to your problem.
There are some more interesting observations here: https://stackoverflow.com/a/23128178/505088. Of particular interest is the fact that CreateProcess
is blocked from starting OSK. It has to be done by ShellExecuteEx
. Or presumably ShellExecute
but as regular readers of my posts will know, I shun ShellExecute
because of its broken error handling mechanism.
I would say, as an aside, that if you really must execute as an x86 process, then it seems wrong to target AnyCPU. You should target x86.
Update
It's clear from the comments and your question edit that you have not fully understood this answer. I'll try spell it out a little more clearly. You need the following:
- A 32 bit process in order to use Awesomium.
- A 64 bit process in order to start OSK.
So, that's two processes. Your main process is the 32 bit one. When you need to show the OSK, start the 64 bit process which in turn starts OSK. The 64 bit process can terminate as soon as it has started OSK.