AutoHotkey Community

It is currently May 27th, 2012, 1:22 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: August 25th, 2008, 8:54 pm 
Offline

Joined: October 9th, 2004, 8:55 pm
Posts: 217
Location: Budapest, Hungary
I needed this feature and I've seen there was no solution which worked reliably in Firefox and Opera (I don't use IE, I assume there is some COM solution for it).

It uses user Javascript to monitor when the page is loaded and modifies the page title if it's loaded, so one can query it with wingetttitle.

For Firefox GreaseMonkey needs to be installed for the script to work, Opera has the necessary functionality built-in.

It's not a pure AutoHotkey solution, but at least it works reliably.

Code:
// ==UserScript==
// @name           loaded
// @namespace      my
// @description    indicate if a page is loded
// @include        http://www.cnn.com
// ==/UserScript==


window.addEventListener(
  'load',
  function (e) {
    document.title += " [loaded]";
 }, false);



See also this topic for an other feature using the same technique.


Last edited by keyboardfreak on August 29th, 2008, 5:06 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 25th, 2008, 9:56 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
keyboardfreak wrote:
I needed this feature and I've seen there was no solution which worked reliably in Firefox and Opera (I don't use IE, I assume there is some COM solution for it)

Unfortunately there is no COM interface to the afore mentioned browsers thus no AHK COM solution to be had
Thank you keyboardfreak this has been many times asked for and is the best idea I have seen but it as you mentioned isnt an ahk solution but a Grease Monkey/Javascript Solution. Albeit a pretty darn good one
I think once Firefox exposes its internal methods and properties to other languages other than mozilla plug in based then the move from IE to mozilla in the corp world can finally begin. But not untill then
another interesting solution I found is
http://www.autohotkey.com/forum/viewtop ... it+firefox
garry wrote:
this is for Mozilla Firefox:
Code:
;-- from AUTOWQ german forum
;-- http://de.autohotkey.com/forum/topic29.html
#Persistent
UR=http://www.screamer-radio.com/
SC=Screamer      ;title
IE=%A_programfiles%\Mozilla Firefox\firefox.exe
CL=ahk_class MozillaWindowClass

Run,%IE% %UR%,,max
WinWait,%SC%
IfWinNotActive,%SC%,,WinActivate,%SC%
WinWaitActive,%SC%
Sleep,300
SetTimer,FireFoxLoadDetect,500
Return

FireFoxLoadDetect:    ;check firefox rotary wheel
col32:=0xB2B2B2
col16:=0xB5B2B5
WinGetPos,,,WI,HI,A
;---Firefox 1.5 / 2.0 ------
Wi -= 16                            ; Position from wheel = Windowswidth -16
PixelGetColor, OutputVar, Wi, 41    ; 41 = Position from top

if outputvar in %col16%,%col32%
  {
  msgbox,%UR% is open
  ExitApp
  }
return


As far as COM IE and Gui Browsers go
http://www.autohotkey.com/forum/viewtop ... highlight=
The above link is a complete COM IE Gui Browser tutorial
This is just an excerpt the first 2 snippets do not standalone but the 3rd one that I got from Sean does
tank wrote:
wait for it to finish loading
Code:
loop
      If (rdy:=COM_Invoke(pwb,"readyState") = 4)
         break
another way to check if a page has loaded using javascript via com
Code:
pwin:=COM_Invoke(doc:=COM_Invoke(pwb,"Document"),"parentWindow")   
   if pwin is integer
      loop
         If rdy:=COM_Invoke(pwin, "execScript","var rdy=document.readyState","rdy") = "complete" 
            break

of course always release objects not textyou wouldnt release rdy but you would release doc in the example above
a comletely independent way to check readystate requires tab if enabled to be the selected tab but doesnt require the window to be active
http://www.autohotkey.com/forum/viewtop ... sc&start=0
Sean wrote:
It'll check whether a webpage is completely loaded or not in the active Internet Explorer.

NEED the latest COM Standard Library.

Code:
; Run, iexplore.exe http://www.google.com/
MsgBox, % IEReady()
Return

