##lazarus多线程以实现多页面定时打卡的例子##
- lazarus2.2.6版本
步骤
- 获取窗口句柄,鼠标移动到输入框.
- 单击鼠标获取输入焦点
- 利用剪贴板粘贴输入内容
- 按下回车键,或者点击提交按钮,进行发送.
备注 - Win10平台正常运行
- 利用临界区以保证输入内容正确
- 线程处理函数传参需要事先定义一个recode类型
program GetWindow1;
uses
{$ifdef unix}cthreads, {$endif} sysutils, Windows, dateutils, LazUTF8;
var
MyCriticalSection: TRTLCriticalSection;
type
pcom= ^consum_s;
consum_s = record
keyno: integer;
iinterval: integer;
end;
procedure time_count(interval: integer);
var
{t1: TDateTime;}
HH,MM,SS,MS: Word;
HH2: Word;
begin
{t1:= now;}
{WriteLn('current time is [' + FormatDateTime( 'HH:MM:SS', t1) + ']');}
DecodeTime(Time,HH,MM,SS,MS);
Writeln (format('current time is [%.2d:%.2d:%.2d]',[HH,MM,SS]));
if MM + interval >= 60 then
begin
if HH + 1 < 24 then
begin
HH2:= HH + 1;
Writeln (format('[%.2d:%.2d:%.2d] would be comming',[HH2,(MM + interval)-60,SS]));
end
else
begin
HH2:= 0;
Writeln (format('[%.2d:%.2d:%.2d] would be comming',[HH2,(MM + interval)-60,SS]));
end;
end
else
Writeln (format('[%.2d:%.2d:%.2d] would be comming',[HH,MM+interval,SS]));
Writeln();
end;
procedure mykey_press_release(keyno: integer);
begin
if keyno = 1 then
begin
keybd_event(VK_CONTROL, 0, 0, 0)