BzowK

How to Trigger Action When Window Without Title Appears

6 posts in this topic

#1 ·  Posted (edited)

Hey Guys - 

I'm a novice AutoIT user and have a quick question, please.  I have a system which hosts many Python-based web apps as well as a few other things.  When first starting most of these applications, I am prompted for credentials in a separate window.  For the web-based ones, it's Google Chrome's standard username & password prompt window.  These windows do not have a title, but each does have different text as it shows the full URL including port number.  Attached is a screenshot.

post-75634-0-37013900-1422984164_thumb.p

I'd like to be able to auto-fill my credentials and perhaps a couple other things, but cannot figure out how to script this - mostly because I don't know how to reference the window appearing.  

I've did get Lastpass (with binary) to work - but - it made things worse.  Lastpass scans the pages for the words "username" and "password" but a couple of my hosted apps are for configuration purposes and use those fields a lot.  Unfortunatly, Lastpass would try entering my credentials each time they appeared anywhere because I will still on the same address.

Any ideas?  Thanks!

UPDATE

I forgot to mention that I used the window info tool which was useful, but for one of the hosted apps, the title changes all of the time as it reflects download states (below)  How do I reference it?

post-75634-0-76323700-1422984807_thumb.p

I also found a script to make a hotkey which I guess i could use if need be, but would rather automate it all if possible.

Thanks!

Edited by BzowK

Share this post


Link to post
Share on other sites



It's usually a bad idea to store usernames and passwords inside scripts for security purposes. Maybe pulling them from a text file would be of better security.

Have a look at the >IUIAutomation MS framework.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks - I'll look into that after I get the functionality working.  For now, I've got the below and found out I could use the window title with a wildcard for ID.  The thing is, that once it runs, the script stops.  Should be an easy question, but how do I get it to loop?  

#include <Constants.au3>
    WinWait("[TITLE:mywindow*]", "",10)
    Sleep(20)
AutoItSetOption("SendKeyDelay",100)
;this is the user id
send("myusername")
send ("{TAB}")
;this is the password
send("mypassword")
send ("{ENTER}")

Ohh - also - not only do I want for it to loop, but want to add credentials for another site, too.  It would be the same script as the above, but different window title.  Should I use seperate scripts or is there a way to put it in a single one?

Thanks!

Edited by BzowK

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Using code tags like so [ autoit ] ; code here [ /autoit ] (remove the spaces) will help us with easily picking something out as it gives it syntax highlighting and formatting.

$var = "test" ; this is a test
#include <Constants.au3>
 
AutoItSetOption("SendKeyDelay",100)
 
While 1
  If WinActive("[TITLE:mywindow]", "") Then
      Sleep(20)
      send("myusername") ;this is the user id
      send ("{TAB}")
      send("mypassword") ;this is the password
      send ("{ENTER}")
  EndIf
WEnd

Something like this? :)

EDIT: formatting

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

OK, I'm confused.  I think I know what you are talking about, but can't get it to work.  I took my script and did the following for individual sites:

#include <Constants.au3>
[Site1]
WinWait("[TITLE:mywindow1*]", "",10)
Sleep(20)
AutoItSetOption("SendKeyDelay",100)
;this is the user id
send("myusername1")
send ("{TAB}")
;this is the password
send("mypassword1")
send ("{ENTER}")
[/Site1]


[Site2]
WinWait("[TITLE:mywindow2*]", "",10)
Sleep(20)
AutoItSetOption("SendKeyDelay",100)
;this is the user id
send("myusername2")
send ("{TAB}")
;this is the password
send("mypassword2")
send ("{ENTER}")
[/Site2]

You're probably laughing at my knowledge of this right now, but hopefully you can see what I'm trying to do. :)  When I ran the above, i got syntax errors all over the place.

Basically, the script I used in my 2nd post (and multiplied above) works except for 3 things...

- I'm trying to get it to loop instead of existing after filling in creds (I want it to run 100% of the time)

- I'd like to be able to put the same in for about 5-6 different sites I login to the same way instead of having copies of the same script with different window titles running

- With the script I have working, once the authentication window appears, it takes about 5 seconds for the text to autofill.  I've tried playing with variables, but can't get it to fill instantly. 

I tried your script with my variables which worked, but when I ran it; it never filled anything in.

What do you think?  Thanks again!

Edited by BzowK

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

The while loop that I put it in will run always. The only way you'd be able to stop it is by right clicking the icon and exiting the script in the toolbar, or in SciTE tools - stop executing. Unless you put a hotkey in that you would set to run an exit function, like so

HotKeySet("{ESC}", "Quit")
 
Func Quit()
    Exit
EndFunc

Also, by putting this at the top of your script it will stop the delay in sending keys:

AutoItSetOption("SendKeyDelay", 0) ;<<< 0 sets to no delay

Give this a try, make sure you change the params that you have already changed like the window title etc.:

#include <Array.au3>
#include <Constants.au3>
 
Local $ActiveWin, $winNeedUP[7]
$winNeedUP[1] = "mywintitle1"
$winNeedUP[2] = "mywintitle1"
$winNeedUP[3] = "mywintitle1"
$winNeedUP[4] = "mywintitle1"
$winNeedUP[5] = "mywintitle1"
$winNeedUP[6] = "mywintitle1"
$winNeedUP[0] = 6 ; num of titles

While 1
    $ActiveWin = WinActive("[ACTIVE]", "")
    setUP($ActiveWin)
    Sleep(10)
WEnd

Func setUP($activeWindow)
    Local $winTitle = WinGetTitle($activeWindow)
    If _ArraySearch($winNeedUP, $winTitle) <> -1 Then
        Send("myusername1")
        Send ("{TAB}")
        Send("mypassword1")
        send ("{ENTER}")
   EndIf
EndFunc

Does that help? :)

P.S. we all learn sometime. ;)

P.S.S. you might need to tweak some of the titles when you first declare them, as they might not match up exactly.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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