MaritimeGirl Posted January 4, 2012 Share Posted January 4, 2012 I have gone through so many pages of suggestions but none seem to work for me.I have a page which triggers an alert but has no name for the alert. It's just the default "Windows Internet Explorer" window title and my statement of "Cannot exceed 500 characters." and an OK button. No, I cannot change the application code to give it a title.Of course my script grinds to a screeching halt when it gets to that alert since I can't get access to it to click the OK button. ControlClick needs a window title so I don't think I can get that to work or maybe I haven't tried the right configuration. MouseClick does not run until after I manually press the OK button and my script will then resume. I'd rather not hardcode coordinates for the mouseclick if I can programmatically access that pesky little OK button to click it.Does anyone have a way to fix this? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 4, 2012 Moderators Share Posted January 4, 2012 Hi, MaritimeGirl. Is there any text in the field you can grab, if not the title? I've used something similar to this in the past: If WinExists("", "Test") Then WinClose("", "Test") EndIf "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 4, 2012 Author Share Posted January 4, 2012 Yes, I have the text of the alert. It looks good but the problem remains that how do I get it to be running so that the alert can be dismissed? As soon as the alert happens (which I trigger (by populating an IE textarea with too much text on purpose as a test), the script stops completely so that code would not be executed. I saw an example using AdlibEnable that looked promising but that function was discontinued in a previous version of AutoIt. I know I would need to have a timed loop of your 3 lines of code already running before the alert happens. How? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 4, 2012 Moderators Share Posted January 4, 2012 MaritimeGirl,AdlibEnable/Disable were not discontunued, they were superceded by AdlibRegister/Unregister which allow several Adlib functions to be set at the same time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 4, 2012 Moderators Share Posted January 4, 2012 (edited) Something like this might get you started. AdlibRegister("Popup") Func Popup() If WinActive("", "Test") Then WinClose("", "Test") EndIf EndFunc Edit: Beaten to the punch again Edited January 4, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 4, 2012 Author Share Posted January 4, 2012 I was hopeful but no such luck. I tried AdlibRegister and the function does not get called until after I manually press the OK button on the alert. Here's the bare bones relevant code that I tried: ... $o_form = _IEFormGetCollection ($oIE, 0) $o_name = _IEFormElementGetObjByName($o_form, "myTextArea") AdlibRegister("Popup") _IEFormElementSetValue($o_name, "way more than 500 characters...") AdlibUnRegister() ... Func Popup() msgbox(0,"was called","was called to kill popup") If WinActive("", "Cannot exceed 500 characters.") Then WinClose("", "Cannot exceed 500 characters.") EndIf EndFunc ... When I run that, I get my popup, I manually press OK and THEN I'm greeted by the msg from the Popup function. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 4, 2012 Moderators Share Posted January 4, 2012 (edited) MaritimeGirl, notice from the Help file...";... execution must be non blocking, avoid ...Wait(), MsgBox(), InputBox() functions"Have you tried it without the MsgBox? Edited January 4, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 4, 2012 Author Share Posted January 4, 2012 Tried without the msg as well - doesn't kill the popup either. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted January 4, 2012 Moderators Share Posted January 4, 2012 Hi, MariTimeGirl. It may be more helpful if you post your script in full. I duplicated the piece you gave me, using another site to enter the text, and the Popup function successfully closed the popup for me. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
JohnOne Posted January 4, 2012 Share Posted January 4, 2012 Or post the website. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 4, 2012 Author Share Posted January 4, 2012 I can't post the website nor the 2500 lines of code as it is a confidential intranet application.I have made a brand new test html and au3 to illustrate the problem.Here is the alert.html...<html><body><form><textarea id="mytextarea" name="mytextarea" onfocus="javascript:alert('too much text')"" onchange="javascript:alert('too much text')" onkeypress="javascript:alert('too much text')"></textarea></form></body></html>Here is the alert.au3...#include "IE.au3"Dim $oIE_IEAttach ($oIE)If Not IsObj($oIE) Then $oIE = _IECreate ()_IENavigate ($oIE, "http://localhost/alert.html")EndIf $HWND = _IEPropertyGet($oIE, "HWND")WinSetState($HWND, "", @SW_MAXIMIZE)$o_form = _IEFormGetCollection ($oIE, 0)$o_name = _IEFormElementGetObjByName($o_form, "mytextarea")_IELoadWait($oIE, 5000)AdlibRegister("Popup") _IEFormElementSetValue($o_name, "x") AdlibUnRegister()msgbox(0,"","After popup manually pressed") Func Popup() If WinActive("", "too much text") Then WinClose("", "too much text") EndIfEndFunc Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 5, 2012 Author Share Posted January 5, 2012 So I've stumped everyone with this? Link to comment Share on other sites More sharing options...
JohnOne Posted January 5, 2012 Share Posted January 5, 2012 Yes. Unlucky. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
arcker Posted January 6, 2012 Share Posted January 6, 2012 (edited) mmm i don't think you understnad how the popup function works. I've intercepted many message boxes without any issue.Your adlibregister must be called first. Then make a loop.If the window appears, it will be closed.Try to get the window info with au3info.exein the popup function :Func Popup() consolewrite ("window is trapped !") If WinActive("", "too much text") Then WinClose("", "too much text") EndIf EndFuncIt doesn't matter if the popup has been clicked or notfor the adlib, please use different value, more 500ms than default. Edited January 6, 2012 by arcker -- Arck System _ Soon -- Ideas make everything "La critique est facile, l'art est difficile" Projects :[list] [*]Au3Service : Run your exe as service V3 / Updated 29/07/2013 Get it Here [/list] Link to comment Share on other sites More sharing options...
MaritimeGirl Posted January 6, 2012 Author Share Posted January 6, 2012 (edited) According to documention, AdlibRegister constantly calls the function until AdlibUnregister is called at the given interval. I've added the time parameter as 750. It still doesn't dismiss the popup. Based on your post, I can't determine what you're telling me to loop. I tried looping a call to Popup() and my alert trigger instide the adlib commands but it still doesn't work. And the title is as I mentioned in my first post - the default of "Windows Internet Explorer" which I've also tried specifying in the Popup() function.If you can get that snippet of example code to work, please show me the exact syntax. I've spent days trying to get this to work and no matter what I've tried, I've been forced to manually press the OK button. Edited January 6, 2012 by MaritimeGirl Link to comment Share on other sites More sharing options...
Robjong Posted January 6, 2012 Share Posted January 6, 2012 (edited) took another look, try this one... #include "IE.au3" AdlibRegister("_KillPopup") Global $oIE = _IECreate("http://localhost/alert.html") While 1 Sleep(50) WEnd AdlibUnRegister("_KillPopup") _IEQuit($oIE) Func _KillPopup() WinClose("", "too much text") EndFunc Edit 1: working example Edit 2: changed URL Edited January 6, 2012 by Robjong 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