IEReady(hIESvr = 0)
{
   If Not   hIESvr
   {
      Loop,   50
      {
         ControlGet, hIESvr, hWnd, , Internet Explorer_Server1, A ; ahk_class IEFrame
         If   hIESvr
            Break
         Else   Sleep 100
      }
      If Not   hIESvr
         Return   """Internet Explorer_Server"" Not Found."
   }
   Else
   {
      WinGetClass, sClass, ahk_id %hIESvr%
      If Not   sClass == "Internet Explorer_Server"
         Return   "The specified control is not ""Internet Explorer_Server""."
   }

   COM_Init()
   If   DllCall("SendMessageTimeout", "Uint", hIESvr, "Uint", DllCall("RegisterWindowMessage", "str", "WM_HTML_GETOBJECT"), "Uint", 0, "Uint", 0, "Uint", 2, "Uint", 1000, "UintP", lResult)
   &&   DllCall("oleacc\ObjectFromLresult", "Uint", lResult, "Uint", COM_GUID4String(IID_IHTMLDocument2,"{332C4425-26CB-11D0-B483-00C04FD90119}"), "int", 0, "UintP", pdoc)=0
   &&   pdoc && pweb:=COM_QueryService(pdoc,IID_IWebBrowserApp:="{0002DF05-0000-0000-C000-000000000046}")
      Loop
         If   COM_Invoke(pweb, "ReadyState") = 4
            Break
         Else   Sleep 500
   COM_Release(pdoc)
   COM_Release(pweb)
   COM_Term()
   Return   pweb ? "DONE!" : False
}

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 25th, 2008, 10:55 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Simple yet effective, another why didn't I think of that :P If there are any GM clones for IE window.attachEvent('onload',function (){document.title+=' [loaded]';}); would be a valid hook.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2008, 1:03 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
Oooh, I like it :D

Thanks for posting this.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2008, 1:57 am 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
i tried injecting this into IE and it failed to update the title ?? even tried updating title with
Code:
javascript:void(document.title="[loaded]")
nothing :cry:

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2008, 9:30 am 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
tank wrote:
i tried injecting this into IE and it failed to update the title
Not sure why, perhaps it's an anti-XSS rule. Firefox doesn't have this problem. Here's an example of the embedded script, which works.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2008, 12:42 pm 
Offline
User avatar

Joined: December 21st, 2007, 3:14 pm
Posts: 3826
Location: Louisville KY USA
Titan wrote:
tank wrote:
i tried injecting this into IE and it failed to update the title
Not sure why, perhaps it's an anti-XSS rule. Firefox doesn't have this problem. Here's an example of the embedded script, which works.
oh i know thats why i think its odd
its valid javascript it should work
its very odd indeed
Im gonna do some research of my own see if i can root it out for sure

_________________
No matter what your oppinion Please join this discussion
Formal request to Polyethene
Image


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 9th, 2010, 10:06 am 
Offline

Joined: September 2nd, 2007, 1:56 am
Posts: 15
Location: urban india = hell
keyboardfreak wrote:
It's not a pure AutoHotkey solution, but at least it works reliably.

Code:
// ==UserScript==
// @name           loaded
// @namespace      my
// @description    indicate if a page is loded
// @include        http://www.cnn.com
// ==/UserScript==


window.addEventListener(
  'load',
  function (e) {
    document.title += " [loaded]";
 }, false);


I was so excited to stumble across this thread, I tried it, but it doesnt work in Opera 10.10
I dont know how to correct or update the js. Please help :)

_________________
no fate but what we make


Report this post
Top
 Profile  
Reply with quote  
PostPosted: March 9th, 2010, 6:16 pm 
yogi wrote:
I was so excited to stumble across this thread, I tried it, but it doesnt work in Opera 10.10
I dont know how to correct or update the js. Please help :)


It should work (it works on v9.6x), but you need to modify the js for the sites you want it to work on (you might find some help on the Opera site). Make sure that you have user js enabled in Opera configuration.

If you modify the original post js code to look like this
Code:
// ==UserScript==
// @name           loaded
// @namespace      my
// @description    indicate if a page is loded
// ==/UserScript==


window.addEventListener(
  'load',
  function (e) {
    document.title += " [loaded]";
 }, false);

it should work on all sites (as originally posted in only works on http://www.cnn.com).


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 1:49 pm 
Offline

Joined: September 2nd, 2007, 1:56 am
Posts: 15
Location: urban india = hell
works like a charm now, thanks so much for the corrected javascript!!! :))

_________________
no fate but what we make


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2010, 10:37 pm 
Offline

Joined: October 11th, 2007, 3:03 pm
Posts: 51
I'm very excited about this thread, but I don't know enough about JavaScript or greasemonkey in Firefox to be able to apply the techniques here.

How about some step-by-step instructions to get this to work in Firefox?

Thanks in advance.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: ummm
PostPosted: March 25th, 2010, 5:27 pm 
this only works with sites that have swf on the page

like google doesnt work, youtube does
facebook doesnt work, yahoo does


Report this post
Top
  
Reply with quote  
PostPosted: May 1st, 2010, 2:24 pm 
rifts wrote:
this only works with sites that have swf on the page

like google doesnt work, youtube does
facebook doesnt work, yahoo does


I am using Opera and it works perfectly also with google and yahoo.
I do not have a facebook account so I did not tested.
The only modification I made is:
"document.title = "loaded-" + document.title; "

to display it at the beginning of the title,
because on sites with very long title the "load" is not displayed.

Very nice job keyboardfreak, simple and powerful


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2010, 1:00 am 
Offline

Joined: August 4th, 2010, 5:59 am
Posts: 53
1. is this possible to modify the page title when it's loading and then change it again when page is completely loaded?
2. what about situation when we don't know exacly address of page? at opera page i've found:
Quote:
// ==UserScript==
// @include http://example.com/*
// @include http://www.example.com/*
// @exclude http://example.com/directory/*
// @exclude http://www.example.com/example.html
// ==/UserScript==

but it doesn't work when there is a subdomain e.g: http://subdomain.example.com/stg.cgi?23424234
how can we change jsBumbler's script to work in this situation?

thanks in advance


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 9th, 2010, 10:14 am 
Offline

Joined: March 26th, 2010, 5:55 pm
Posts: 129
This has been mentioned in other threads before, but MozRepl lets you connect over a socket and do pretty much anything with Firefox. In this way it can be very scriptable. You can do essentially anything a plugin can do, not just js within the page. For a while I was sending it commands from AHK and it worked great.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Bon and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group