基本信息
源码名称:c++ 模拟鼠标按键
源码大小:2.34M
文件格式:.rar
开发语言:C/C++
更新时间:2020-10-14
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
设定按键坐标与定时器,自动点击鼠标

//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit2.h"
#include <System.IniFiles.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TFrame2 *Frame2;
//---------------------------------------------------------------------------
__fastcall TFrame2::TFrame2(TComponent* Owner)
: TFrame(Owner)
{
nMx = 0;
nMy = 0;
    nInterval = 10;
}
//---------------------------------------------------------------------------
void __fastcall TFrame2::FrameInit(int nIndex)
{
    box->Caption = String(nIndex);
this->Tag = nIndex;

TIniFile *IniFile = new TIniFile(ExtractFilePath(Application->ExeName) "config.ini");
String group;
group.sprintf(L"GROUP%d",nIndex);
if(IniFile){

Mx->Text = IniFile->ReadString(group,"MX","0");
My->Text = IniFile->ReadString(group,"MY","0");
chInterval->Checked = IniFile->ReadInteger(group,"BREP",0)==0?false:true;
txtIntval->Text = IniFile->ReadString(group,"INTERVAL","10");
delete IniFile;
}
    this->btnPause->Enabled = false;
}
void __fastcall TFrame2::btnSaveClick(TObject *Sender)
{
//
int nIndex = this->Tag;
    TIniFile *IniFile = new TIniFile(ExtractFilePath(Application->ExeName) "config.ini");
String group;
group.sprintf(L"GROUP%d",nIndex);
if(IniFile){

IniFile->WriteString(group,"MX",Mx->Text);
IniFile->WriteString(group,"MY",My->Text);
IniFile->WriteInteger(group,"BREP",chInterval->Checked?1:0);
nInterval = _wtoi(txtIntval->Text.c_str());
if(nInterval<1) nInterval =1;


IniFile->WriteString(group,"INTERVAL",nInterval);
delete IniFile;
if(Sender==btnSave){
ShowMessage("保存参数成功");
}
}

nMx = _wtoi(Mx->Text.c_str());
nMy = _wtoi(My->Text.c_str());
tm->Interval = nInterval*1000;

}
//---------------------------------------------------------------------------

void __fastcall TFrame2::btnStartClick(TObject *Sender)
{

    btnSaveClick(Sender);

if(btnStart->Tag==0){
btnStart->Tag = 1;
btnStart->Enabled = false;



tmTimer(tm);

if(chInterval->Checked){
tm->Enabled = true;
}
btnPause->Enabled = true;
}
}
//---------------------------------------------------------------------------

void __fastcall TFrame2::tmTimer(TObject *Sender)
{
//

SetCursorPos(nMx,nMy);//注意:这个坐标是屏幕的绝对坐标
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);


}
//---------------------------------------------------------------------------

void __fastcall TFrame2::btnPauseClick(TObject *Sender)
{
//
tm->Enabled = false;
btnStart->Tag = 0;
btnStart->Enabled = true;
btnPause->Enabled = false;




}
//---------------------------------------------------------------------------