Sign in to follow this  
Followers 0
bobsyuruncle

IE Simulating onevent actions?

4 posts in this topic

Hi,

I'm working on an app that data gathers troubleshooting diagnostic information on a private portal. On the page I'm working on now there's one form with a search and a large table of results. Each item has an "information" link that downloads additional information.

Each one of those "information" links has .innerHTML source that looks like

<TD><A onclick="window.open('showHubHealthInfoPopup.xhtml?hubHealthInfoId=55555', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;" href="#">Information</A></TD>

My question is... Is there a way to directly simulate the onclick action by passing the innerHTML in some way?
Say for example if there were a function or way to pass the event action directly into the session without the click: _ieAction("window.open('showHubHealthInfoPopup.xhtml?hubHealthInfoId=55555', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;")

I can use other methods to search for the "information" links I need and doing a click action with the ie.au3 functions, but if there was a way to directly send the event action I could just alter the hubHealthInfoId= and submit the event directly.

Thanks in advance and sorry if that was poorly phrased.

Share this post


Link to post
Share on other sites



_myClickInnerHtml($oIE, "A", "window.open('showHubHealthInfoPopup.xhtml?hubHealthInfoId=55555', 'popupWindowName', 'dependent=yes, menubar=no, toolbar=no'); return false;")

Func _myClickInnerHtml(ByRef $oObj, $sTagName, $sInnerHtml)
    
    If Not IsObj($oObj) Then
        Return SetError(1, 0, 0)
    EndIf
    
    Local $oCollection = _IETagNameGetCollection($oObj, $sTagName)
    If Not IsObj($oCollection) Then
        Return SetError(2, 0, 0)
    EndIf
    
    Local $vRet
    For $oItem In $oCollection
        If String($oItem.innerHtml) = $sInnerHtml) Then
            $vRet = _IEAction($oItem, "click")
            Return SetError(@error, @extended, $vRet)
        EndIf
    Next
    
    Return SetError(3, 0, 0)
EndFunc


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

hi,
Thank you, wow... that is easily 10x better than the jumpled version of that code I was just in the process of debugging. This will save me tons of time, so thank you!

I did have a couple followup questions... I love the function, but just wondering how do I grab the spawned window and attach to $oIE? Do I need to search for it, or is there something dynamic from script to grab the id?

Second question, while the answer provided works perfectly for my coding project I was still wondering if there is a way to 'push' an event script onto the page or maybe I'm thinking in the wrong direction here and what I'm looking for is an HTTP post?  Would that be a way I could send an onevent string to IE perhaps? something like: "onclick="window.open('showHubHealthInfoPopup.xhtml?..." except as an event it would be without the onclick.

If your not sure that's fine, the answer provided resolves my issue, I'm just trying to understand how dynamically I can make autoit scripts interact with this portal.  I searched the forums, but I didn't find much on this.

Thanks again for the example!

Share this post


Link to post
Share on other sites

Spawned window?  If you're using the _IEAction() function (incorrectly obviously), I assumed you were using _IE functions.  You get the $oIE from _IECreate().

Now you're suggesting you're using http post funcs?

 

Do yourself, me, and the rest of the forum a favor, I detest guessing, provide a working example (to test, I don't care if the url is to your project or not, but it needs to have an example of what you want to accomplish).

You can inject event listeners/events/whatever into any code.

'?do=embed' frameborder='0' data-embedContent>>

Is an example of how I use javascript to get around issues I have with the standard IE.au3 functions.

ObjEvent() for event functions.

Pretty much anything can be done, you just have to take the time to learn how from the help file and searching the forum.


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

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