Development :  K-Meleon Forum
K-Meleon development related discussions. 
Time Delay\Loop
Posted by: caraz
Date: January 30, 2005 12:38AM

I want to create something that requires some type of time delay/loop

I want it to execute X block of code every Y seconds

or, at least, wait Z seconds before executing X block of code

How can i does this in the macro language?

Is their a better tutorial for using the macro language that also covers all the basics?

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: rmn
Date: January 30, 2005 02:23AM

No way to do it with current macro language, but if the code you want to execute can be rewritten in javascript, you can use its normal delayed-looping functions (whatever they are; I don't know much js). The Reload macro (the last one in macros.cfg) might help you.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: caraz
Date: January 30, 2005 03:32AM

can anyone break down/rewrite the reload macro so it can infinetly loop X block of code every Y seconds

or, can someone just provide fill in the blank macro (macro+javascript) code to accomplish this task

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: fluxy
Date: April 12, 2005 05:26PM

I think that would be a great improvement in the macro language. Loops should be introduced and other conditional stuffs too. They are soooo useful

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: rmn
Date: April 13, 2005 04:25PM

> Loops should be introduced

Loops are already available. Timed/delayed loops aren't.

> and other conditional stuffs too

What other?

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: jsnj
Date: April 14, 2005 07:17AM

IIRC the original poster solved his request by using the event macros. Most common time delay requests can be solved by using the OnLoad macro.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: Anurag Jain
Date: March 07, 2006 06:06PM

for(i=0; i<len;i++)
{
statement 1;
pause(3000);
statement 2;
}


function pause(numberMillis) {
var now = new Date();
var exitTime = now.getTime() + numberMillis;
while (true) {
now = new Date();
if (now.getTime() > exitTime)
return;
}
}

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: everling
Date: March 18, 2006 11:35PM

I haven't touched KM's macros, but Anurag Jain's code looks suspiciously like the Javascript language. If it is Javascript, there are the setTimeout and the setInterval functions.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: rmn
Date: March 19, 2006 08:19AM

Yeah, that's JS, not K-Meleon macro.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: shaggy
Date: March 29, 2006 11:50PM

Use setTimeInterval() function.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: mark307
Date: April 15, 2006 08:11PM

I posted timer plugin that offers function similar macro statement "id" but with frequently executing.

http://rapidshare.de/files/18065120/timer-0.0.1.zip.html

However, JavaScript is still only solution to do with specially page.
Thanks.

Options: ReplyQuote
Re: Time Delay\Loop
Date: January 17, 2010 05:53AM

Here is how I make a loop that loops every millisecond:

<input value="" id="time" type="text"/>
<script type="text/javascript">
function SetTime()
{
document.getElementById("time").attributes[0].nodeValue=(new Date());
window.setTimeout("SetTime()",1);
}
SetTime()
</script>

It is possible to create a loop using functions instead of using a while loop, or for loop. The function just repeats it's self at the end of it, and i added a delay to it repeating it's self. This is one of my most logical pieces of work. We never have to use loops again because you can just use functions! ROFL

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: disrupted
Date: January 17, 2010 06:05AM

thanks daniel.. but(quoting romanito):
Quote
rmn
Yeah, that's JS, not K-Meleon macro.

that problem is now solved as macro language has been updated couple of years ago to include while {}loop

blast from the past?

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: akrama
Date: October 19, 2011 11:58PM

Quote
Daniel Schoolman
Here is how I make a loop that loops every millisecond:

<input value="" id="time" type="text"/>
<script type="text/javascript">
function SetTime()
{
document.getElementById("time").attributes[0].nodeValue=(new Date());
window.setTimeout("SetTime()",1);
}
SetTime()
</script>

It is possible to create a loop using functions instead of using a while loop, or for loop. The function just repeats it's self at the end of it, and i added a delay to it repeating it's self. This is one of my most logical pieces of work. We never have to use loops again because you can just use functions! ROFL
yes you use looping concept in javascript.

Options: ReplyQuote
Re: Time Delay\Loop
Posted by: reena19_lko
Date: January 25, 2012 06:51PM

Hoping this will help you...
Function sleep(seconds) from module time is pretty much the best. Remember seconds is a float so you can delay 0.5 seconds.

Python Syntax (Toggle Plain Text)

1.import_time

2.

3.print "Hello ..."

4.print "are you"

5.print "... there!"



Edited 1 time(s). Last edit at 01/25/2012 06:53PM by reena19_lko.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.