Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 15 of 15
  1. #1
    Join Date
    Apr 2004
    Location
    Taiwan
    Posts
    83

    Huh? How to use the Page.StartTimer and Page.StopTimer?

    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.
    Pierre

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    There is an example here on how to use the timer.

    http://www.indigorose.com/forums/showthread.php?t=7246
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  3. #3
    Join Date
    Apr 2004
    Location
    Taiwan
    Posts
    83
    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.
    Pierre

  4. #4
    Join Date
    Aug 2003
    Location
    Maine, USA
    Posts
    1,695
    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

  5. #5
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    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);


    Quote Originally Posted by pierre
    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.

  6. #6
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    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]
    Code:
    --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)
    Code:
    --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
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  7. #7
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Dig them crazy code windows daddy-o!

    Corey Milner
    Creative Director, Indigo Rose Software

  8. #8
    Join Date
    Apr 2004
    Location
    Taiwan
    Posts
    83
    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
    Pierre

  9. #9
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    [OnTimer]
    Code:
    --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
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  10. #10
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    I feel like I've seen this post somewhere before, before, before...

    Quote Originally Posted by TJ_Tigger
    [OnTimer]
    Code:
    --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

  11. #11
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    deja vu
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  12. #12
    Join Date
    Apr 2004
    Location
    Taiwan
    Posts
    83
    Sorry, I keep bothering all. Sorry again.
    Pierre

  13. #13
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    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.

    Quote Originally Posted by pierre
    Sorry, I keep bothering all. Sorry again.

  14. #14
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    We are here.
    Quote Originally Posted by Worm
    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.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

  15. #15
    Join Date
    Apr 2004
    Location
    Taiwan
    Posts
    83
    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).."__".."Mult i_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();
    Pierre

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts