📄 ie.~cpp
字号:
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "IE.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
int h,m;
String hour,min,sec;
TMain *Main;
//---------------------------------------------------------------------------
__fastcall TMain::TMain(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TMain::Timer1Timer(TObject *Sender)
{
static s;
s=s+1;
if(s%60==0)
{m=m+1;sec="0";}
else
{
sec=s%60;
}
if(m%60==0&&m!=0)
{h=h+1;min="0";}
min=m;
hour=h;
if(s%7==0)
{
AnsiString URL_="Explorer.exe http://";
URL_=URL_+edt_ie->Text;
const char *my=URL_.c_str();
WinExec(my ,SW_SHOW);
}
if((s+5)%this->Edit1->Text==0)
{
edt_num->Text=s/9;
HWND WinHandle = FindWindow(NULL,edt_title->Text.c_str());
SendMessage(WinHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
edt_time->Text=hour+" : "+min+" : "+sec;
//HWND WinHandle = FindWindow(NULL, "Windows 任务管理器");
//HWND WinHandle = FindWindow(NULL,edt_title->Text.c_str());
//SendMessage(WinHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
//---------------------------------------------------------------------------
void __fastcall TMain::btn_okClick(TObject *Sender)
{
//AnsiString URL_="Explorer.exe http://www.xsmhero.blog.163.com";
/*AnsiString URL_="Explorer.exe http://";
URL_=URL_+edt_ie->Text;
const char *my=URL_.c_str();
WinExec(my ,SW_SHOW); */
if(btn_ok->Caption=="OK")
{
btn_ok->Caption="取消";
if(edt_ie->Text==""&&edt_title->Text=="")
{
ShowMessage("网址或窗口标题名不能为空!");
}
else
{
Timer1->Enabled=true;
//Timer2->Enabled=true;
}
}
else
{
Timer1->Enabled=false;
btn_ok->Caption="OK";
}
}
//---------------------------------------------------------------------------
void __fastcall TMain::Timer2Timer(TObject *Sender)
{
HWND WinHandle = FindWindow(NULL,edt_title->Text.c_str());
SendMessage(WinHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}
//---------------------------------------------------------------------------
void __fastcall TMain::Label6Click(TObject *Sender)
{
this->Edit1->Visible=true;
}
//---------------------------------------------------------------------------
void __fastcall TMain::btn_ok2Click(TObject *Sender)
{
if(btn_ok2->Caption=="关闭网页")
{
Timer2->Enabled=true;
btn_ok2->Caption="取消";
}
else
{
Timer2->Enabled=false;
btn_ok2->Caption="关闭网页";
}
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -