ShaneF Posted January 22, 2011 Posted January 22, 2011 Hey guys, After hours of research on here and the help file I am unable to get the above to work. I have an image I have to click on the webform which then instantly initiates a JS popup with either an error or confirmation message in it. The title is "Message from webpage" (sounds customised) but AutoIT can not find it. Here is the code I'm having trouble with... $oForms = _IEFormGetObjByName($oIE,"containerForm") $oSite = _IEFormElementGetObjByName($oForms, "xml:/Shipment/@ReceivingNode") $oCtnr = _IEFormElementGetObjByName($oForms, "xml:/Shipment/Extn/@UnitNo") $oBill = _IEFormElementGetObjByName($oForms, "xml:/Shipment/Extn/@BillOfLading") _IEFormElementSetValue($oSite,$site) _IEFormElementSetValue($oCtnr,$ctnr) _IEFormElementSetValue($oBill,$bill) _IEImgClick($oForms,"action.gif") if WinExists("Message from webpage") then WinActivate("Message from webpage", "") ControlClick("Message from webpage", "", "[CLASS:Button; TEXT:OK; Instance:1;]") EndIf Looking at the XML/AJAX source for the site reveals there is no control name for the image that is clicked, so I couldn't effectively implement the Example 2 in _IEAction that everyone seems to get pointed to. I've tried everything from newbie-style sleeping and sending Enter to the _IEAction thing ending up with the above - any more ideas?
ShaneF Posted January 22, 2011 Author Posted January 22, 2011 Just to clarify - it is javascript 'alerts' I'm having issues with... I have tried every single way I can find and have even tried being creative without luck. It has to be possible - it works in a competing product, but my HQ want me to stick to AutoIT as we have some internal support for it. This, however, stumped them...
pedmacedo Posted January 22, 2011 Posted January 22, 2011 You can use _IENavigate($ie,"Javascript CODE HERE"), or _IELinkClickByText($ie,"LINK LABLE HERE"). If this doesn't work and the button is always at the same place, you could use a MouseClick("primary",button_x,button_y)
ShaneF Posted January 22, 2011 Author Posted January 22, 2011 You can use _IENavigate($ie,"Javascript CODE HERE"), or _IELinkClickByText($ie,"LINK LABLE HERE").If this doesn't work and the button is always at the same place, you could use a MouseClick("primary",button_x,button_y) Nice idea, but the script pauses when the action image is clicked (the click triggers the popup).The problem is that there is no button control to handle so I've been unable to use ControlSend functions and I can't get an IE control ID to handle it.The problem with MouseClick is that there are several possible responses, so the OK button will appear in different places...
ShaneF Posted January 22, 2011 Author Posted January 22, 2011 Nice idea, but the script pauses when the action image is clicked (the click triggers the popup). The problem is that there is no button control to handle so I've been unable to use ControlSend functions and I can't get an IE control ID to handle it. The problem with MouseClick is that there are several possible responses, so the OK button will appear in different places... As it stops the entire script from running I thought the best way to handle it would be to write and compile another script that constantly runs during this script to check for these dialogs and respond OK to all of them. Here is the code for the small app: $ctr = 0 while $ctr=0 $var = WinList() For $i = 1 to $var[0][0] If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then if $var[$i][0] = "Message from webpage" Then WinActivate("Message from webpage") ControlClick("Message from webpage","","Button1") EndIf EndIf Next sleep(250) WEnd Func IsVisible($handle) If BitAnd( WinGetState($handle), 2 ) Then Return 1 Else Return 0 EndIf EndFunc
DaleHohm Posted January 22, 2011 Posted January 22, 2011 You don't need an element name or ID to get a reference to it. You can get it by Index instead. See any of the _IE*GetCollection functions. Then go back and use the 2nd _IEAction example. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now