PDA

View Full Version : How to use the Page.StartTimer and Page.StopTimer?


pierre
04-20-2004, 11:04 AM
Hi all:
I can't understand the Page.StartTimer and Page.StopTimer of using methods. Who has some examples for me? Sorry, I am a design novice. I hope the thread won't bother you. Thank you for advance.
I wish I use the Page.StartTimer and Page.StopTimer to control time that let me control other external application or programs of open or close.

TJ_Tigger
04-20-2004, 11:07 AM
There is an example here on how to use the timer.

http://www.indigorose.com/forums/showthread.php?t=7246

pierre
04-21-2004, 08:11 AM
TJ_Tigger:
Sorry, keep bother you. I am a stupid man. I still can't understand the Page.StartTimer how to use. Can you teach me or give me a simple example about the timer,please? Thank you for advance.

rhosk
04-21-2004, 08:18 AM
This is a FINE example of Timer capabilities in AMS. Should be everything you need and more...


http://www.indigorose.com/forums/showthread.php?t=7088

Worm
04-21-2004, 08:22 AM
Pierre,

To start the timer you need to issue the command to start it.

Page.StartTimer(interval);

The interval is a number representing the milliseconds you want between the On Timer event being processed.

Here are some examples:
--run the code in the page's On Timer event every second.
Page.StartTimer(1000);

--run the code in the page's On Timer event every 1/4 second.
Page.StartTimer(250);

--run the code in the page's On Timer event every 5 second.
Page.StartTimer(5000);


TJ_Tigger:
Sorry, keep bother you. I am a stupid man. I still can't understand the Page.StartTimer how to use. Can you teach me or give me a simple example about the timer,please? Thank you for advance.

TJ_Tigger
04-21-2004, 08:37 AM
As Worm and Ron have said, the timer is realtive straight forward to setup. There are two commands to review.

Page.StartTimer(milliseconds)
Page.StopTimer

When you use the Page.StartTimer it will cause the "On Timer" event to occur when the duration you defined expires. This event will continue to occur at every x milliseconds as defined by Page.StartTimer. To use this in the example you provided on another post.
[ON Click]

--It uses Windows Media Player to open a file that the name is 12-128k_wma.wma
File.Run("AutoPlay\\Docs\\wmplayer.exe", "D:\\design-MM\\AUDIO\\source\\12\\wma\\12-128k_wma.wma", "", SW_SHOWNORMAL, false);
--assume the file plays for 6 minutes, this equates to 360 seconds or 360000milliseconds, start the timer for 360000milliseconds
Page.StartTimer(360000)


[On Timer]
--This event will only happen when the timer expires after 360000 milliseconds (the duration of our song as defined above)

--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles();

window_name = "Windows Media Player";

for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
Page.StopTimer

Corey
04-21-2004, 02:21 PM
Dig them crazy code windows daddy-o!

Corey Milner
Creative Director, Indigo Rose Software (http://www.indigorose.com)

pierre
04-22-2004, 10:29 AM
TJ_Tigger:
I has tried your suggestion that it can reach my demand. Thank you help me solve problem again.

I have other problems. Can you solve or teach me again?
The codes as below:
I wish you can modify or add some codes that it reaches my request.

My request function is: I want to check Windows Media Player and Winamp and RealOne Player at the same time. If the external application is not Windows Media Player, it is Winamp or RealOne Player. I hope the AMS5 still can close the external application(Winamp or RealOne Player).
How can I do ?

[OnTimer]
--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles();

window_name = "Windows Media Player";

for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end

TJ_Tigger
04-22-2004, 02:22 PM
[OnTimer]

--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles();

tblwindow_name = {"Windows Media Player", "Real", "WinAmp"};

for index, window_name in tblwindow_name do

for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
end

Worm
04-22-2004, 02:25 PM
I feel like I've seen this post somewhere before, before, before...

[OnTimer]

--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles();

tblwindow_name = {"Windows Media Player", "Real", "WinAmp"};

for index, window_name in tblwindow_name do

for handle, title in windows do

result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
end

TJ_Tigger
04-22-2004, 03:03 PM
deja vu
;)

pierre
04-22-2004, 10:08 PM
Sorry, I keep bothering all. Sorry again.

Worm
04-22-2004, 10:14 PM
Please don't take this too seriously. If you don't get it, you don't get it. Keep asking until the light bulb comes on.

Sorry, I keep bothering all. Sorry again.

TJ_Tigger
04-22-2004, 10:28 PM
We are here. :p
Please don't take this too seriously. If you don't get it, you don't get it. Keep asking until the light bulb comes on.

pierre
04-23-2004, 06:42 AM
Hi TJ_Tigger and Worm:
Thank you keep helping me solving many confuse problems.
Now, I have a problem that it needs you help me modyfying below codes.

--It will display a dialog window to input a numeric by user for loop, and it will open test.m3u by Winamp media player. If the user input a numeric is 5, it will count five times. The autorun application window will minimize first. After 1419000 seconds, the count becomes two until five, then play to end. At this time, the external application (winamp) will be closed by automatically after count equal five, and through 1419000 seconds. And it will record every time open media player time and date.

I wish I can interrupt the application [It means the auto run application, not external application(winamp)] any time after the user has input a numeric to count for loop on this codes.
How can I do? Please you help me modifying and solving this codes probelm again. Thank you for advance.

[OnClick]
numeric = "";
while (numeric == "") and (numeric ~= "CANCEL") do
numeric = Dialog.Input("Burn in", "Please enter your numeric for loop :", "", MB_ICONQUESTION);

if numeric == "" then
result = Dialog.Message("Invalid Input", "Please use a numeric value greater than" , MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);

elseif numeric ~= "CANCEL" then
min = 1; -- The number to start at
max = numeric; -- The number to stop at

for count = min, max do
File.Open("AutoPlay\\Docs\\test.m3u", "", SW_SHOWNORMAL);
TextFile.WriteFromString("C:\\Test.log", System.GetDate(DATE_FMT_US).."__Start time:"..System.GetTime(TIME_FMT_AMPM).."__".."Multi_Media_Audio" .. "\r\n", true);
handle = Application.GetWndHandle();
--Hide the AutoPlay application window.
Window.Minimize(handle);
Application.Sleep (1419000);
end
end
end

[OnTimer]

--Finds all open windows with the string "Windows Media Player" in the title and sends each of them a close message.

windows = Window.EnumerateTitles()
tblwindow_name = {"Windows Media Player", "Real", "WinAmp"};
for index, window_name in tblwindow_name do

for handle, title in windows do
result = String.Find(title, window_name, 1, false);

if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
end
Page.StopTimer();