Jump to content

MSTSC and AutoIT


 Share

Recommended Posts

Is it possible to control the application on remote desktop (MSTSC - RDP / Terminal Server Connection) using Autoit? My intention is to open a user session using MSTSC and open a program in the user session and select a tab, and the clik a ok button in that tab. Please let me know if it is possible or not. If yes. can anyone give any example script? many thanks in advance.

Link to comment
Share on other sites

  • Moderators

You can control the RDP connection, but it sounds like you're asking about launching a connection and then controlling an application on the remote machine is that correct? If so, what is the application? That will determine how easy it is to manipulate, as some GUI-driven apps can be challenging through a remote console.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

hello Subashes, welcome to AutoIt and to the forum!

the limitation is that direct handling of windows and controls over remote session is not possible, as the user actually sees a video of what's going on the server - and you have no contact with the elements of that video. you can simulate mouse clicks, but that heavily depends on the correct visual identification of the elements, and requires lack of user interference (yeah, like that never happens... ;) )

best solution: prepare an AutoIt script that does what you want on the server, then compile it and either publish it (Terminal Server style) or use its shortcut instead of the target application (Remote Desktop style). either way, the compiled AutoIt script runs on the remote machine.

next best solution: if it's that simple, try to simulate everything using key press only (no mouse clicks). if you can do that, than you are probably able to have your script do what you want on the user machine - the only requirement is that the user does not interfere with the operation in the few seconds it should take.

search the forum, this subject has been discussed a few times already.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

One thing you can do, which I have found helpful, is to run MSTSC, and then after a few seconds to send a CR into the Remote Desktop. This will dismiss those ultra-annoying Legal Captions that block scripts running from the startup menu. Once the Remote Desktop is cooking, though, the answer orbs provided is the only way.

Link to comment
Share on other sites

Sorry for the late response, I away due to some medical emergency.. Thanks for your replies..

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.

First challenge : We have a license agreement while RDP login which I need to press OK. (For some reason our management is not ready to suppress it).

If above works, then I will be able to open multiple user sessions using RDP.

Then the next challenge is to start the legacy application and select a specific tab in it and click a button. I can use Tab key to go to that tab, and then press Return to "click" the button. (May be create a exe using AutoIt which perform this task and run it remotely from the server)

But I am clueless how to achieve this. I am new to AutoIt. If any one can help me to get a sample code. I can start experimenting with it and try to make it work.


 

Link to comment
Share on other sites

  • Moderators

Subashes, there is a reason you're being asked what the software is; how can anyone assist you if they don't know what the program is or even have a screenshot of what tabs you need to click on? You need to help us help you. You can start with the name of the legacy application, some screenshots to show where you want to click, and a detailed step by step explanation of what you want to accomplish.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

This is a custom program which was developed for our company..

Step by step instructions are..

First I open the MSTSC and the type the server Name and press Connect, Then I get a prompt to enter user name and password and click OK.

Once it's connected I get following legal prompt to press OK.

post-89935-0-62586600-1423495585_thumb.j

Once I login I launch the application using a shortcut in desktop (Application window shown below). Application opens by default to the Setup Tab. I need to click on 'Router' Tab and Then Click on The 'Start Router' button.

post-89935-0-79848600-1423495756_thumb.j

After Clicking The 'Start Router' button, I get a status prompt where I need to press 'Yes'

post-89935-0-43239400-1423495928_thumb.j

Please let me know if you need any further information.

Edited by Subashes
Link to comment
Share on other sites

  • 2 weeks later...

Hi I just read your thread quickly, and I'm not that good in autoit at all, but I try to help you out as much as I can.

I assume that connecting with the MSTSC, user names etc is done, since its "still on your PC" (sorry for the unprofessional language :D )

Once you start the application, you can either use Send ("{X tab}{Enter}") where X is the number of tab strokes you need to get to Router. Same way maybe for the Start router button, If the PopUpWindow has its focus on yes, then a Send Enter could work.

Otherwise orbs and clicked solutions seems the best to me, but I must say I never really worked with remotemachines, mostly made scripts that were used as a stand alone application for specified tasks in the company I work for.

If you wanna go with MouseClicks you can first move the Window with WinMove (I guess, may not work since the remote machine) to the 0,0 coordinates, and from there on you can be sure which Control is where to automate it with clicking.

I'm not sure if you can but if you want you can try to decline users usage of their inputs with BlockInput while the scripts run (shouldn't be a real problems since I assume this doesn't really take more then 1min top)

Hope I helped somewhat

Link to comment
Share on other sites

as for connection - there should be no problem storing your server hostname, your username and password (and certificate, if applicable) into an .rdp file.

as for the legal prompt - it is technically possible to automate, but you are going to click that manually. if you want that removed. contact the sysadmin in-charge and have them disable it (unless mandated by some regulations, of course).

as for the application - are you allowed to run your script on the server? how you proceed depends on an answer to this question.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Compile a script, and port it over, and run it via PAEXEC.

You would have to do all pixel searches and OCR through MSTSC, which would be (not entirely, but effectively) imposible.  Imposible from a consistancy of execution perspective.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

Open the help file...look at all the Win* (window functions) and Control* functions.

Outside of that, you can always go to a pay for scripting site if you want someone to do all the work

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

  • 3 years later...
On 20/02/2015 at 11:11 AM, Subashes said:

I don't have any experience with Autoit. Thanks in advance.

Start by the begining. "hello world".

Dont want to be unpleasant. You have to learn how to start a script. You have to understand how it work. 

-Handles. 

WinMove

-Windows names 

WinGetTitle

-Windows Automation and how. 

ControlClick

;IUIAutomation (UDF)

-Mouse automation. 

MouseMove
MouseClick

 

We're not able to learn you everything in one time. 

 

Try to learn that. Make some try's. Show some code. Come back here. 

 

regards.

Edited by caramen

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Developers
46 minutes ago, caramen said:

Start by the begining. "hello world".

Guess you need to start with reading the date on the post. ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

15 minutes ago, Jos said:

Guess you need to start with reading the date on the post. ;) 

Facepalm :lol:.

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...