• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1698
  • Last Modified:

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?
0
Subsun
Asked:
Subsun
  • 6
  • 3
  • 3
  • +1
3 Solutions
 
David Johnson, CD, MVPOwnerCommented:
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
 
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
 The Evil-ution of Network Security Threats

What are the hacks that forever changed the security industry? To answer that question, we created an exciting new eBook that takes you on a trip through hacking history. It explores the top hacks from the 80s to 2010s, why they mattered, and how the security industry responded.

 
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
 
pcelbaCommented:
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
 
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
 
QlemoC++ DeveloperCommented:
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
 
QlemoC++ DeveloperCommented:
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
 
QlemoC++ DeveloperCommented:
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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 6
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now