Indigo Rose Software

Professional Software Development Tools

 
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Feb 2005
    Posts
    30

    stopping a program

    Hello
    Sorry for my English

    I have a code to launch a program at a specifiec time thats OK

    But i want to stop that program on a other time.

    code on a page "Show"
    Code:
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    Page.StartTimer(1000)
    code on a page "Timer"
    Code:
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    if sTime == "15:35:00" then 
    	result = File.Run(_ProgramFilesFolder.."\\program\\program.exe", "", "", SW_SHOWNORMAL, false);
    
    end
    Is that possibel.

    Thanxs kurtgamer

  2. #2
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    That should work. I would recommend that if you are going to compare seconds that you lessen the timer to have it run more frequently. Even though you have it set to one second, I have seen it skip a second in a display due to a system being short on memory.

    Page.StartTimer(500)

    Tigg
    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
    Oct 2005
    Location
    American Dubai
    Posts
    629
    If you need to 'stop' a program at a specific time, you could use

    Code:
    -- define variable H
    Window.Close(H, CLOSEWND_TERMINATE);
    Where 'H' is a variable holding the WndHandle of the window you want to terminate.

    If you don't know the WndHandle of the window that needs to be closed, you could use

    Code:
    Windows_Open = Window.EnumerateTitles(false);

  4. #4
    Join Date
    Feb 2005
    Posts
    30
    Quote Originally Posted by TJ_Tigger
    That should work. I would recommend that if you are going to compare seconds that you lessen the timer to have it run more frequently. Even though you have it set to one second, I have seen it skip a second in a display due to a system being short on memory.

    Page.StartTimer(500)

    Tigg
    No good Tigg
    Because the program starts 2 times in the same second.

  5. #5
    Join Date
    Feb 2005
    Posts
    30
    Quote Originally Posted by Mina
    If you need to 'stop' a program at a specific time, you could use

    Code:
    -- define variable H
    Window.Close(H, CLOSEWND_TERMINATE);
    Where 'H' is a variable holding the WndHandle of the window you want to terminate.

    If you don't know the WndHandle of the window that needs to be closed, you could use

    Code:
    Windows_Open = Window.EnumerateTitles(false);
    Mina i test what You give to me but it dont work wright now.
    I take the code from the help

    Code:
    -- Get the titles and window handles of all open windows.
    windows = Window.EnumerateTitles();
    
    -- A variable containing text in the title you want to search for.
    window_name = "Notepad";
    
    -- Loop through the table of windows.
    for handle, title in windows do
    
        -- Check if the window title has the target text.
        result = String.Find(title, window_name, 1, false);
    
        -- if the string was found in the title, send the window a close message.
        if (result ~= -1) then
            Window.Close(handle, CLOSEWND_SENDMESSAGE);
        end
    end
    with a Notepad its OK
    But with my application NOT OK

    I wil try now to get al of the "titles and window handles of all open windows"
    in a table to check of my app.'s name

    kurtgamer

  6. #6
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    Quote Originally Posted by kurtgamer
    No good Tigg
    Because the program starts 2 times in the same second.
    Yup, because 500 milliseconds is half a second and the program is set to start in 1 second
    To get over this, something like this might help:

    Code:
    -- ((On timer))
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    if sTime == "15:35:00" and Launched then 
       Launched = false
    else
       result = File.Run(_ProgramFilesFolder.."\\program\\program.exe", "", "", SW_SHOWNORMAL, false);
    launched = true
    
    end

  7. #7
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    Quote Originally Posted by kurtgamer
    Mina i test what You give to me but it dont work wright now.
    I take the code from the help

    Code:
    -- Get the titles and window handles of all open windows.
    windows = Window.EnumerateTitles();
    
    -- A variable containing text in the title you want to search for.
    window_name = "Notepad";
    
    -- Loop through the table of windows.
    for handle, title in windows do
    
        -- Check if the window title has the target text.
        result = String.Find(title, window_name, 1, false);
    
        -- if the string was found in the title, send the window a close message.
        if (result ~= -1) then
            Window.Close(handle, CLOSEWND_SENDMESSAGE);
        end
    end
    with a Notepad its OK
    But with my application NOT OK

    I wil try now to get al of the "titles and window handles of all open windows"
    in a table to check of my app.'s name

    kurtgamer
    Replace "Notepad" with "the title of your window" in
    Code:
    window_name = "Notepad";

    For example, to close this window (indigorose forums), i used the following code and it worked:


    Code:
    windows = Window.EnumerateTitles();
    window_name = "stopping a program - Indigo Rose Software Forums - Mozilla Firefox";
    for handle, title in windows do
    result = String.Find(title, window_name, 1, false);
    if (result ~= -1) then
    Window.Close(handle, CLOSEWND_SENDMESSAGE);
    end
    end
    If you are using firefox, it should work perfectly with you

  8. #8
    Join Date
    Feb 2005
    Posts
    30
    Quote Originally Posted by Mina
    Yup, because 500 milliseconds is half a second and the program is set to start in 1 second
    To get over this, something like this might help:

    Code:
    -- ((On timer))
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    if sTime == "15:35:00" and Launched then 
       Launched = false
    else
       result = File.Run(_ProgramFilesFolder.."\\program\\program.exe", "", "", SW_SHOWNORMAL, false);
    launched = true
    
    end

    No Mina no good the application starts 2 times/sec and counting

  9. #9
    Join Date
    Feb 2005
    Posts
    30
    thanxs mina
    now i get it

    its the title of the window
    My bad englisch i tought it was the name of the program

    sorry I was not thinking straight

    kurtgamer

    Perfect for stopping my application thanxs
    Last edited by kurtgamer; 03-14-2006 at 09:21 AM.

  10. #10
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    Quote Originally Posted by kurtgamer
    No Mina no good the application starts 2 times/sec and counting
    Sorry, but i haven't made a project that did such actions before..
    Try it this way

    Code:
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    Last_Run = Registry.GetValue(HKEY_CURRENT_USER, "My-Application", "Last_Run", false);
    if Last_Run ~= "15:35:00" and sTime == "15:35:00" then
    result = File.Run(_ProgramFilesFolder.."\\program\\program.exe", "", "", SW_SHOWNORMAL, false);
    Registry.SetValue(HKEY_CURRENT_USER, "My-Application", "Last_Run", "15:35:00", REG_SZ);
    elseif Last_Run == "15:35:00" and sTime == "15:35:00" then
    Registry.SetValue(HKEY_CURRENT_USER, "My-Application", "Last_Run", sTime, REG_SZ);
    end

  11. #11
    Join Date
    Sep 2002
    Location
    Sol 3
    Posts
    3,160
    Quote Originally Posted by kurtgamer
    No good Tigg
    Because the program starts 2 times in the same second.
    Yes it will. Thanks Mina for responding, I would do what Mina did and put a variable that is set when you first launch the application then when your timer fires again then you can check to see if it is launched based on that variable. You could also stop the timer after you launch the program. I don't know it that will be appropriate or not, but it is a thought.

    Along the lines of checking the time multiple times within a second, you could have a counter that will reset after so many seconds as well. Something like this. Change the number in Red below to make it wait a number of timer iterations equal to the specified number.

    Code:
    --Launch code for the Timer
    Page.StartTimer(500);
    g_Timer_ctr = 0
    Launched = false;
    
    -- (On timer)
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    if Launched and g_Timer_ctr < 4 then 
       g_Timer_ctr = g_Timer_ctr +1;
       if g_Timer_ctr == 4 then
       	Launched = false
       	g_Timer_ctr = 0
       end
    elseif sTime == "10:54:00" and not Launched then
       result = File.Run(_SystemFolder.."\\notepad.exe", "", "", SW_SHOWNORMAL, false);
       Launched = true
       g_Timer_ctr = g_Timer_ctr +1;	
    end
    Tigg
    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
    Feb 2005
    Posts
    30
    Hallo mina
    I have learnd many things from your reply's

    my code is now the same you give me but i have taken the time ("17.53.00") to a string
    it's faster for changing.

    Now i will looking into the code from TJ-Tigger.

  13. #13
    Join Date
    Oct 2005
    Location
    American Dubai
    Posts
    629
    Quote Originally Posted by TJ_Tigger
    Code:
    --Launch code for the Timer
    Page.StartTimer(500);
    g_Timer_ctr = 0
    Launched = false;
    
    -- (On timer)
    sTime = System.GetTime(TIME_FMT_MIL)
    Label.SetText("Label11", sTime)
    
    if Launched and g_Timer_ctr < 4 then 
       g_Timer_ctr = g_Timer_ctr +1;
       if g_Timer_ctr == 4 then
       	Launched = false
       	g_Timer_ctr = 0
       end
    elseif sTime == "10:54:00" and not Launched then
       result = File.Run(_SystemFolder.."\\notepad.exe", "", "", SW_SHOWNORMAL, false);
       Launched = true
       g_Timer_ctr = g_Timer_ctr +1;	
    end
    Tigg
    Uh, yeah i could've said that..

  14. #14
    Join Date
    Mar 2005
    Posts
    3

    close rtf file

    Hallo TJ_Tigger
    I set a button to open a rtf file (assum afile name 2300.rtf) ,I need the code required to close it when I press anthor button
    with my regards
    Last edited by osamazaied; 05-01-2006 at 12:24 PM.

  15. #15
    Join Date
    Apr 2005
    Location
    In Wonderworld
    Posts
    246
    this will close an rtf file called 2300 that is opend , put this on a click action of your button.

    Code:
    -- Get the titles and window handles of all open windows.
    windows = Window.EnumerateTitles();
    
    -- A variable containing text in the title you want to search for.
    window_name = "2300";
    
    -- Loop through the table of windows.
    for handle, title in windows do
    
        -- Check if the window title has the target text.
        result = String.Find(title, window_name, 1, false);
    
        -- if the string was found in the title, send the window a close message.
        if (result ~= -1) then
            Window.Close(handle, CLOSEWND_SENDMESSAGE);
        end
    end

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Strange behaviour of the Close Program action
    By Elp in forum Setup Factory 6.0
    Replies: 2
    Last Post: 05-17-2004, 10:38 AM
  2. Is there a way to stop a program launching twice?
    By amaru96 in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 09-09-2003, 08:59 PM
  3. HOWTO: Make a Program Run Every Time the System Starts
    By Support in forum Setup Factory 6.0 Knowledge Base
    Replies: 0
    Last Post: 10-01-2002, 09:44 AM
  4. Stopping program to complete uninstall
    By johnjohn in forum Setup Factory 5.0
    Replies: 1
    Last Post: 08-24-2001, 02:58 PM

Posting Permissions

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