Mouse Click (1.1) to trigger action against sleep
Mouse movements seem to not be enough to appear active.
This commit is contained in:
parent
e2d351b37a
commit
5e0537cb20
1 changed files with 23 additions and 3 deletions
26
main.pas
26
main.pas
|
|
@ -17,8 +17,11 @@ type
|
||||||
private
|
private
|
||||||
{ Private declarations }
|
{ Private declarations }
|
||||||
FMyTask : ITask ;
|
FMyTask : ITask ;
|
||||||
|
currentPos : TPoint ;
|
||||||
|
counter : Integer ;
|
||||||
procedure startTask ;
|
procedure startTask ;
|
||||||
procedure stopTask ;
|
procedure stopTask ;
|
||||||
|
|
||||||
public
|
public
|
||||||
{ Public declarations }
|
{ Public declarations }
|
||||||
end;
|
end;
|
||||||
|
|
@ -37,8 +40,10 @@ implementation
|
||||||
|
|
||||||
procedure TfrmMain.FormCreate(Sender: TObject);
|
procedure TfrmMain.FormCreate(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
direction := False ;
|
direction := False ;
|
||||||
runIt := False ;
|
runIt := False ;
|
||||||
|
currentPos := Point( mouse.CursorPos.X , mouse.CursorPos.Y ) ;
|
||||||
|
counter := 0 ;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -82,6 +87,21 @@ begin
|
||||||
procedure
|
procedure
|
||||||
begin
|
begin
|
||||||
direction := Not direction ;
|
direction := Not direction ;
|
||||||
|
counter := counter + 1 ;
|
||||||
|
if counter >= 60 then
|
||||||
|
begin
|
||||||
|
counter := 0 ;
|
||||||
|
// Move cursor to specific screen coordinates
|
||||||
|
currentPos := Point( mouse.CursorPos.X , mouse.CursorPos.Y ) ;
|
||||||
|
mouse.CursorPos := Point( 1, 1 ) ;
|
||||||
|
// Simulate mouse button press and release
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 1, 1, 0);
|
||||||
|
Sleep(150);
|
||||||
|
mouse_event(MOUSEEVENTF_LEFTUP, 0, 1, 1, 0);
|
||||||
|
// Get back to position
|
||||||
|
mouse.CursorPos := currentPos ;
|
||||||
|
end;
|
||||||
|
|
||||||
if direction then
|
if direction then
|
||||||
mouse.CursorPos := Point( mouse.CursorPos.X + 2, mouse.CursorPos.Y + 2 )
|
mouse.CursorPos := Point( mouse.CursorPos.X + 2, mouse.CursorPos.Y + 2 )
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue