Let’s say I have installed http://technet.microsoft.com/en-us/sysinternals/cc817881
I want to be able to sendmessage with win32 api but targeting the second virtual desktop while I will stay on first virtual desktop.
How to do that in c# ?
Update: for the context, what I’d like is to automate a manual task in background at periodic interval on an application which would reside in 2nd virtual desktop while I’m working on first desktop.
The link you provide describes a tool which is based on the Windows built-in desktop-mechanism.
Basically this means that you have really distinct desktops (with separate Logon!) which do not interact – they can’t even see the windows of each other, i.e.unlike other “virtual desktop utilities” you can’t move a window or application from one desktop to another.
This is the reference on MSDN to the use Desktop API which among other things explains the permissions issues etc. involved in such an undertaking.
Only way you could achieve what you want in this situation is to build a Windows Service which in turn monitors desktop startup/shutdown.
In case of desktop startup you need to start a process inside that desktop.
This process must offer some sort of desktop-agnostic IPC mechanism like TCP/IP or global mutex + global shared memory or similar…
You communicate with that process and this process does whatever you need (SendMessage, SendKeys…) inside that desktop on your behalf.