PDA

View Full Version : How can interrupt auto run application when running?



pierre
04-24-2004, 09:54 AM
Hi All:
Now, I have a problem that it needs all 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 all 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();

Stefan_M
04-24-2004, 02:21 PM
The problem is the action "Application.Sleep (1419000)".

Onlinehelp Note: While sleeping, the application will not respond to mouse movements, clicks, or key presses.

"will be closed by automatically after count equal five, and through 1419000 seconds"
Time: (number) The time to sleep, in milliseconds.
time to sleep: 1419 seconds (about 23 minutes).

Where do you start the timer?
Where do you create the "test.log" file. (The file must exist)

Your code in the [On Timer] is better placed at the end of the code from [OnClick]




Stefan

pierre
04-25-2004, 09:32 AM
Hi Stefan_M:
First, thank you for replying my problem. But I can't complete your meaning.

Your said:
Where do you start the timer?
Where do you create the "test.log" file. (The file must exist)

1th:
Q: Where do you start the timer?
A: After user input a numeric count for loop on this codes.

2th:
Q: Where do you create the "test.log"file?
A: I will create the test.log file by AMS5.0 on c: drive.

Other confuse problem: Your said: On the [OnTimer] tab, all codes can put in [OnClick] tab, is it correct? Can you reply the issue again? Thank you for advance.

Stefan_M
04-25-2004, 10:18 AM
In all cases I mean where did you place the 'code' to do something.

Why did place the code for closing the application in the [OnTimer] page?

There is a conceptual problem: you want that the application reacts on user events but you make the application sleep for a long time.



Stefan

pierre
04-26-2004, 06:10 AM
Hi Stefan_M:
What action can I use to interrupt autorun application when running program?