Sign in to follow this  
Followers 0
SorryButImaNewbie

Handling PopUp windows while logging in IE

18 posts in this topic

So I have to write something that would search for a specific string (the text of the popup window) and if it finds it then It click on a specific button (on the popup window)

I thought about something like _INetGetSource then check it with a StringInStr, and if the return is not 0 or 1 then it should re-collect all the objects (_IEFrameGetObjByName? maybe?) so it would "see" the new button, then _IEAction should take care of the rest.

I'm new to IE automatization so I'm just looking for some approvments or ideas like yeah this should work / you should use this function you moron, its simplier :) 

Thank you !

Share this post


Link to post
Share on other sites



Hello there :)

I was once also new to IE automatization, mind you I still am. Just not all green just a bit shady ^^

What are we speaking of here really? Are we doing a, by pure definition, a popup window? Like the link you find here: http://www.mckenziemdt.org/plugtest/popup.htm (it's a fast google search, don't judge!), or is it more like those windows you find when for example you want to log into most routers. That's not really in a pure new IE window? If the former, then I'd suggest maybe use _IEAttach() to get hold of said new window. If it's the latter, then I do not know if I can help you too too much xD Especially without no sort of abstract example to poke, rub and touch.

Share this post


Link to post
Share on other sites

You have windows popups and you have popping up html windows and you have html5 overlays so screenshot helps to understand what you talk about. Iuiautomation in examples section can handle a lot.of scenarios and sometimes.ie.au3 can help out. When its a windows popup native autoit controlclick will be sufficient

1 person likes this

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi and thank you for the help!

Sorry didn't knew what to tell you to make it easier for you guys, I think the popup is initiated by a javascript, and it "floats" fixed to the middel of the screen, pic:

"You are not allowed to use that image extension in this community" --> PNG, okey so the web page is https://ematrica.autopalya.hu/ and the popup is the same if you click on the "Belépés" (Entry, Enter?) button, there it popup a window asking for your account name and code + a button to enter. I think it works on the same principle (edit)

but its mre likely that its a "morphing window according to different scenarios (at first it show Processing Data... then if it sees that you have "similar" tickets it tells you that and ask's how to proceed (as in the pic with the funny language :) )

</div>
        <div id="ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_UpdateProgress1" style="display:none;">
                            
                <div class="popUpLayer">
                    &nbsp;</div>
                <div class="popUpBox">
                    <h3 class="inProgress">
                        <span id="ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_progressText">Feldolgozás folyamatban...</span>
                    </h3>
                </div>

I tried to check it with IE developer tool, but it wasnt my lucky day 3 times it wasnt able to interract with it (it only saw the forms of the webpage, dunno why but common error, and restart of IE and/or developer tool didnT help) I searched the code from the source manually, and hope that this is the pice that would tell you something more then it tells to me.

Just for fun I bet for that its a HTML code I'm not familiar with! Tell me right/wrong :)

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

You're right... ??

You still have not shown us how you've tried to interact with that section of data.

That would be the starter.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I'm right now trying to handle it with ControlClick but doesn't seems to react (dont know if the title is good or not, it could be the problem, but can only find its class)

While
        If ControlCommand("Figyelmeztetés", "", "ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez", "IsEnabled", "") Then
            ControlClick("Figyelmeztetés", "", "ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez")
        Sleep(10)
        EndIf
WEnd

I read this (check if control exists) from Melba (>link) it worth a try, but didn't have high hopes without the proper name of the form, also dont really understand why we need the while/WEnd in it.

