Solved

How to send Keystroke or mouse clicks to remote desktop?

Posted on 2015-01-28
15
755 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 80

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 42

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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
LVL 80

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 42

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
 
LVL 42

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 69

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 80

Expert Comment

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

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 69

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Set OWA language and time zone in Exchange for individuals, all users or per database.
This article will help you understand what HashTables are and how to use them in PowerShell.
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

838 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