How to send Keystroke or mouse clicks to remote desktop?

Does anyone know any tool or method to send Keystroke or mouse clicks to remote desktop?
LVL 40
SubsunAsked:
Who is Participating?
 
pcelbaConnect With a Mentor Commented:
In such case you have to execute several EXEs (two at least) under the same RDP session. One of them is your application the other one is checking the app state and sends the keystrokes.

The one sending keystrokes must have admin rights.

To confirm login dialog is not so easy and you'll need some C and Windows internals programmer help.

You should rather redesign your app to work without keyboard/mouse interaction.
0
 
David Johnson, CD, MVPConnect With a Mentor OwnerCommented:
Simple answer is that you can't unless you use something like sendkey or (autohotkey) since you are only seeing a representation of the screen and also sending a representation of the keyboard/mouse
0
 
pcelbaCommented:
You should better specify what is your goal. To send any Windows event to the Remote desktop itself is possible because it is just another application in your Windows environment.

To send mouse clicks and keystrokes to an application running under the Remote desktop is  a little bit more difficult but you may look at this code: http://www.codeguru.com/vb/gen/vb_system/keyboard/article.php/c14629/SendKeys.htm
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
SubsunAuthor Commented:
Thanks for the response, I was in a perception that, SendKeys doesn't work with Remote Desktop. I am trying to automate a application launch on multiple servers. The legacy application need some need some manual intervention, I mean we need to select some tabs and click some buttons to start it. We also need to start the app in two different user sessions.
0
 
David Johnson, CD, MVPOwnerCommented:
on the server where the app lies use an auto-it or autohotkeys script to open it and call the script and not the application directly
0
 
SubsunAuthor Commented:
But in that case also we need to open the user sessions. which is a challenge.. Because we have a license agreement while login which I need to press OK. For some reason our management is not ready to suppress it.
0
 
pcelbaCommented:
Application launch on multiple servers can be done by PS Tools: https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
0
 
SubsunAuthor Commented:
Like I said simply launching the app wont help as it required some manual intervention to start functioning. Also we need to start it from two different user sessions. And while login in to this sessions we need to press ok to a legal warning.
0
 
SubsunAuthor Commented:
Redesigning of app is not an option, as it is a legacy app and also building new app will take time..

Can anyone give a working example on selecting tab in a third-party application window and clink a button on that window?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Are you able to use Tab to go to that tab, and then press Return to "click" the button?
0
 
SubsunAuthor Commented:
@Qlemo, Yes, I can do that, first I need to select the application then use tab keys..
0
 
David Johnson, CD, MVPOwnerCommented:
auto-it or autohotkey as previously mentioned will do it.
0
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
In VBS, this is something along
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.AppActivate "Beginning of your application window ttle"
WScript.Sleep 250
Wshshell.SendKeys "{TAB}"
WScript.Sleep 250
Wshshell.SendKeys "{ENTER}"

Open in new window

PowerShell is very similar:
$wsh = New-Object -Com WScript.Shell
$wsh.AppActivate('Beginning of your application window ttle')
start-sleep -m 250
$wsh.SendKeys('{TAB}')
start-sleep -m 250
$wsh.SendKeys('{ENTER}')

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
This does not work with the RDP session, it needs to be run on the remote system directly.
0
 
SubsunAuthor Commented:
Unfortunately I couldn't make any suggestion to work as per my requirement in remote desktop..  I will have to work with product development team to see if there any option to start the application without any manual intervention. I am not deleting this question as there is some valuable suggestion which may help others..
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.