return;

}

btnStart->Enabled = false;

btnStop->Enabled = true;

Panel1->Enabled = false;

Application->Minimize(); // 最小化刷刷窗口

}

//--------------------------------------------
void __fastcall TForm1::btnStopClick(TObject *Sender)// 停止刷屏

{

Timer1->Enabled = false;

btnStart->Enabled = true;

btnStop->Enabled = false;

Panel1->Enabled = true;

}

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

void __fastcall TForm1::Timer1Timer(TObject *Sender)

{

// 现刷屏nTimes次,到nTotalTimes次后完成。

if (nTimes == nTotalTimes)

{

btnStopClick(Sender);

return;

}


HWND hWnd;

hWnd = GetForegroundWindow(); // 得到当前窗口

if (hWnd == Form1->Handle) return; // 不需要程序本身的窗口


DWORD FormThreadID = GetCurrentThreadId();

DWORD CWndThreadID = GetWindowThreadProcessId(hWnd, NULL);


// 附加输入线程

AttachThreadInput(CWndThreadID, FormThreadID, true);

hWnd = GetFocus(); // 得到当前键盘光标所在的窗口

AttachThreadInput(CWndThreadID, FormThreadID, false); // 取消

if (hWnd == NULL) return;


nTimes++;

for (int i = 1; i <= SS_Text->Text.Length(); i++)

{ // 模拟键盘按键输入文本

PostMessage(hWnd, WM_CHAR, (WPARAM)(SS_Text->Text[i] & 0xFF), 0);

}


if (chkAutoNumber->Checked)

{ // 自动编号

AnsiString Lines = IntToStr(nTimes);

for (int j = 1; j <= Lines.Length(); j++)

PostMessage(hWnd, WM_CHAR, (WPARAM)(Lines[j]), 0);

}


if (chkAutoWrap->Checked) // 自动回车

PostMessage(hWnd, WM_KEYDOWN, VK_RETURN, 0);

}

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

本程序在Windows 2000 + C++ Builder 5下编译通过。源程序下载地址是:[url]http://www.cfan.net.cn/qikan/[/url] cxg/0206mnj.zip。

相关文章:

  • 2021-11-01
  • 2021-11-17
  • 2021-10-03
  • 2021-09-26
  • 2021-09-11
  • 2022-12-23
  • 2021-11-17
猜你喜欢
  • 2021-05-03
  • 2022-12-23
  • 2021-04-21
  • 2021-06-07
  • 2021-06-20
  • 2021-09-02
  • 2021-11-20
相关资源
相似解决方案