Posted by Met@ on September 08, 2002 at 14:41:20:
In Reply to: Re: Closing a program posted by Met@ on August 31, 2002 at 14:42:40: : : : : : Yeah, i thought it wouldn't work, see the problem iz getting the handle of IE.... try looking up handle in the windows sdk... : : : : Tnx for your reply! Erm.....who can I do that(I'm working with Win2K)? : : : : Met@ : : : Hey, look what I found: : : : //Use this to close all open IE windows. : : : Var : : : //note instead of SC_CLOSE : : : //SC_MINIMIZE can be used to minimize all ie windows : : : //This could be used on a button click or in a timer for example. : : : I think this is what I was looking for...yes! IT IS! Thanks for your help anyhow! :D :D :D <(^_^)> : : : Met@ : : Whoops! I cheered too early......LOL IT DOESN'T WORK! *pulling hair out of head* : : TIA : : Met@ : Hey! IT DOES WORK! It just doesn't work with the windows that just opened.......LOL Look: : procedure TForm1.Button1Click(Sender: TObject); : That DOES work, but it only closes the windows that were already open! But nevermind that ;) I thought of another way......LOL I wanted my IE to close for some weird reasons.........had to do with the order of the programs on my start bar LOL IE opened faster than my mail programs, so IE had to close...LOL But I can build in a timer! *DUH* So, I'm gonna try that now! :D : Met@ YAY! IT WORKS! Here's my source......maybe it's of any use for other visitors ;) This program opens Outlook, then waits a few secs, then opens Outlook Express, waits a few secs, opens IE at a specified url, waits a few secs, opens IE at a specified url, waits a few secs, opens IE at a specified url, displays a message at 21:54 (saying that Outlook and Outlook Express will be closed in 5 minutes) and closes Outlook and Outlook Express at 21:59 (just in time for the daily back-up). Now I only have to find a way to display the program window "on top of" all windows at 21:54.......hmmmmm..I'll start another topic about that later! Okay, my source: unit tijd; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, SHELLAPI, ExtCtrls; type TForm1 = class(TForm) Button1: TButton; Label1: TLabel; Label2: TLabel; Label3: TLabel; Timer1: TTimer; Timer2: TTimer; Timer3: TTimer; Timer4: TTimer; Timer5: TTimer; Timer6: TTimer; procedure Button1Click(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure Timer2Timer(Sender: TObject); procedure Timer3Timer(Sender: TObject); procedure Timer4Timer(Sender: TObject); procedure Timer6Timer(Sender: TObject); procedure Timer5Timer(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin Timer1.Enabled := true; Timer6.Enabled := true; end; procedure TForm1.Timer1Timer(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('D:\Program Files\Microsoft Office\Office\OUTLOOK.EXE'), nil, nil, SW_SHOW); Timer2.Enabled := true; Timer1.Enabled := false; end; procedure TForm1.Timer2Timer(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('D:\Program Files\Outlook Express\MSIMN.EXE'), nil, nil, SW_SHOW); Timer3.Enabled := true; Timer2.Enabled := false; end; procedure TForm1.Timer3Timer(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), PChar('http://thesimssite.endoria.net/indexECHT.htm'), nil, SW_SHOW); Timer3.Enabled := false; Timer4.Enabled := true; end; procedure TForm1.Timer4Timer(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), PChar('http://thesimssite.endoria.net/CC/phpBB2/index.php'), nil, SW_SHOW); Timer4.Enabled := false; Timer5.Enabled := true; end; procedure TForm1.Timer5Timer(Sender: TObject); begin ShellExecute(Handle, 'open', PChar('D:\Program Files\Internet Explorer\IEXPLORE.EXE'), PChar('http://www.the-forums.nl'), nil, SW_SHOW); Timer5.Enabled := false; end; procedure TForm1.Timer6Timer(Sender: TObject); var Outlook, OE: Thandle; begin if TimeToStr(time)='21:54:00' then Showmessage('Outlook en Outlook Express' + ' worden over vijf minuten afgesloten!'); if TimeToStr(time)='21:59:00' then begin Outlook := FindWindow('rctrl_renwnd32',nil); If Outlook <> 0 Then SendMessage(Outlook, WM_SYSCOMMAND,SC_CLOSE,0); end; begin OE := FindWindow('Outlook Express Browser Class',nil); If OE <> 0 then SendMessage(OE, WM_SYSCOMMAND,SC_Close,0); end; end; end.(Oh yeah, the timerintervals are set at different values, to make the program "wait".... |
|