Sign in to follow this  
Followers 0
vm2007

AutoIT not working on remote machine

10 posts in this topic

Hi All,

This is my first post. I am using Autoit for automation of our website. The script I have works fine if i run it on my machine and i have the same setup on a different machine which i access using Remote Desktop Connection. The script works fine on RDC only till the time i keep the RDC session maximized. If i minimize the window, the script runs but it does not do anything. Please help me.

1st Script that i was using. This works on my machine.

WinWaitActive("[CLASS:ViewsTextfieldEdit]","","15")
 Send("vm2007{TAB}")
 Send("abcdef{Enter}")
 
after reading the posts on forum i changed it to:
 
WinWait("[CLASS:ViewsTextfieldEdit]","","20")
ControlSend("", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:2]", "vm2007{TAB}")
ControlSend("", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:1]", "abcdef{Enter}")
 
The second one works even if i focus on something else on my primary machine but i need to keep the RDC session maximized. If i minimize it then it fails.
 
I read something about ControlID but do not know how to use it in my 2nd script. Can that solve the problem?
 

 

Share this post


Link to post
Share on other sites



Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yes i access the machine (Win XP) using mstsc only.....the 2nd script works as long as the RDP window is maximized...i can even work on other applications on my main machine (I use 2 monitors and i can work on applications on 2nd monitor). So focus i guess is not the problem but if i minimize the RDP window then autoit fails to execute the steps i have mentioned.

Is the script i mentioned correct? or do i need to enter some other parameters to it?

Edited by vm2007

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

please clarify: when you run the script on the remote machine over RDC, you mean:

1) the script is running on your machine and interacts with the RDC window

       or

2) the script is running on the remote machine

which scenario is it?

Edited by orbs

Share this post


Link to post
Share on other sites

The script is running on the remote machine.....I only use 'mstsc' for starting the execution which again i do on remote machine only and then I simply monitor it.

There is nothing related to the setup on my main machine.

Share this post


Link to post
Share on other sites

ok, so you're one step in the right direction.

how about this: when the script reaches a point in which the dialog window is expected to be active, but may be not active if you minimize the RDC window, put some reasonable Sleep() and then try to force it by WinActivate().

another option: add the title/text of the dialog window to the ControlSend()

Share this post


Link to post
Share on other sites

ok, so you're one step in the right direction.

how about this: when the script reaches a point in which the dialog window is expected to be active, but may be not active if you minimize the RDC window, put some reasonable Sleep() and then try to force it by WinActivate().

another option: add the title/text of the dialog window to the ControlSend()

 

Sounds good to me...will come back after trying it out to let you know whether it worked or not. Thanks.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Without being able to test the specifics it seems like using direct control manip. vs. send keys is the way to go.  Not sure why is doesn't work.  Perhaps adding some debug checks to see where in the process fails will lead you to a solution.  Are you running the script compiled or in SCITE (just a matter of outputing to a file instead of ConsoleWrite)?   A mystery this is...

Edited by spudw2k

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I tried the suggestions but it did not work. I have modified the script to this now:

WinWait("[CLASS:ViewsTextfieldEdit]","","20")
WinActivate("[CLASS:Chrome_WidgetWin_1]", "")
ControlSend("[CLASS:ViewsTextfieldEdit]", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:2]", "vm2007{TAB}")
ControlSend("[CLASS:ViewsTextfieldEdit]", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:1]", "abcdef{Enter}")
 
But this does not work at all. The previous version at least used to work when RDP was in focus and maximized.
 
The details of the window using Tool are like this
*******************************************
>>>> Window <<<<
Title: TestPage3456 - Google Chrome
Class: Chrome_WidgetWin_1
Position: -4, -4
Size: 1928, 1054
Style: 0x17CF0000
ExStyle: 0x00000100
Handle: 0x00290788
 
>>>> Control <<<<
Class: ViewsTextfieldEdit
Instance: 2
ClassnameNN: ViewsTextfieldEdit2
Name:
Advanced (Class): [CLASS:ViewsTextfieldEdit; INSTANCE:2]
ID: 108113024
Text:
Position: 894, 537
Size: 196, 19
ControlClick Coords: 53, 3
Style: 0x56000080
ExStyle: 0x00000000
Handle: 0x001706B0
 
>>>> Mouse <<<<
Position: 947, 540
Cursor ID: 5
Color: 0xFFFFFF
 
*************************
 
Any more suggestions as to what change do i need to make in the script so that it works in all scenarios??
Edited by vm2007

Share this post


Link to post
Share on other sites

Finally i was able to make it work...I guess I did less research before jumping into this. The working script is as follows. It works even when RDP window is minimized.

sleep(10000)
WinWait("[CLASS:Chrome_WidgetWin_1]","","20")
ControlSend("[CLASS:Chrome_WidgetWin_1; Title:TestPage3456 - Google Chrome", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:2]", "vm2007{TAB}")
ControlSend("[CLASS:Chrome_WidgetWin_1; Title:TestPage3456 - Google Chrome]", "", "[CLASS:ViewsTextfieldEdit; INSTANCE:1]", "abcdef{Enter}")
 
Thanks everyone for your inputs...:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0