Jump to content
Sign in to follow this  
program builder

Is there any way to make youtube page close

Recommended Posts

program builder

I would like to be able to close youtube page after video playes, on any

video played. Is it possable? thanks.

Share this post


Link to post
Share on other sites
program builder

I want the code to be written in autoit. What I need, is, a way

to do a winwaitactive, where it waits for text, inside the page its self.

Is that even possable?

Edited by program builder

Share this post


Link to post
Share on other sites
PsaltyDS

It's being played by an API in the browser. So if it's IE, you might inject some Javascript to use the Player API and check the status in a loop:

player.getPlayerState():Number

Returns the state of the player. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5).

...or trigger by the onStateChange event:

Events

onStateChange

This event is fired whenever the player's state changes. Possible values are unstarted (-1), ended (0), playing (1), paused (2), buffering (3), video cued (5). When the SWF is first loaded it will broadcast an unstarted (-1) event. When the video is cued and ready to play it will broadcast a video cued event (5).

Subscribing to Events

Subscribe to events by adding an event listener to the player reference. For example, to get notified when the player's state changes, add an event listener for onStateChange and include a callback function.

function onYouTubePlayerReady(playerId) {
  ytplayer = document.getElementById("myytplayer");
  ytplayer.addEventListener("onStateChange", "onytplayerStateChange");
}

function onytplayerStateChange(newState) {
   alert("Player's new state: " + newState);
}
Good luck with it.

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
program builder

Is that even Autoit script? I need autoit script.

Share this post


Link to post
Share on other sites
PsaltyDS

No, Javascript run within the HTML of of web page.

To some extent, AutoIt can inject and kick off the javascript, but I don't think there is an interface to control it directly from outside the browser.

:blink:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
program builder

at the end of most of the videos, it says if you like...

is there any way to have autoit read the text, and shut

down the page?

Edited by program builder

Share this post


Link to post
Share on other sites
program builder

would something like this work?

ControlGetHandle("If you like", "", "")

could someone give me the correct code?

Share this post


Link to post
Share on other sites
program builder

;why isn't this working?

while 1

if winactive("YouTube", "If you like") then

send("{altdown}{f4}{altup}")

endif

wend

Share this post


Link to post
Share on other sites
program builder

Let me refrase the question.

Is there any way to read text inside of a webpage.

maybe that will get an answer.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×