So just a few things to know from the top - I'm using Chrome and G33kdudes plugin to automate Chrome.
I have a window that appears on a webpage I'm trying to automate. I'm not sure if it functions as a popup, or a unload event listener. I assume it's the latter as when I attempt to navigate away from a page I get the attached prompt.
It is not always a guarantee that this event listener will popup it seems to be about 50/50, so I'm trying to find a piece of Autohotkey code that is able to detect this event listener and then press enter if the event listener pops up.
Thanks in advance.
Detecting and interreacting with OnUnload Event
Detecting and interreacting with OnUnload Event
- Attachments
-
- Unload.PNG (7.58 KiB) Viewed 355 times
-
- Posts: 4398
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Detecting and interreacting with OnUnload Event
I think an event you are interested in is beforeunload. You can try to just clear it by evaluating the js code:
Code: Select all
window.onbeforeunload = function() { }
Re: Detecting and interreacting with OnUnload Event
Hi, thanks for the reply. I'm quite new to AutoHotkey, so I'm wondering if it's possible to write the whole function out as an example. What sort of functions should be contained within the brackets to either accept or dismiss this popup?
-
- Posts: 4398
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Detecting and interreacting with OnUnload Event
That is not an AHK code, but javascript. That code should be evaluated as it is via PageInst.Evaluate("window.onbeforeunload = function() { }"). The function is really blank, this is needed to clear a beforeunload event handler. There is no guarantee that this will work, it's just an attempt.
Re: Detecting and interreacting with OnUnload Event
Hey thanks again teadrinker, I tried this method but it doesn't seem to do the trick. I still get the pop-up occasionally and I need a stable way to interact with it.
Is there a way to create a sort situational 'IF' statement that analyses as to whether a beforeunload pops up, and if it does then to send enter?
Is there a way to create a sort situational 'IF' statement that analyses as to whether a beforeunload pops up, and if it does then to send enter?
-
- Posts: 4398
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Detecting and interreacting with OnUnload Event
To answer your question, I need real page to test.
Who is online
Users browsing this forum: Rohwedder and 115 guests