Welberg Posted December 16, 2010 Share Posted December 16, 2010 On a webpage clicking a specific action results in a confirm window with an OK and CANCEL button. I would like to click OK on that confirm window but can't get that done. To determine this point I started using AdlibRegister. But the 11 ms looping stops when the confirm window gets around. The specific action that is triggered is called "GoForIt": <A href="javascript:fnGoForIt()"><B>GoForIt</B></A> The GoForIt function: function fnGoForIt(){ var opt; opt=window.confirm('Do you want to continue?'); if (opt == true) { window.document.frmReq.txtSubmit.value="POST"; window.document.frmReq.submit(); } } Within my script I use AdlibRegister: $strTemp = "1000" AdlibRegister("MyAdlib", 11) Sleep( 110 ) _IELinkClickByText ($oIE, "GoForIt") $strTemp = "5000" Send("{ENTER}") $strTemp = "6000" Sleep( 110 ) ConsoleWrite("ENDING|" & @LF) _IEQuit ($oIE) ConsoleWrite("ENDED|" & @LF) Exit The MyAdlib function is like: Func myadlib() ConsoleWrite("BGN|") if (WinActive("[ACTIVE]", "")) Then $strTemp = $strTemp + 1 $handle = WinGetHandle("[ACTIVE]", "") $strTitle = WinGetTitle("[active]") ConsoleWrite("Title=" & $handle & "|" & $strTitle & "|" & $strTemp & @LF) EndIf ConsoleWrite("END" & @LF) EndFunc The console log looks like upto the moment the conform window gets opened: BGN|Title=0x000513C0|Title - Windows Internet Explorer|1001 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1002 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1003 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1004 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1005 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1006 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1007 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1008 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|1009 END After clicking "CANCEL" the log continues like: BGN|Title=0x000513C0|Title - Windows Internet Explorer|5001 END BGN|Title=0x000513C0|Title - Windows Internet Explorer|6001 END .............upto BGN|Title=0x000513C0|Title - Windows Internet Explorer|6086 END ENDING| ENDED| Link to comment Share on other sites More sharing options...
wakillon Posted December 16, 2010 Share Posted December 16, 2010 Welcolme to the forum ! Please use AutoIt Tags for your scriptI presume you work with Active window because you can't get javascript window title ? AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Welberg Posted December 16, 2010 Author Share Posted December 16, 2010 This is the script (I left out that which does not affect the problem): #include <IE.au3> _IENavigate ($oIE, "http://...", 0) _IELoadWait($oIE) #Activate Delete link $strTemp = "1000" AdlibRegister("MyAdlib", 11) Sleep( 110 ) _IELinkClickByText ($oIE, "Delete") $strTemp = "5000" Send("{ENTER}") $strTemp = "6000" Sleep( 110 ) ConsoleWrite("ENDING|" & @LF) _IEQuit ($oIE) ConsoleWrite("ENDED|" & @LF) Exit Func MyAdlib() ConsoleWrite("BGN|") if (WinActive("[ACTIVE]", "")) Then $strTemp = $strTemp + 1 $handle = WinGetHandle("[ACTIVE]", "") $strTitle = WinGetTitle("[active]") ConsoleWrite("Title=" & $handle & "|" & $strTitle & "|" & $strTemp & @LF) EndIf If ControlFocus("Message from webpage","OK",1) Then ControlClick("Message from webpage", "OK", 1) EndIf ConsoleWrite("END" & @LF) EndFunc Link to comment Share on other sites More sharing options...
wakillon Posted December 16, 2010 Share Posted December 16, 2010 (edited) Can you get the javascript window title by AutoItWindowInfo ? and try by replace WinActive("[ACTIVE]", "") by WinActive( $_JavascriptWindowTitle, "")because i don't think that WinActive("[ACTIVE]", "") is a good way Edited December 16, 2010 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Welberg Posted December 16, 2010 Author Share Posted December 16, 2010 Makes no difference as the myadlib loop freezes the moment the javascript pop-up gets shown/active. I started using the myadlib loop to see what is happening and so faced the freezing. As this is an external site I am trying to replicate with a local setup. Link to comment Share on other sites More sharing options...
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