Sign in to follow this  
Followers 0
pmneve

AutoItX3 control functions fail in virtual machine when remote desktop window not open

2 posts in this topic

Am running ruby and watir 1.6.5 which uses AutoItX3.dll (v. 3.1.1) on a Windows Server 2003 virtual machine accessed from an XP Pro laptop through Remote Desktop.

If I run the script and leave the desktop window open, the following code runs correctly.

If I minimize the window the code hangs after the WinActivate command (the WinWait for "Save As" also never times out)

Have substituted a newer version of AutoItX3.dll (v 3.3.3) to no avail.

@Wait = 60

data_path = [full path where file is to be saved]

...

ai = WIN32OLE.new("AutoItX3.Control")

ai.WinWait("File Download", "", @Wait)

ai.WinActivate("File Download", "")

ai.ControlFocus("File Download", "", "&Save")

sleep 1

ai.ControlClick("File Download", "", "&Save", "primary")

sleep 1

ai.WinWait("Save As", "", @Wait)

sleep 0.5

ai.ControlSend("Save As", "", "Edit1", data_path)

ai.ControlClick("Save As", "", "&Save", "left")

ai.WinWait("Download complete", "", @Wait)

ai.ControlClick("Download complete", "", "Close")

...

This is an urgent problem as the application running this is a critical path project.

Greatly appreciate any help anyone can give!

Share this post


Link to post
Share on other sites



Yea, I've experienced same problem too. Thought I posted my findings on the forum too but can't find it at the moment.

Seems one must be logged on & active for AutoIt to function. I don't think there's a fix for this. But there are some workarounds:

Run the automation through Remote Desktop's console (or admin) session, which is done via mstsc.exe /console or mstsc.exe /admin, depending on your server & remote desktop client version. You'll know you're using console session if your session ID in task manager shows 0. If you disconnect the remote desktop, the console session still runs because console/admin session = the local desktop session that is attached to the machine's keyboard, monitor, & mouse. In your case, the machine is virtual but it means the same thing. The only thing is on disconnect, the console session is just locked on the local desktop and not connected via remote desktop.

However, if that still fails because the sessions is locked (i.e. Ctrl+Alt+Del lock computer locked), then the other workaround is to use VNC.

Install VNC on the virtual machine, then connect via VNC and run automation. You may then disconnect from VNC. Because VNC gives you remote access to local desktop, Windows doesn't have any type of "session" to associate the VNC session, so you're always logged on, even when disconnecting VNC client. So your automation will always run and this is the best workaround I've found.

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