#cs
name:ctl00$wpm$UserControlPortlet1302082381$ctl00_wpm_UserControlPortlet1302082381_userControlPortlet$btnEllenorzeshez
id:ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez
onclick:javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$wpm$UserControlPortlet1302082381$ctl00_wpm_UserControlPortlet1302082381_userControlPortlet$btnEllenorzeshez", "", true, "", "", false, false))
String: Ön korábban már vásárolt, vagy a kosarában jelenleg található olyan e-matrica, melyek érvényességi időtartama átfedésben van. Az Adatok módosítása gombra kattintva Önnek lehetősége van módosítani az utoljára vásárolni kívánt termék adatait (rendszám; érvényességi idő kezdete, stb.), vagy a Tovább gombra kattintva - jóváhagyva az átfedést - továbbléphet.
#ce
ConsoleWrite(_INetGetSource('https://ematrica.autopalya.hu/vasarlas?kategoria=d1&ervenyesseg=2'))
Local $Keres = 'WebForm_DoPostBackWithOptions'
While True
Local $Talal
Local $Keres = ConsoleRead()
If $Talal = StringInStr($Keres, 'WebForm_DoPostBackWithOptions') = True Then
Local $Tovabb = _IEGetObjById($Explorer, 'ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez')
Sleep(500)
_IEAction($Tovabb, "click")
EndIf
WEnd

 

This is my monster of a code trying to write source code to the console and check if specific string is there, and if it is then click on the button, If i recall this worked a few times somehow, maybe with the other string I commendted out.

Sorry for the mess, but this have been droped on me with a tight deadline, and its also my first time automatizing IE so I made it in a bit of hurry, and tried to solve more things at once (which was stupid from me)

Hope these code snippets helps 

(Edit: somehow I put the code out of the 2. code box, fixed)

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

okey I checked it again, my code acts (with the string = Ön korábban már vásárolt, vagy a kosarában jelenleg található olyan e-matrica, melyek érvényességi időtartama átfedésben van.)

Is closeing the popup but stuck on the Sleep(500) (from the debugtrayicon) and giving the following "erroe" message in the console:

--> IE.au3 T3.0-1 Error from function _IEAction(click), $_IESTATUS_InvalidDataType
--> IE.au3 T3.0-1 Warning from function _IEGetObjById, $_IESTATUS_NoMatch (ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez)
 
doesnt this mean that it couldnt give the data to $Tovabb?
Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

Wow, that's a hot mess.

Control* functions are not going to work as you think they would (or how you have them coded) in IE.

The ID for IE objects is not the same for Control* functions.

I asked you this once before, if you knew what the ID was for, and instead of responding, you started a different thread.

No matter how much you're in a hurry, if you don't understand what you're doing, it's going to take longer than taking the time to understand.

First thing is you need to start debugging your code.

Your snippet you provide doesn't allow us to run anything, but your error code shows that your $Tovabb = code, the id (ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_btnEllenorzeshez) doesn't exist or it isn't found.

Local $oObj = _IEGetObjByID($Explorer, "ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_progressText")
If Not IsObj($oObj) Then ; Validate your code is working, you can't get past this point if $oObj isn't an actual object
   ; set some error code here and debug
EndIf

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

It didnt showed the MsgBox I put in to your code

(thank you for your help, and you are right, I dont really understand what m'I doing properly, more like I try to jump step by step. Do you happend to have somethinkg I should read about this? I haven't used autoit neither did i learn it before, but a programmer quited his job and now i try to learn on the fly)

Sleep(2000)
    Local $oObj = _IEGetObjById($Explorer, "ctl00_wpm_UserControlPortlet1302082381_ctl00_wpm_UserControlPortlet1302082381_userControlPortlet_progressText")
    If Not IsObj($oObj) Then ; Validate your code is working, you can't get past this point if $oObj isn't an actual object
        ; set some error code here and debug
        MsgBox(0, 'Error', 'error')
    EndIf

I put the sleep before it aftern the first try didn't show error, so maybe it needs time to load (tried it with _IELoadWait as well same result) so this means it is an Object right? I mean the MsgBox should pop if $oObj isn't an object.

I'm very thankfull for your help, I have an idea about how bad my autoit skills, and solutions are, not talking about the small amount of IT knowladge I happen to have from my BSc, so thanks

Edited by SorryButImaNewbie

Share this post


Link to post
Share on other sites

Yes, you should get the message box if it is not an object.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Sorry SmOke_N, but I couldn't hold myself to test ^^

#include <IE.au3>
#include <Array.au3>
#include <Excel.au3>
#include <File.au3>
#include <Misc.au3>
#include <MsgBoxConstants.au3>
#include <GuiListBox.au3>
#include <String.au3>

Local $oIE = _IECreate("https://ematrica.autopalya.hu/")

