ernstoutz

Autoit functions in virtual machines

6 posts in this topic

Newbie here, i'm working to automate a display that should log in and load a few webpages that cycle through various information. one webpage requires a credential login. ive automated it on my laptop (Win 7). I compile the script and load it into the startup folder of a Win 7 virtual machine. It opens the wepage and run fine except for the part where it should detect the credential prompt window and enter the info. as below:

$ABSTitle = "Windows Security"
$username_field = "[CLASS:Edit; INSTANCE:1]" ;that's how it's named in the standard Internet Explorer credentials window
$password_field = "[CLASS:Edit; INSTANCE:2]" ;that's how it's named in the standard Internet Explorer credentials window

If WinWaitActive($ABSTitle, "", 10) then ;if the creds are required
      ControlSend($ABSTitle, "", $username_field, $username_cred)
      Send("{TAB}")
      ControlSend($ABSTitle, "", $password_field, $password_cred))
      ControlSend($ABSTitle, "", $password_field, "{ENTER}") ; presse enter
   EndIf

i can manually enter the credentials and the script continues just fine. I have also verified its not a weird reference of something like $username_field, it remains the same. If I am in the incorrect topic please point me in the right direction.

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Could you please check which of this statements does not work? WinWaitActive, ControlSend etc.? Add some debugging lines to check the return values.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-02-03 - Version 1.4.7.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sorry water, I realize now in my frustration i didn't state which one wasn't working. i cleaned up my code before posting but i did determine that it is the "winwaitactive" that wasn't working. but i have other similar lines that will work:

if WinWaitActive($javaAuthPopup, "", 10) Then;bypass the java credential prompt
      Send("+{TAB}")
      Send("{ENTER}")
   EndIf

Even after i manually correct the credentials prompt the rest of the could, which contains yet another WinWaitActive will function fine. As i said before all the names of the windows i'm referencing are correct. I;m sure its something simple i over looked

Share this post


Link to post
Share on other sites

A couple of things to try. You could increase your WinWaitActive from 10 to 60 to see if you simply need to give it more time. Also, try running the small script below when the Java window is up. Do you see a window that matches up with your given title?

#include <Array.au3>

Local $aWins = WinList()
    _ArrayDisplay($aWins)

If you do, then change the WinList call to something like this and see if you still get a hit:

Local $aWins = WinList("<my title>", "some text from my window")

 


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

A couple of things to try. You could increase your WinWaitActive from 10 to 60 to see if you simply need to give it more time. Also, try running the small script below when the Java window is up. Do you see a window that matches up with your given title?

#include <Array.au3>

Local $aWins = WinList()
    _ArrayDisplay($aWins)

I found "Windows Security|0x00030342" when i run it on the virtual machine (Windows Security|0x00050B0C, when run on mine), which matches what i am trying to detect for

 

If you do, then change the WinList call to something like this and see if you still get a hit:

Local $aWins = WinList("<my title>", "some text from my window")

 

The second results in "Windows Security|0x00030342" (and on my machine Windows Security|0x000B0A9A)

secondWinList.thumb.PNG.be6b15bc4bfde716

I also increased the detection time but i saw the credential prompt appear in much less than the timeout.

 

 

Edited by ernstoutz
too many duplicate pictures

Share this post


Link to post
Share on other sites

Interesting note, I had mistyped the password a few times whilst in the VM, after a couple incorrect passwords one of my debugging messages had appeared, it had actually found the credentials prompt and proceeded to log in fine. Even hitting the cancel on the credentials prompt will work if I refresh the page and a new credential window appears. 

After another go around i was able to catch the window info using autoit's window info and i only see a difference with the handle which would be almost impossible to reference as they are generated different for each new window that appears.

I attempted to find the window by using just the CLASS attribute and had a similar success of entering the incorrect creds until a new window had appeared, which then logged in as expected.

 In the image the VM window info is on the left, my machine on the right.

Capture.PNG

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