mirror of
https://github.com/moparisthebest/Simba
synced 2024-11-22 09:12:19 -05:00
Added KeyUp/KeyDown/KeyPress and SendText. Should work on Windows as well on Linux.
git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@211 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
6b38b276bc
commit
a68d70d456
@ -11,7 +11,7 @@
|
|||||||
<TargetFileExt Value=""/>
|
<TargetFileExt Value=""/>
|
||||||
<Icon Value="0"/>
|
<Icon Value="0"/>
|
||||||
<UseXPManifest Value="True"/>
|
<UseXPManifest Value="True"/>
|
||||||
<ActiveEditorIndexAtStart Value="1"/>
|
<ActiveEditorIndexAtStart Value="0"/>
|
||||||
</General>
|
</General>
|
||||||
<VersionInfo>
|
<VersionInfo>
|
||||||
<ProjectVersion Value=""/>
|
<ProjectVersion Value=""/>
|
||||||
@ -35,8 +35,8 @@
|
|||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<IsPartOfProject Value="True"/>
|
<IsPartOfProject Value="True"/>
|
||||||
<UnitName Value="project1"/>
|
<UnitName Value="project1"/>
|
||||||
<CursorPos X="1" Y="95"/>
|
<CursorPos X="23" Y="98"/>
|
||||||
<TopLine Value="73"/>
|
<TopLine Value="84"/>
|
||||||
<EditorIndex Value="0"/>
|
<EditorIndex Value="0"/>
|
||||||
<UsageCount Value="38"/>
|
<UsageCount Value="38"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
@ -90,8 +90,8 @@
|
|||||||
<Unit7>
|
<Unit7>
|
||||||
<Filename Value="../../Units/MMLCore/input.pas"/>
|
<Filename Value="../../Units/MMLCore/input.pas"/>
|
||||||
<UnitName Value="Input"/>
|
<UnitName Value="Input"/>
|
||||||
<CursorPos X="78" Y="314"/>
|
<CursorPos X="56" Y="49"/>
|
||||||
<TopLine Value="296"/>
|
<TopLine Value="24"/>
|
||||||
<EditorIndex Value="1"/>
|
<EditorIndex Value="1"/>
|
||||||
<UsageCount Value="13"/>
|
<UsageCount Value="13"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
@ -109,7 +109,7 @@
|
|||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<UnitName Value="ocr"/>
|
<UnitName Value="ocr"/>
|
||||||
<CursorPos X="11" Y="361"/>
|
<CursorPos X="11" Y="361"/>
|
||||||
<TopLine Value="37"/>
|
<TopLine Value="330"/>
|
||||||
<EditorIndex Value="3"/>
|
<EditorIndex Value="3"/>
|
||||||
<UsageCount Value="14"/>
|
<UsageCount Value="14"/>
|
||||||
<Loaded Value="True"/>
|
<Loaded Value="True"/>
|
||||||
@ -181,124 +181,124 @@
|
|||||||
</Units>
|
</Units>
|
||||||
<JumpHistory Count="30" HistoryIndex="29">
|
<JumpHistory Count="30" HistoryIndex="29">
|
||||||
<Position1>
|
<Position1>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
|
||||||
<Caret Line="483" Column="21" TopLine="459"/>
|
|
||||||
</Position1>
|
|
||||||
<Position2>
|
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="656" Column="18" TopLine="636"/>
|
<Caret Line="656" Column="18" TopLine="636"/>
|
||||||
</Position2>
|
</Position1>
|
||||||
<Position3>
|
<Position2>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="62" Column="33" TopLine="47"/>
|
<Caret Line="62" Column="33" TopLine="47"/>
|
||||||
</Position3>
|
</Position2>
|
||||||
<Position4>
|
<Position3>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="653" Column="39" TopLine="637"/>
|
<Caret Line="653" Column="39" TopLine="637"/>
|
||||||
|
</Position3>
|
||||||
|
<Position4>
|
||||||
|
<Filename Value="../../Units/MMLCore/window.pas"/>
|
||||||
|
<Caret Line="52" Column="40" TopLine="37"/>
|
||||||
</Position4>
|
</Position4>
|
||||||
<Position5>
|
<Position5>
|
||||||
<Filename Value="../../Units/MMLCore/window.pas"/>
|
<Filename Value="../../Units/MMLCore/window.pas"/>
|
||||||
<Caret Line="52" Column="40" TopLine="37"/>
|
<Caret Line="73" Column="33" TopLine="58"/>
|
||||||
</Position5>
|
</Position5>
|
||||||
<Position6>
|
<Position6>
|
||||||
<Filename Value="../../Units/MMLCore/window.pas"/>
|
<Filename Value="../../Units/MMLCore/window.pas"/>
|
||||||
<Caret Line="73" Column="33" TopLine="58"/>
|
<Caret Line="373" Column="39" TopLine="368"/>
|
||||||
</Position6>
|
</Position6>
|
||||||
<Position7>
|
<Position7>
|
||||||
<Filename Value="../../Units/MMLCore/window.pas"/>
|
|
||||||
<Caret Line="373" Column="39" TopLine="368"/>
|
|
||||||
</Position7>
|
|
||||||
<Position8>
|
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="98" Column="27" TopLine="91"/>
|
<Caret Line="98" Column="27" TopLine="91"/>
|
||||||
</Position8>
|
</Position7>
|
||||||
<Position9>
|
<Position8>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="656" Column="33" TopLine="637"/>
|
<Caret Line="656" Column="33" TopLine="637"/>
|
||||||
</Position9>
|
</Position8>
|
||||||
<Position10>
|
<Position9>
|
||||||
<Filename Value="../../Units/MMLCore/window.pas"/>
|
<Filename Value="../../Units/MMLCore/window.pas"/>
|
||||||
<Caret Line="63" Column="37" TopLine="47"/>
|
<Caret Line="63" Column="37" TopLine="47"/>
|
||||||
</Position10>
|
</Position9>
|
||||||
<Position11>
|
<Position10>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="68" Column="30" TopLine="63"/>
|
<Caret Line="68" Column="30" TopLine="63"/>
|
||||||
</Position11>
|
</Position10>
|
||||||
<Position12>
|
<Position11>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="487" Column="3" TopLine="469"/>
|
<Caret Line="487" Column="3" TopLine="469"/>
|
||||||
|
</Position11>
|
||||||
|
<Position12>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="81" Column="4" TopLine="66"/>
|
||||||
</Position12>
|
</Position12>
|
||||||
<Position13>
|
<Position13>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="81" Column="4" TopLine="66"/>
|
<Caret Line="60" Column="4" TopLine="45"/>
|
||||||
</Position13>
|
</Position13>
|
||||||
<Position14>
|
<Position14>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="60" Column="4" TopLine="45"/>
|
<Caret Line="81" Column="4" TopLine="66"/>
|
||||||
</Position14>
|
</Position14>
|
||||||
<Position15>
|
<Position15>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="81" Column="4" TopLine="66"/>
|
<Caret Line="60" Column="4" TopLine="45"/>
|
||||||
</Position15>
|
</Position15>
|
||||||
<Position16>
|
<Position16>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="60" Column="4" TopLine="45"/>
|
<Caret Line="11" Column="67" TopLine="1"/>
|
||||||
</Position16>
|
</Position16>
|
||||||
<Position17>
|
<Position17>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="11" Column="67" TopLine="1"/>
|
<Caret Line="466" Column="18" TopLine="451"/>
|
||||||
</Position17>
|
</Position17>
|
||||||
<Position18>
|
<Position18>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="466" Column="18" TopLine="451"/>
|
<Caret Line="477" Column="36" TopLine="45"/>
|
||||||
</Position18>
|
</Position18>
|
||||||
<Position19>
|
<Position19>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
||||||
<Caret Line="477" Column="36" TopLine="45"/>
|
<Caret Line="493" Column="19" TopLine="478"/>
|
||||||
</Position19>
|
</Position19>
|
||||||
<Position20>
|
<Position20>
|
||||||
<Filename Value="../../Units/MMLCore/ocr.pas"/>
|
|
||||||
<Caret Line="493" Column="19" TopLine="478"/>
|
|
||||||
</Position20>
|
|
||||||
<Position21>
|
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="98" Column="33" TopLine="91"/>
|
<Caret Line="98" Column="33" TopLine="91"/>
|
||||||
</Position21>
|
</Position20>
|
||||||
<Position22>
|
<Position21>
|
||||||
<Filename Value="../../Units/MMLCore/client.pas"/>
|
<Filename Value="../../Units/MMLCore/client.pas"/>
|
||||||
<Caret Line="33" Column="53" TopLine="31"/>
|
<Caret Line="33" Column="53" TopLine="31"/>
|
||||||
|
</Position21>
|
||||||
|
<Position22>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="12" Column="6" TopLine="1"/>
|
||||||
</Position22>
|
</Position22>
|
||||||
<Position23>
|
<Position23>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="12" Column="6" TopLine="1"/>
|
<Caret Line="41" Column="17" TopLine="23"/>
|
||||||
</Position23>
|
</Position23>
|
||||||
<Position24>
|
<Position24>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="41" Column="17" TopLine="23"/>
|
<Caret Line="96" Column="16" TopLine="75"/>
|
||||||
</Position24>
|
</Position24>
|
||||||
<Position25>
|
<Position25>
|
||||||
<Filename Value="project1.lpr"/>
|
|
||||||
<Caret Line="96" Column="16" TopLine="75"/>
|
|
||||||
</Position25>
|
|
||||||
<Position26>
|
|
||||||
<Filename Value="../../Units/MMLCore/input.pas"/>
|
<Filename Value="../../Units/MMLCore/input.pas"/>
|
||||||
<Caret Line="47" Column="65" TopLine="33"/>
|
<Caret Line="47" Column="65" TopLine="33"/>
|
||||||
|
</Position25>
|
||||||
|
<Position26>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="13" Column="25" TopLine="1"/>
|
||||||
</Position26>
|
</Position26>
|
||||||
<Position27>
|
<Position27>
|
||||||
<Filename Value="project1.lpr"/>
|
<Filename Value="project1.lpr"/>
|
||||||
<Caret Line="13" Column="25" TopLine="1"/>
|
<Caret Line="96" Column="39" TopLine="82"/>
|
||||||
</Position27>
|
</Position27>
|
||||||
<Position28>
|
<Position28>
|
||||||
<Filename Value="project1.lpr"/>
|
|
||||||
<Caret Line="96" Column="39" TopLine="82"/>
|
|
||||||
</Position28>
|
|
||||||
<Position29>
|
|
||||||
<Filename Value="../../Units/MMLCore/input.pas"/>
|
<Filename Value="../../Units/MMLCore/input.pas"/>
|
||||||
<Caret Line="47" Column="33" TopLine="33"/>
|
<Caret Line="47" Column="33" TopLine="33"/>
|
||||||
</Position29>
|
</Position28>
|
||||||
<Position30>
|
<Position29>
|
||||||
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
|
||||||
<Caret Line="477" Column="35" TopLine="469"/>
|
<Caret Line="477" Column="35" TopLine="469"/>
|
||||||
|
</Position29>
|
||||||
|
<Position30>
|
||||||
|
<Filename Value="project1.lpr"/>
|
||||||
|
<Caret Line="97" Column="12" TopLine="73"/>
|
||||||
</Position30>
|
</Position30>
|
||||||
</JumpHistory>
|
</JumpHistory>
|
||||||
</ProjectOptions>
|
</ProjectOptions>
|
||||||
@ -306,7 +306,7 @@
|
|||||||
<Version Value="8"/>
|
<Version Value="8"/>
|
||||||
<SearchPaths>
|
<SearchPaths>
|
||||||
<IncludeFiles Value="$(ProjOutDir)/"/>
|
<IncludeFiles Value="$(ProjOutDir)/"/>
|
||||||
<OtherUnitFiles Value="$(ProjPath)/../../Units/MMLCore/;$(ProjPath)/../../Units/Misc/;$(ProjPath)/../../Units/MMLAddon/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(ProjPath)/../../Units/Linux/"/>
|
<OtherUnitFiles Value="$(ProjPath)/../../Units/MMLCore/;$(ProjPath)/../../Units/Misc/;$(ProjPath)/../../Units/MMLAddon/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType)/;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/;$(ProjPath)/../../Units/Linux/;$(LazarusDir)/components/mouseandkeyinput/"/>
|
||||||
</SearchPaths>
|
</SearchPaths>
|
||||||
<CodeGeneration>
|
<CodeGeneration>
|
||||||
<Optimizations>
|
<Optimizations>
|
||||||
|
@ -93,7 +93,9 @@ begin
|
|||||||
writeln('Time: ' + FloatToStr(((GetTickCount - Time) / (i + 1))));
|
writeln('Time: ' + FloatToStr(((GetTickCount - Time) / (i + 1))));
|
||||||
writeln(C.MOCR.GetUpTextAt(0,0)); }
|
writeln(C.MOCR.GetUpTextAt(0,0)); }
|
||||||
|
|
||||||
C.MInput.ClickMouse(5,5, mouse_Left);
|
//C.MInput.ClickMouse(5,5, mouse_Left);
|
||||||
|
sleep(2000);
|
||||||
|
C.MInput.SendText('a');
|
||||||
|
|
||||||
C.Free;
|
C.Free;
|
||||||
bmp.OnDestroy:=nil;
|
bmp.OnDestroy:=nil;
|
||||||
|
42
Units/MMLAddon/PSInc/Wrappers/keyboard.inc
Normal file
42
Units/MMLAddon/PSInc/Wrappers/keyboard.inc
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
This file is part of the Mufasa Macro Library (MML)
|
||||||
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
||||||
|
|
||||||
|
MML 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 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
MML 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.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
See the file COPYING, included in this distribution,
|
||||||
|
for details about the copyright.
|
||||||
|
|
||||||
|
Keyboard.inc for the Mufasa Macro Library
|
||||||
|
}
|
||||||
|
|
||||||
|
procedure KeyDown(key: Word);
|
||||||
|
begin
|
||||||
|
CurrThread.Client.MInput.KeyDown(key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure KeyUp(key: Word);
|
||||||
|
begin
|
||||||
|
CurrThread.Client.MInput.KeyUp(key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SendKeys(s: string);
|
||||||
|
begin
|
||||||
|
CurrThread.Client.MInput.SendText(s);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure PressKey(key: Word);
|
||||||
|
begin
|
||||||
|
CurrThread.Client.MInput.PressKey(key);
|
||||||
|
end;
|
@ -97,6 +97,12 @@ Sender.AddFunction(@SetColorToleranceSpeed, 'procedure SetColorToleranceSpeed(ct
|
|||||||
Sender.AddFunction(@MoveMouse, 'procedure MoveMouse(x, y: integer);');
|
Sender.AddFunction(@MoveMouse, 'procedure MoveMouse(x, y: integer);');
|
||||||
Sender.AddFunction(@GetMousePos, 'procedure GetMousePos(var x, y: integer);');
|
Sender.AddFunction(@GetMousePos, 'procedure GetMousePos(var x, y: integer);');
|
||||||
|
|
||||||
|
{Keyboard}
|
||||||
|
Sender.AddFunction(@KeyDown, 'procedure KeyDown(key: Word);');
|
||||||
|
Sender.AddFunction(@KeyUp, 'procedure KeyUp(key: Word);');
|
||||||
|
Sender.AddFunction(@PressKey, 'procedure PressKey(key: Word);');
|
||||||
|
Sender.AddFunction(@SendKeys, 'procedure SendKeys(s: string);');
|
||||||
|
|
||||||
{ OCR}
|
{ OCR}
|
||||||
|
|
||||||
Sender.AddFunction(@rs_GetUpText, 'function rs_GetUpText: string;');
|
Sender.AddFunction(@rs_GetUpText, 'function rs_GetUpText: string;');
|
||||||
|
@ -157,7 +157,6 @@ begin
|
|||||||
SyncInfo:= TheSyncInfo;
|
SyncInfo:= TheSyncInfo;
|
||||||
SetLength(PluginsToLoad,0);
|
SetLength(PluginsToLoad,0);
|
||||||
Client := TClient.Create;
|
Client := TClient.Create;
|
||||||
|
|
||||||
PSScript := TPSScript.Create(nil);
|
PSScript := TPSScript.Create(nil);
|
||||||
PSScript.UsePreProcessor:= True;
|
PSScript.UsePreProcessor:= True;
|
||||||
PSScript.OnNeedFile := @RequireFile;
|
PSScript.OnNeedFile := @RequireFile;
|
||||||
@ -196,6 +195,7 @@ end;
|
|||||||
{$I PSInc/Wrappers/colour.inc}
|
{$I PSInc/Wrappers/colour.inc}
|
||||||
{$I PSInc/Wrappers/math.inc}
|
{$I PSInc/Wrappers/math.inc}
|
||||||
{$I PSInc/Wrappers/mouse.inc}
|
{$I PSInc/Wrappers/mouse.inc}
|
||||||
|
{$I PSInc/Wrappers/keyboard.inc}
|
||||||
{$I PSInc/Wrappers/dtm.inc}
|
{$I PSInc/Wrappers/dtm.inc}
|
||||||
{$I PSInc/Wrappers/ocr.inc}
|
{$I PSInc/Wrappers/ocr.inc}
|
||||||
|
|
||||||
|
@ -30,11 +30,13 @@ interface
|
|||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
mufasatypes, // for common mufasa types
|
mufasatypes, // for common mufasa types
|
||||||
windowutil // for mufasa window utils
|
windowutil, // for mufasa window utils
|
||||||
{$IFDEF LINUX}
|
{$IFDEF LINUX}
|
||||||
,ctypes,x, xlib,xtest{,keysym} // for X* stuff
|
ctypes,x, xlib,xtest, // for X* stuff
|
||||||
// do non silent keys with XTest.
|
// do non silent keys/mouse with XTest / TKeyInput.
|
||||||
{$ENDIF};
|
{Later on we should use xdotool, as it allows silent input}
|
||||||
|
{$ENDIF}
|
||||||
|
MouseAndKeyInput, KeyInputIntf, lclintf;
|
||||||
type
|
type
|
||||||
TMInput = class(TObject)
|
TMInput = class(TObject)
|
||||||
constructor Create(Client: TObject);
|
constructor Create(Client: TObject);
|
||||||
@ -46,8 +48,10 @@ type
|
|||||||
procedure MouseButtonActionSilent(x,y : integer; mClick: TClickType; mPress: TMousePress);
|
procedure MouseButtonActionSilent(x,y : integer; mClick: TClickType; mPress: TMousePress);
|
||||||
procedure ClickMouse(X, Y: Integer; mClick: TClickType);
|
procedure ClickMouse(X, Y: Integer; mClick: TClickType);
|
||||||
|
|
||||||
procedure KeyUp(key: Integer);
|
procedure KeyUp(key: Word);
|
||||||
procedure KeyDown(key: Integer);
|
procedure KeyDown(key: Word);
|
||||||
|
procedure PressKey(key: Word);
|
||||||
|
procedure SendText(text: string);
|
||||||
|
|
||||||
// Not used yet.
|
// Not used yet.
|
||||||
procedure SetSilent(_Silent: Boolean);
|
procedure SetSilent(_Silent: Boolean);
|
||||||
@ -63,13 +67,14 @@ type
|
|||||||
private
|
private
|
||||||
// Not used yet.
|
// Not used yet.
|
||||||
Silent: Boolean;
|
Silent: Boolean;
|
||||||
|
//KeyInput: TKeyInput;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Client{$IFDEF MSWINDOWS},windows{$ENDIF};
|
Client,{$IFDEF MSWINDOWS}windows {$ELSE}lcltype{$ENDIF};
|
||||||
|
|
||||||
{$IFDEF MSWINDOWS}
|
{$IFDEF MSWINDOWS}
|
||||||
type
|
type
|
||||||
@ -123,24 +128,52 @@ constructor TMInput.Create(Client: TObject);
|
|||||||
begin
|
begin
|
||||||
inherited Create;
|
inherited Create;
|
||||||
Self.Client := Client;
|
Self.Client := Client;
|
||||||
|
//Self.KeyInput := KeyInput;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TMInput.Destroy;
|
destructor TMInput.Destroy;
|
||||||
begin
|
begin
|
||||||
|
|
||||||
|
//Self.KeyInput := nil;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMInput.KeyUp(key: Integer);
|
procedure TMInput.KeyUp(key: Word);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
{Self.}KeyInput.Up(Key);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMInput.KeyDown(key: Integer);
|
procedure TMInput.KeyDown(key: Word);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
{Self.}KeyInput.Down(Key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMInput.PressKey(key: Word);
|
||||||
|
begin
|
||||||
|
Self.KeyDown(key);
|
||||||
|
Self.KeyUp(key);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ No using VkKeyScan }
|
||||||
|
function GetSimpleKeyCode(c: char): word;
|
||||||
|
|
||||||
|
begin
|
||||||
|
//result := ord(UpCase(c));
|
||||||
|
c := lowerCase(c);
|
||||||
|
if ((c >= 'a') and (c <= 'z')) then
|
||||||
|
Exit(VK_A + (Byte(c) - 97));
|
||||||
|
Raise Exception.CreateFMT('GetSimpleKeyCode - char is not in A..z',[]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TMInput.SendText(text: string);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
begin
|
||||||
|
for i := 1 to length(text) do
|
||||||
|
Self.PressKey(GetSimpleKeyCode(text[i]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMInput.GetMousePos(var X, Y: Integer);
|
procedure TMInput.GetMousePos(var X, Y: Integer);
|
||||||
|
Loading…
Reference in New Issue
Block a user