Local $username = _IEGetObjById($oIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_UserName")
If @error Then
   ConsoleWrite("We got a error trying to attach to UserName!" & @LF)
   Exit
EndIf

Local $password = _IEGetObjById($oIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_Password")
If @error Then
   ConsoleWrite("We got a error trying to attach to PassWord!" & @LF)
   Exit
EndIf

Local $submit = _IEGetObjById($oIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_Login")

_IEPropertySet($username, "innertext", "TheUnpatientCricket")
_IEPropertySet($password, "innertext", "TheCricket")
_IEAction($submit, "click")

Yes I know I am including unnecessary items, it's my test bed. This "should" automatically log into the site :) Not sure if that's off topic because you wanted something else, but I noticed a challenge and took it. Besides, if you are as green as I take it you are, this is a rather neat example of how to :) Do ask if you have anything unanswered by it. Also, yes, it's console. So I recommend debug this in SciTE or replace consoles with message boxes ^^

1 person likes this

Share this post


Link to post
Share on other sites

That worked for you?

I see a few things that could later become issues, I'll try to point out a couple.

1.  The forms control "values" are read/passed at submission, you won't usually find something screen scrapping innertext/html

2.  I'm pretty sure that _IEAction(obj, "click") is failing for a lot of folks the higher their IE versions are going, on forms, try to get the form object, and use _IEFormSubmit()

Other than that, I have no issues with others helping people, I was pointing out that the OP was not understanding things that people were telling them.

That the OP was in such a hurry to get things done, they were confusing autoits standard window functions with its object control functions.

The sooner that the OP took several hours out of their day to read and understand the _IE* functions and what they did, the better the OP's life was going to be.

We tend to lean toward the "teach to fish" method, often you will see me throw code out there, when I do that, I'm fishing... I'm fishing to see if that person is going to be worth spending my personal time on in the future ;) .


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Heh, you are a kinda clever person. Wonder how well you'd handle chess :) This course of action has it's origins in a bulk program I've build, it has ran I would say at least 30.000 cycles, and this is probably the most solid bit of code in it. Thus I am using it :D And I got the latest IE btw case you wonder ^^ It's a quite high learning curve this, so I cannot really blame him. Not justifying him either saying it though because once over it, things really get interesting. And the AutoIt community is really helpful to those that shall we say "deserve" help (bit harsh perhaps but not literally now, think we booth understand exactly what I meant). So I am really pleased. And the only reason for me being here, other than seeking challenges, is to give back what people like you have done for me :) And will most probably still be doing in the future. This code I wrote, it took me maybe 20 min, when it would in the past take days of trying to understand the sodding code xD

If you don't mind, Smoke, would you show how you would have done it? I am not going to curse you if you don't want, it's just my way of learning. I understand you like _IEFormSubmit more than you like my _IEAction? I would use _IEFormSubmit, but I don't really see any form to hook onto. Thus I am using the as you tell me not most optimal route. Also, I am a little bit unclear about what you mean instead of controlling the input boxes like I do. Because you seem to know a better way around that as well?

Share this post


Link to post
Share on other sites

I use _IEAction too and it works well, but its not a preference, more like a "ohh this works, so stick to it for now" thing.

I may misunderstand what you guys talks about my function for entering is like this:

MsgBox(0, "Login", "Ematrica_Login") ;for debugging
    Local $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        Local $sMyString = "Belépés"
        Local $sLinkText = _IEPropertyGet($oLink, "innerText")
        If StringInStr($sLinkText, $sMyString) Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next
    ;Beírja a acc/pass-t (focus alapból rajta van a textboxon)
    Send($acc)
    Send('{TAB}')
    Send($pass)
    Local $Belepes = _IEGetObjById($oIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_Login")
    _IEAction($Belepes, "click")
    _IELoadWait($oIE)

what do you think? (I think it was pretty neat for my lvl so dont be to rough :) )

Thank you for your help. BTW In my project I just try to get the popups windows name and clickon them (_IEGetObjName _IEAction) and if there is no such thing then it just goes on. I think thats a pretty simple solution to this.

Also thanks a lot for the help!

PS.: (Master Smoke, did I fail? can I take a new one a month from now? :) )

