Jump to content

Autoit functions in virtual machines


Recommended Posts

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.

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
Share on other sites

  • Moderators

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")

 

"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

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
Link to comment
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

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...