Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

chrome browse/Java Sript: How can I detect a onunload event


  • Please log in to reply
4 replies to this topic
briter
  • Members
  • 148 posts
  • Last active: Jan 31 2018 05:41 PM
  • Joined: 13 Nov 2014

Hi Community,

 

I am working on a script which uses Chrome a lot. I need to close tabs on a regular basis and sometimes there are webpages which use the Java Script "onunload" event, which opens a warnings message saying something like "Are you sure you want to leave this page? Yes/No" when attempting to close the tab via "send ^w".

 

Does anyone have a workaround for this. I would be even greatful if there was a way that AHK detects this event so I can handle it somehow.

My script has to rely on that the tab closes, otherwise it messes up completely.

 

Many thanks in advance and Regards!



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
Does your popup have a win title or ahk_class?

Note: IE Can be fully automated with the newest release of autohotkey from http://ahkscript.org
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

briter
  • Members
  • 148 posts
  • Last active: Jan 31 2018 05:41 PM
  • Joined: 13 Nov 2014

No, all I get is "ahk_class Chrome_WidgetWin_1" which I get for any tab in Chrome.

 

But I must say that I have not been working with classes so far. I used Windows Spy from AHK to retreive this information.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

Can you post a screenshot of your winspy when you hover over the popup? ( you need to upload it somewhere else, as this forum does not allow you to upload images ) 


Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

briter
  • Members
  • 148 posts
  • Last active: Jan 31 2018 05:41 PM
  • Joined: 13 Nov 2014

Here we go:

 

http://de.tinypic.com/r/fbased/8

 

 

EDIT:

 

OK, I must have been blind. there is acutally a different window title which I can handle by simply sending {ENTER} and then ^w again.

 

I just donĀ“t know if the text "Die Seite auf" will be the same for any JS Onunload event. 

 

If not, I am still dealing with the problem.

 

Regards