Selaa lähdekoodia

merge Delphi and FPC version

Juliette ELSASS 9 kuukautta sitten
vanhempi
sitoutus
5cafc74fa2

+ 0 - 91
lcl/KeyInputIntf.pas

@@ -1,91 +0,0 @@
-{ KeyInputIntf
-
-  Copyright (C) 2008 Tom Gregorovic
-
-  This source is free software; you can redistribute it and/or modify it under the terms of the
-  GNU General Public License as published by the Free Software Foundation; either version 2 of the
-  License, or (at your option) any later version.
-
-  This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  A copy of the GNU General Public License is available on the World Wide Web at
-  <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-unit KeyInputIntf;
-
-
-interface
-
-uses
-  Classes, SysUtils, Types, windows, messages, Forms;
-
-type
-  { TKeyInput }
-
-  TKeyInput = class
-  protected
-    procedure DoDown(Key: Word); dynamic; abstract;
-    procedure DoUp(Key: Word); dynamic; abstract;
-  public
-    procedure Down(Key: Word);
-    procedure Up(Key: Word);
-
-    procedure Press(Key: Word);  overload;
-    procedure Press(StringValue : String);  overload;
-
-    procedure Apply(Shift: TShiftState);
-    procedure Unapply(Shift: TShiftState);
-  end;
-
-implementation
-
-{ TKeyInput }
-
-procedure TKeyInput.Down(Key: Word);
-begin  DoDown(Key);
-  Application.ProcessMessages;
-end;
-
-procedure TKeyInput.Up(Key: Word);
-begin
-  DoUp(Key);
-  Application.ProcessMessages;
-end;
-
-procedure TKeyInput.Press(Key: Word);
-begin
-  Down(Key);
-  Up(Key);
-end;
-
-procedure TKeyInput.Press(StringValue: String);
-var
-  i : Integer;
-begin
-  i :=1;
-  while (i <= Length(StringValue)) do
-    begin
-      Press(Ord(StringValue[i]));
-      Inc(i);
-    end;
-end;
-
-procedure TKeyInput.Apply(Shift: TShiftState);
-begin
-  if ssCtrl in Shift then Down(VK_CONTROL);
-  if ssAlt in Shift then Down(VK_MENU);
-  if ssShift in Shift then Down(VK_SHIFT);
-end;
-
-procedure TKeyInput.Unapply(Shift: TShiftState);
-begin
-  if ssShift in Shift then Up(VK_SHIFT);
-  if ssCtrl in Shift then Up(VK_CONTROL);
-  if ssAlt in Shift then Up(VK_MENU);
-end;
-
-end.
-

+ 0 - 50
lcl/MouseAndKeyInput.pas

@@ -1,50 +0,0 @@
-{ MouseAndKeyInput
-
-  Copyright (C) 2008 Tom Gregorovic
-
-  This source is free software; you can redistribute it and/or modify it under the terms of the
-  GNU General Public License as published by the Free Software Foundation; either version 2 of the
-  License, or (at your option) any later version.
-
-  This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  A copy of the GNU General Public License is available on the World Wide Web at
-  <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-unit MouseAndKeyInput;
-
-interface
-
-uses
-  MouseInputIntf,
-  KeyInputIntf,
-  WinMouseInput,
-  WinKeyInput,
-  Classes, SysUtils;
-
-var
-  MouseInput: TMouseInput;
-  KeyInput: TKeyInput;
-
-implementation
-
-
-
-initialization
-
-  // Create platform specific object for mouse input
-  MouseInput := InitializeMouseInput;
-
-  // Create platform specific object for key input
-  KeyInput := InitializeKeyInput;
-
-finalization
-
-  FreeAndNil(MouseInput);
-  FreeAndNil(KeyInput);
-
-
-end.

+ 0 - 283
lcl/MouseInputIntf.pas

@@ -1,283 +0,0 @@
-{ MouseInputIntf
-
-  Copyright (C) 2008 Tom Gregorovic
-
-  This source is free software; you can redistribute it and/or modify it under the terms of the
-  GNU General Public License as published by the Free Software Foundation; either version 2 of the
-  License, or (at your option) any later version.
-
-  This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  A copy of the GNU General Public License is available on the World Wide Web at
-  <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-unit MouseInputIntf;
-
-interface
-
-uses
-  Classes, SysUtils, Types, windows, Controls, Forms;
-
-type
-  { TMouseInput }
-
-  TMouseInput = class
-  protected
-    procedure DoDown(Button: TMouseButton); dynamic; abstract;
-    procedure DoMove(ScreenX, ScreenY: Integer); dynamic; abstract;
-    procedure DoUp(Button: TMouseButton); dynamic; abstract;
-    procedure DoScrollUp; dynamic; abstract;
-    procedure DoScrollDown; dynamic; abstract;
-  public
-    procedure Down(Button: TMouseButton; Shift: TShiftState); overload;
-    procedure Down(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure Down(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-
-    procedure Move(Shift: TShiftState; Control: TControl; X, Y: Integer; Duration: Integer = 0); overload;
-    procedure MoveBy(Shift: TShiftState; DX, DY: Integer; Duration: Integer = 0); overload;
-    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer; Duration: Integer); overload;
-    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-
-    procedure ScrollUp(Shift: TShiftState); overload;
-    procedure ScrollUp(Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure ScrollUp(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-    procedure ScrollDown(Shift: TShiftState); overload;
-    procedure ScrollDown(Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure ScrollDown(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-
-    procedure Up(Button: TMouseButton; Shift: TShiftState); overload;
-    procedure Up(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure Up(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-
-    procedure Click(Button: TMouseButton; Shift: TShiftState); overload;
-    procedure Click(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure Click(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState); overload;
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
-  end;
-
-implementation
-
-uses
-  Math, MouseAndKeyInput;
-
-{ TMouseInput }
-
-procedure TMouseInput.Down(Button: TMouseButton; Shift: TShiftState);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoDown(Button);
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-  Application.ProcessMessages;
-end;
-
-procedure TMouseInput.Down(Button: TMouseButton; Shift: TShiftState;
-  Control: TControl; X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  Down(Button, Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.Down(Button: TMouseButton; Shift: TShiftState;
-  ScreenX, ScreenY: Integer);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoMove(ScreenX, ScreenY);
-    DoDown(Button);
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-end;
-
-procedure TMouseInput.Move(Shift: TShiftState; Control: TControl; X, Y: Integer; Duration: Integer = 0);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  Move(Shift, P.X, P.Y, Duration);
-end;
-
-procedure TMouseInput.MoveBy(Shift: TShiftState; DX, DY: Integer; Duration: Integer = 0);
-var
-  P: TPoint;
-begin
-  P := Mouse.CursorPos;
-  Move(Shift, P.X + DX, P.Y + DY, Duration);
-end;
-
-procedure TMouseInput.Move(Shift: TShiftState; ScreenX, ScreenY: Integer; Duration: Integer);
-const
-  Interval = 20; //ms
-var
-  TimeStep: Integer;
-  X, Y: Integer;
-  Start: TPoint;
-  S: LongWord;
-begin
-  Start := Mouse.CursorPos;
-
-  while Duration > 0 do
-  begin
-    TimeStep := Min(Interval, Duration);
-
-    S := {%H-}Windows.GetTickCount;
-    while {%H-}Windows.GetTickCount - S < TimeStep do Application.ProcessMessages;
-
-    X := Start.X + ((ScreenX - Start.X) * TimeStep) div Duration;
-    Y := Start.Y + ((ScreenY - Start.Y) * TimeStep) div Duration;
-    Move(Shift, X, Y);
-
-    Duration := Duration - TimeStep;
-    Start := Point(X, Y);
-  end;
-
-  Move(Shift, ScreenX, ScreenY);
-end;
-
-procedure TMouseInput.Move(Shift: TShiftState; ScreenX, ScreenY: Integer);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoMove(ScreenX, ScreenY);
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-  Application.ProcessMessages;
-end;
-
-procedure TMouseInput.ScrollUp(Shift: TShiftState);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoScrollUp;
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-  Application.ProcessMessages;
-end;
-
-procedure TMouseInput.ScrollUp(Shift: TShiftState; Control: TControl;
-  X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  ScrollUp(Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.ScrollUp(Shift: TShiftState; ScreenX, ScreenY: Integer);
-begin
-  Move(Shift, ScreenX, ScreenY);
-  ScrollUp(Shift);
-end;
-
-procedure TMouseInput.ScrollDown(Shift: TShiftState);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoScrollDown;
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-  Application.ProcessMessages;
-end;
-
-procedure TMouseInput.ScrollDown(Shift: TShiftState; Control: TControl;
-  X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  ScrollDown(Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.ScrollDown(Shift: TShiftState; ScreenX, ScreenY: Integer);
-begin
-  Move(Shift, ScreenX, ScreenY);
-  ScrollDown(Shift);
-end;
-
-procedure TMouseInput.Up(Button: TMouseButton; Shift: TShiftState);
-begin
-  KeyInput.Apply(Shift);
-  try
-    DoUp(Button);
-  finally
-    KeyInput.Unapply(Shift);
-  end;
-  Application.ProcessMessages;
-end;
-
-procedure TMouseInput.Up(Button: TMouseButton; Shift: TShiftState;
-  Control: TControl; X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  Up(Button, Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.Up(Button: TMouseButton; Shift: TShiftState;
-  ScreenX, ScreenY: Integer);
-begin
-  Move(Shift, ScreenX, ScreenY);
-  Up(Button, Shift);
-end;
-
-procedure TMouseInput.Click(Button: TMouseButton; Shift: TShiftState);
-begin
-  Down(Button, Shift);
-  Up(Button, Shift);
-end;
-
-procedure TMouseInput.Click(Button: TMouseButton; Shift: TShiftState;
-  Control: TControl; X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  Click(Button, Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.Click(Button: TMouseButton; Shift: TShiftState;
-  ScreenX, ScreenY: Integer);
-begin
-  Move(Shift, ScreenX, ScreenY);
-  Click(Button, Shift);
-end;
-
-procedure TMouseInput.DblClick(Button: TMouseButton; Shift: TShiftState);
-begin
-  Click(Button, Shift);
-  Click(Button, Shift);
-end;
-
-procedure TMouseInput.DblClick(Button: TMouseButton; Shift: TShiftState;
-  Control: TControl; X, Y: Integer);
-var
-  P: TPoint;
-begin
-  P := Control.ClientToScreen(Point(X, Y));
-  DblClick(Button, Shift, P.X, P.Y);
-end;
-
-procedure TMouseInput.DblClick(Button: TMouseButton; Shift: TShiftState;
-  ScreenX, ScreenY: Integer);
-begin
-  Move(Shift, ScreenX, ScreenY);
-  DblClick(Button, Shift);
-end;
-
-end.
-

+ 0 - 71
lcl/WinKeyInput.pas

@@ -1,71 +0,0 @@
-{ WinKeyInput
-
-  Copyright (C) 2008 Tom Gregorovic
-
-  This source is free software; you can redistribute it and/or modify it under the terms of the
-  GNU General Public License as published by the Free Software Foundation; either version 2 of the
-  License, or (at your option) any later version.
-
-  This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  A copy of the GNU General Public License is available on the World Wide Web at
-  <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-unit WinKeyInput;
-
-interface
-
-uses
-  Classes, SysUtils, Controls, Forms,
-  Windows, //JwaWinUser,
-  KeyInputIntf;
-
-type
-
-  { TWinKeyInput }
-
-  TWinKeyInput = class(TKeyInput)
-  protected
-    procedure DoDown(Key: Word); override;
-    procedure DoUp(Key: Word); override;
-  end;
-
-function InitializeKeyInput: TKeyInput;
-
-implementation
-
-function InitializeKeyInput: TKeyInput;
-begin
-  Result := TWinKeyInput.Create;
-end;
-
-procedure SendKeyInput(Flag: DWORD; Key: Word);
-var
-  Input: TInput;
-begin
-  FillChar({%H-}Input, SizeOf(Input), 0);
-  Input.Itype := INPUT_KEYBOARD;
-  Input.ki.dwFlags := Flag;
-  Input.ki.wVk := Key;
-
-  SendInput(1, Input, SizeOf(Input));
-end;
-
-
-{ TWinKeyInput }
-
-procedure TWinKeyInput.DoDown(Key: Word);
-begin
-  SendKeyInput(0, Key);
-end;
-
-procedure TWinKeyInput.DoUp(Key: Word);
-begin
-  SendKeyInput(KEYEVENTF_KEYUP, Key);
-end;
-
-end.
-

+ 0 - 126
lcl/WinMouseInput.pas

@@ -1,126 +0,0 @@
-{ WinMouseInput
-
-  Copyright (C) 2008 Tom Gregorovic
-
-  This source is free software; you can redistribute it and/or modify it under the terms of the
-  GNU General Public License as published by the Free Software Foundation; either version 2 of the
-  License, or (at your option) any later version.
-
-  This code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  A copy of the GNU General Public License is available on the World Wide Web at
-  <http://www.gnu.org/copyleft/gpl.html>. You can also obtain it by writing to the Free Software
-  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-}
-unit WinMouseInput;
-
-
-interface
-
-uses
-  Classes, SysUtils, Controls, Forms,
-  Windows, //JwaWinUser,
-  MouseInputIntf;
-
-type
-
-  { TWinMouseInput }
-
-  TWinMouseInput = class(TMouseInput)
-  protected
-    procedure DoDown(Button: TMouseButton); override;
-    procedure DoMove(ScreenX, ScreenY: Integer); override;
-    procedure DoUp(Button: TMouseButton); override;
-    procedure DoScrollUp; override;
-    procedure DoScrollDown; override;
-  end;
-
-function InitializeMouseInput: TMouseInput;
-
-implementation
-
-function InitializeMouseInput: TMouseInput;
-begin
-  Result := TWinMouseInput.Create;
-end;
-
-procedure SendMouseInput(Flag: DWORD; MouseData: DWORD = 0); overload;
-var
-  Input: TInput;
-begin
-{$IFDEF VER2_6}
-  FillChar(Input, SizeOf(Input), 0);
-{$ELSE}
-  Input := Default(TInput);
-{$ENDIF}
-  Input.mi.mouseData := MouseData;
-  Input.Itype := INPUT_MOUSE;
-  Input.mi.dwFlags := Flag;
-
-  SendInput(1, Input, SizeOf(Input));
-end;
-
-procedure SendMouseInput(Flag: DWORD; X, Y: Integer); overload;
-var
-  Input: TInput;
-begin
-{$IFDEF VER2_6}
-  FillChar(Input, SizeOf(Input), 0);
-{$ELSE}
-  Input := Default(TInput);
-{$ENDIF}
-  Input.Itype := INPUT_MOUSE;
-  Input.mi.dx := MulDiv(X, 65535, Screen.Width - 1); // screen horizontal coordinates: 0 - 65535
-  Input.mi.dy := MulDiv(Y, 65535, Screen.Height - 1); // screen vertical coordinates: 0 - 65535
-  Input.mi.dwFlags := Flag or MOUSEEVENTF_ABSOLUTE;
-
-  SendInput(1, Input, SizeOf(Input));
-end;
-
-{ TWinMouseInput }
-
-procedure TWinMouseInput.DoDown(Button: TMouseButton);
-var
-  Flag: DWORD;
-begin
-  case Button of
-    mbRight: Flag := MOUSEEVENTF_RIGHTDOWN;
-    mbMiddle: Flag := MOUSEEVENTF_MIDDLEDOWN;
-  else
-    Flag := MOUSEEVENTF_LEFTDOWN;
-  end;
-  SendMouseInput(Flag);
-end;
-
-procedure TWinMouseInput.DoMove(ScreenX, ScreenY: Integer);
-begin
-  SendMouseInput(MOUSEEVENTF_MOVE, ScreenX, ScreenY);
-end;
-
-procedure TWinMouseInput.DoUp(Button: TMouseButton);
-var
-  Flag: DWORD;
-begin
-  case Button of
-    mbRight: Flag := MOUSEEVENTF_RIGHTUP;
-    mbMiddle: Flag := MOUSEEVENTF_MIDDLEUP;
-  else
-    Flag := MOUSEEVENTF_LEFTUP;
-  end;
-  SendMouseInput(Flag);
-end;
-
-procedure TWinMouseInput.DoScrollUp;
-begin
-  SendMouseInput(MOUSEEVENTF_WHEEL, WHEEL_DELTA);
-end;
-
-procedure TWinMouseInput.DoScrollDown;
-begin
-  SendMouseInput(MOUSEEVENTF_WHEEL, DWORD(-WHEEL_DELTA));
-end;
-
-end.
-

+ 7 - 9
mouseandkeyinput/keyinputintf.pas

@@ -16,13 +16,13 @@
 }
 }
 unit KeyInputIntf;
 unit KeyInputIntf;
 
 
-{$mode objfpc}{$H+}
+{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
 
 
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, Forms;
-  
+  Classes, SysUtils, {$IFDEF FPC}LCLType,{$ELSE}Types, windows, messages,{$ENDIF} Forms;
+
 type
 type
   { TKeyInput }
   { TKeyInput }
 
 
@@ -33,18 +33,16 @@ type
   public
   public
     procedure Down(Key: Word);
     procedure Down(Key: Word);
     procedure Up(Key: Word);
     procedure Up(Key: Word);
-    
-    procedure Press(Key: Word);
-    procedure Press(StringValue : String);
-    
+
+    procedure Press(Key: Word);  overload;
+    procedure Press(StringValue : String);  overload;
+
     procedure Apply(Shift: TShiftState);
     procedure Apply(Shift: TShiftState);
     procedure Unapply(Shift: TShiftState);
     procedure Unapply(Shift: TShiftState);
   end;
   end;
 
 
 implementation
 implementation
 
 
-uses LCLType;
-
 { TKeyInput }
 { TKeyInput }
 
 
 procedure TKeyInput.Down(Key: Word);
 procedure TKeyInput.Down(Key: Word);

+ 17 - 12
mouseandkeyinput/mouseandkeyinput.pas

@@ -21,18 +21,23 @@ interface
 uses
 uses
   MouseInputIntf,
   MouseInputIntf,
   KeyInputIntf,
   KeyInputIntf,
-  {$IFDEF WINDOWS}
-  WinMouseInput,
-  WinKeyInput,
-  {$ENDIF}
-  {$IFDEF UNIX}
-    {$IFDEF LCLcarbon}
-    CarbonMouseInput,
-    CarbonKeyInput,
-    {$ELSE}
-    XMouseInput,
-    XKeyInput,
-    {$ENDIF}
+  {$IFDEF FPC}
+	  {$IFDEF WINDOWS}
+	  WinMouseInput,
+	  WinKeyInput,
+	  {$ENDIF}
+	  {$IFDEF UNIX}
+	    {$IFDEF LCLcarbon}
+	    CarbonMouseInput,
+	    CarbonKeyInput,
+	    {$ELSE}
+	    XMouseInput,
+	    XKeyInput,
+	    {$ENDIF}
+	  {$ENDIF}
+  {$ELSE}
+	  WinMouseInput,
+	  WinKeyInput,  
   {$ENDIF}
   {$ENDIF}
   Classes, SysUtils;
   Classes, SysUtils;
 
 

+ 35 - 36
mouseandkeyinput/mouseinputintf.pas

@@ -16,13 +16,12 @@
 }
 }
 unit MouseInputIntf;
 unit MouseInputIntf;
 
 
-{$mode objfpc}{$H+}
-
+{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
 interface
 interface
 
 
 uses
 uses
-  Classes, SysUtils, Controls, Forms;
-  
+  Classes, SysUtils, {$IFNDEF FPC}Types, windows,{$ENDIF} Controls, Forms;
+
 type
 type
   { TMouseInput }
   { TMouseInput }
 
 
@@ -34,33 +33,33 @@ type
     procedure DoScrollUp; dynamic; abstract;
     procedure DoScrollUp; dynamic; abstract;
     procedure DoScrollDown; dynamic; abstract;
     procedure DoScrollDown; dynamic; abstract;
   public
   public
-    procedure Down(Button: TMouseButton; Shift: TShiftState);
-    procedure Down(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure Down(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer);
-    
-    procedure Move(Shift: TShiftState; Control: TControl; X, Y: Integer; Duration: Integer = 0);
-    procedure MoveBy(Shift: TShiftState; DX, DY: Integer; Duration: Integer = 0);
-    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer; Duration: Integer);
-    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer);
-
-    procedure ScrollUp(Shift: TShiftState);
-    procedure ScrollUp(Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure ScrollUp(Shift: TShiftState; ScreenX, ScreenY: Integer);
-    procedure ScrollDown(Shift: TShiftState);
-    procedure ScrollDown(Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure ScrollDown(Shift: TShiftState; ScreenX, ScreenY: Integer);
-
-    procedure Up(Button: TMouseButton; Shift: TShiftState);
-    procedure Up(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure Up(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer);
-    
-    procedure Click(Button: TMouseButton; Shift: TShiftState);
-    procedure Click(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure Click(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer);
-    
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState);
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer);
-    procedure DblClick(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer);
+    procedure Down(Button: TMouseButton; Shift: TShiftState); overload;
+    procedure Down(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure Down(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+
+    procedure Move(Shift: TShiftState; Control: TControl; X, Y: Integer; Duration: Integer = 0); overload;
+    procedure MoveBy(Shift: TShiftState; DX, DY: Integer; Duration: Integer = 0); overload;
+    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer; Duration: Integer); overload;
+    procedure Move(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+
+    procedure ScrollUp(Shift: TShiftState); overload;
+    procedure ScrollUp(Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure ScrollUp(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+    procedure ScrollDown(Shift: TShiftState); overload;
+    procedure ScrollDown(Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure ScrollDown(Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+
+    procedure Up(Button: TMouseButton; Shift: TShiftState); overload;
+    procedure Up(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure Up(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+
+    procedure Click(Button: TMouseButton; Shift: TShiftState); overload;
+    procedure Click(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure Click(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
+
+    procedure DblClick(Button: TMouseButton; Shift: TShiftState); overload;
+    procedure DblClick(Button: TMouseButton; Shift: TShiftState; Control: TControl; X, Y: Integer); overload;
+    procedure DblClick(Button: TMouseButton; Shift: TShiftState; ScreenX, ScreenY: Integer); overload;
   end;
   end;
 
 
 implementation
 implementation
@@ -128,14 +127,14 @@ var
   S: LongWord;
   S: LongWord;
 begin
 begin
   Start := Mouse.CursorPos;
   Start := Mouse.CursorPos;
-  
+
   while Duration > 0 do
   while Duration > 0 do
   begin
   begin
     TimeStep := Min(Interval, Duration);
     TimeStep := Min(Interval, Duration);
 
 
-    S := {%H-}GetTickCount;
-    while {%H-}GetTickCount - S < TimeStep do Application.ProcessMessages;
-    
+    S := {%H-}{$IFNDEF FPC}Windows.{$ENDIF}GetTickCount;
+    while {%H-}{$IFNDEF FPC}Windows.{$ENDIF}GetTickCount - S < TimeStep do Application.ProcessMessages;
+
     X := Start.X + ((ScreenX - Start.X) * TimeStep) div Duration;
     X := Start.X + ((ScreenX - Start.X) * TimeStep) div Duration;
     Y := Start.Y + ((ScreenY - Start.Y) * TimeStep) div Duration;
     Y := Start.Y + ((ScreenY - Start.Y) * TimeStep) div Duration;
     Move(Shift, X, Y);
     Move(Shift, X, Y);
@@ -143,7 +142,7 @@ begin
     Duration := Duration - TimeStep;
     Duration := Duration - TimeStep;
     Start := Point(X, Y);
     Start := Point(X, Y);
   end;
   end;
-  
+
   Move(Shift, ScreenX, ScreenY);
   Move(Shift, ScreenX, ScreenY);
 end;
 end;
 
 

+ 6 - 7
mouseandkeyinput/winkeyinput.pas

@@ -16,15 +16,14 @@
 }
 }
 unit WinKeyInput;
 unit WinKeyInput;
 
 
-{$mode objfpc}{$H+}
-
+{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
 interface
 interface
 
 
 uses
 uses
   Classes, SysUtils, Controls, Forms,
   Classes, SysUtils, Controls, Forms,
-  Windows, JwaWinUser,
+  Windows, {$IFDEF FPC}JwaWinUser,{$ENDIF}
   KeyInputIntf;
   KeyInputIntf;
-  
+
 type
 type
 
 
   { TWinKeyInput }
   { TWinKeyInput }
@@ -34,7 +33,7 @@ type
     procedure DoDown(Key: Word); override;
     procedure DoDown(Key: Word); override;
     procedure DoUp(Key: Word); override;
     procedure DoUp(Key: Word); override;
   end;
   end;
-  
+
 function InitializeKeyInput: TKeyInput;
 function InitializeKeyInput: TKeyInput;
 
 
 implementation
 implementation
@@ -49,11 +48,11 @@ var
   Input: TInput;
   Input: TInput;
 begin
 begin
   FillChar({%H-}Input, SizeOf(Input), 0);
   FillChar({%H-}Input, SizeOf(Input), 0);
-  Input.type_ := INPUT_KEYBOARD;
+  Input.{$IFDEF FPC}type_{$ELSE}Itype{$ENDIF} := INPUT_KEYBOARD;
   Input.ki.dwFlags := Flag;
   Input.ki.dwFlags := Flag;
   Input.ki.wVk := Key;
   Input.ki.wVk := Key;
 
 
-  SendInput(1, @Input, SizeOf(Input));
+  SendInput(1, {$IFDEF FPC}@{$ENDIF}Input, SizeOf(Input));
 end;
 end;
 
 
 
 

+ 10 - 10
mouseandkeyinput/winmouseinput.pas

@@ -16,15 +16,15 @@
 }
 }
 unit WinMouseInput;
 unit WinMouseInput;
 
 
-{$mode objfpc}{$H+}
+{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
 
 
 interface
 interface
 
 
 uses
 uses
   Classes, SysUtils, Controls, Forms,
   Classes, SysUtils, Controls, Forms,
-  Windows, JwaWinUser,
+  Windows, {$IFDEF FPC}JwaWinUser,{$ENDIF}
   MouseInputIntf;
   MouseInputIntf;
-  
+
 type
 type
 
 
   { TWinMouseInput }
   { TWinMouseInput }
@@ -37,7 +37,7 @@ type
     procedure DoScrollUp; override;
     procedure DoScrollUp; override;
     procedure DoScrollDown; override;
     procedure DoScrollDown; override;
   end;
   end;
-  
+
 function InitializeMouseInput: TMouseInput;
 function InitializeMouseInput: TMouseInput;
 
 
 implementation
 implementation
@@ -47,7 +47,7 @@ begin
   Result := TWinMouseInput.Create;
   Result := TWinMouseInput.Create;
 end;
 end;
 
 
-procedure SendMouseInput(Flag: DWORD; MouseData: DWORD = 0);
+procedure SendMouseInput(Flag: DWORD; MouseData: DWORD = 0); overload;
 var
 var
   Input: TInput;
   Input: TInput;
 begin
 begin
@@ -57,13 +57,13 @@ begin
   Input := Default(TInput);
   Input := Default(TInput);
 {$ENDIF}
 {$ENDIF}
   Input.mi.mouseData := MouseData;
   Input.mi.mouseData := MouseData;
-  Input.type_ := INPUT_MOUSE;
+  Input.{$IFDEF FPC}type_{$ELSE}Itype{$ENDIF} := INPUT_MOUSE;
   Input.mi.dwFlags := Flag;
   Input.mi.dwFlags := Flag;
 
 
-  SendInput(1, @Input, SizeOf(Input));
+  SendInput(1, {$IFDEF FPC}@{$ENDIF}Input, SizeOf(Input));
 end;
 end;
 
 
-procedure SendMouseInput(Flag: DWORD; X, Y: Integer);
+procedure SendMouseInput(Flag: DWORD; X, Y: Integer); overload;
 var
 var
   Input: TInput;
   Input: TInput;
 begin
 begin
@@ -72,12 +72,12 @@ begin
 {$ELSE}
 {$ELSE}
   Input := Default(TInput);
   Input := Default(TInput);
 {$ENDIF}
 {$ENDIF}
-  Input.type_ := INPUT_MOUSE;
+  Input.{$IFDEF FPC}type_{$ELSE}Itype{$ENDIF} := INPUT_MOUSE;
   Input.mi.dx := MulDiv(X, 65535, Screen.Width - 1); // screen horizontal coordinates: 0 - 65535
   Input.mi.dx := MulDiv(X, 65535, Screen.Width - 1); // screen horizontal coordinates: 0 - 65535
   Input.mi.dy := MulDiv(Y, 65535, Screen.Height - 1); // screen vertical coordinates: 0 - 65535
   Input.mi.dy := MulDiv(Y, 65535, Screen.Height - 1); // screen vertical coordinates: 0 - 65535
   Input.mi.dwFlags := Flag or MOUSEEVENTF_ABSOLUTE;
   Input.mi.dwFlags := Flag or MOUSEEVENTF_ABSOLUTE;
 
 
-  SendInput(1, @Input, SizeOf(Input));
+  SendInput(1, {$IFDEF FPC}@{$ENDIF}Input, SizeOf(Input));
 end;
 end;
 
 
 { TWinMouseInput }
 { TWinMouseInput }