Solved

How to send Keystroke or mouse clicks to remote desktop?

Posted on 2015-01-28
15
513 Views
Last Modified: 2015-02-17
Does anyone know any tool or method to send Keystroke or mouse clicks to remote desktop?
0
Comment
Question by:Subsun
  • 6
  • 3
  • 3
  • +1
15 Comments
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 200 total points
ID: 40577080
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
 
LVL 41

Expert Comment

by:pcelba
ID: 40577098
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
 
LVL 40

Author Comment

by:Subsun
ID: 40577120
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
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40577237
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
 
LVL 40

Author Comment

by:Subsun
ID: 40577284
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
 
LVL 41

Expert Comment

by:pcelba
ID: 40577338
Application launch on multiple servers can be done by PS Tools: https://technet.microsoft.com/en-us/sysinternals/bb896649.aspx
0
 
LVL 40

Author Comment

by:Subsun
ID: 40577372
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 41

Accepted Solution

by:
pcelba earned 200 total points
ID: 40578407
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
 
LVL 40

Author Comment

by:Subsun
ID: 40596171
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40596745
Are you able to use Tab to go to that tab, and then press Return to "click" the button?
0
 
LVL 40

Author Comment

by:Subsun
ID: 40598204
@Qlemo, Yes, I can do that, first I need to select the application then use tab keys..
0
 
LVL 78

Expert Comment

by:David Johnson, CD, MVP
ID: 40598247
auto-it or autohotkey as previously mentioned will do it.
0
 
LVL 68

Assisted Solution

by:Qlemo
Qlemo earned 100 total points
ID: 40598979
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
 
LVL 68

Expert Comment

by:Qlemo
ID: 40598985
This does not work with the RDP session, it needs to be run on the remote system directly.
0
 
LVL 40

Author Comment

by:Subsun
ID: 40614722
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..
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now