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 declarations }
|
||||
FMyTask : ITask ;
|
||||
currentPos : TPoint ;
|
||||
counter : Integer ;
|
||||
procedure startTask ;
|
||||
procedure stopTask ;
|
||||
procedure stopTask ;
|
||||
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
|
@ -37,8 +40,10 @@ implementation
|
|||
|
||||
procedure TfrmMain.FormCreate(Sender: TObject);
|
||||
begin
|
||||
direction := False ;
|
||||
runIt := False ;
|
||||
direction := False ;
|
||||
runIt := False ;
|
||||
currentPos := Point( mouse.CursorPos.X , mouse.CursorPos.Y ) ;
|
||||
counter := 0 ;
|
||||
end;
|
||||
|
||||
|
||||
|
|
@ -82,6 +87,21 @@ begin
|
|||
procedure
|
||||
begin
|
||||
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
|
||||
mouse.CursorPos := Point( mouse.CursorPos.X + 2, mouse.CursorPos.Y + 2 )
|
||||
else
|
||||
|
|
|
|||
Loading…
Reference in a new issue