Share this post


Link to post
Share on other sites

Believe you can even do this:

MsgBox(0, "Login", "Ematrica_Login") ;for debugging
    Local $oLinks = _IELinkGetCollection($oIE)
    For $oLink In $oLinks
        Local $sMyString = "Belépés"
        Local $sLinkText = $oLink.innerText ;save up some characters, make it a bit neater
        If StringInStr($sLinkText, $sMyString) Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next
    ;Beírja a acc/pass-t (focus alapból rajta van a textboxon)
    Send($acc)
    Send('{TAB}')
    Send($pass)
    Local $Belepes = _IEGetObjById($oIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_Login")
    _IEAction($Belepes, "click")
    _IELoadWait($oIE)

But I am not going to test this one sorry :) Also, I shudder at using Send() unless absolutely necessary, but that can be a personal taste. I feel there's too little control on them. Otherwise, I can't really say it's not too half decent. Well done :) Bet "master Smoke" got a bigger wip than I do though.

Share this post


Link to post
Share on other sites

Yeah but as you thought, I'm pretty green in AutoIt (only learned c# before and t was a few years back, and not in very high level) so Send was the tool for me thanks to its simplicity. Also I was always a bit affraid to use whatever new thing i learn (i know thats counter productive, I will try to abaddon this habbit, thats why I used innertext just once). On the plus side I start to feel like a spark is gettin in to a fire in my mind, as soon I fonosh my internship and my other job I will have time to learn and read like a madman. +change my OS to ubunto, as I heard its a good way to get a deeper understanding of a computer (refreashing what i learn) and so on.

On Master Smoke's wip I dont concern myself to much with it, it's for higher lvl guys, but in a few months (20+ :) ) I will get to a level to try it on myself again ^^

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

If you don't mind, Smoke, would you show how you would have done it? I am not going to curse you if you don't want, it's just my way of learning. I understand you like _IEFormSubmit more than you like my _IEAction? I would use _IEFormSubmit, but I don't really see any form to hook onto. Thus I am using the as you tell me not most optimal route. Also, I am a little bit unclear about what you mean instead of controlling the input boxes like I do. Because you seem to know a better way around that as well?

Sorry, I just saw this, I was watching a movie.

That site is weird for sure... I am not a fan of the aspnet ones.

My code would probably not be much different than yours other than the form.  I did look for a way to cheat (often you can find the post to function (the action function) that you can just submit to)... But I still have 20 minutes on my movie so I won't dig more.

This is probably how I would have handled it myself:

#include <IE.au3>

Global $goIE = _IECreate("https://ematrica.autopalya.hu")
If Not IsObj($goIE) Then
    MsgBox(16 + 262144, "Error", "Could not create browser object!")
    Exit 101
EndIf

; form object, if you're not using my IEJS.au3
;  there are two ways to easily get it
; _IEFormGetCollection or call the form directly by its array name
; I will show both

Global $goForm = _IEFormGetCollection($goIE, 0)
Global $goFormWay2 = $goIE.document.forms("aspnetForm"); easily found back tracking through the javascript in debugbar
If Not IsObj($goForm) Or Not IsObj($goFormWay2) Then
    MsgBox(16 + 262144, "Error", "Could not find form object!")
    Exit 102
EndIf

; now we can find our inputs-user/pass
Global $goUser = _IEGetObjById($goIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_UserName"); hate aspnet for these id lengths! lol
If Not IsObj($goUser) Then
    MsgBox(16 + 262144, "Error", "Could not find username object!")
    Exit 103
EndIf

Global $goPass = _IEGetObjById($goIE, "ctl00_wpm_AdvancedLoginPortlet976985280_ctl00_LoginViewControl_LoginControl_Password")
If Not IsObj($goPass) Then
    MsgBox(16 + 262144, "Error", "Could not find password object!")
    Exit 104
EndIf

$goUser.value = "username"
$goPass.value = "password"

_IEFormSubmit($goForm); or $goFormWay2
Sleep(1000); wait for delay
_IELoadWait($goIE) ; wait for next page

.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Heh, sorry for intruding your move watchings. And thanks for showing DebugBar. That is quite a helpful little toy! :D

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