![]() |
Touch-It Virtual Keyboard | Version 4.9.2 |
| Automation |
|
This topic demonstrates how to drive Touch-It using automation. Connecting to the automation serverIf Touch-It is not running when this function is called, it will be started automatically and closed when your application ends.
Interface
var
//Server object implementation uses ComObj; procedure TForm1.FormCreate(Sender :TObject); begin TIServer := CreateOleObject('TouchIt.Automation'); end;Disconnecting from the serverSimply:
procedure TForm1.FormClose(Sender :TObject);
begin
TIServer.Hide; Minimize and restore all keyboardsDelphi example of how to show and hide keyboards.procedure Show; procedure Hide;
procedure Button1Click(Sender :TObject);
begin
//Restore procedure Button2Click(Sender :TObject); begin
//Minimize Open a keyboardDelphi example of how to open a keyboard. It's position is based on the setup. See also OpenAs below.procedure Open (aFileName: OleVariant; aMonitor: Integer);
procedure Button1Click(Sender :TObject);
begin
//Open the templatekb_compact001.kbl using the file name on 1st monitor procedure Button2Click(Sender :TObject); begin
//Open the template kb_medium002.kbl using its ID on 2nd monitor Close a keyboardDelphi example of how to close a keyboard.procedure Close (aFileName: OleVariant; aMonitor: Integer);
procedure Button3Click(Sender :TObject);
begin
//Close the template kb_compact001.kbl using the file name on any monitor procedure Button4Click(Sender :TObject); begin
//Close the template kb_medium002.kbl using its ID on 1st monitor Taskbar or floating keyboard (Open a keyboard)Delphi example of how to either select a taskbar or a floating keyboard using the OpenAs method. If the keyboard is not yet visible, OpenAs opens it before setting its position.procedure OpenAs (aFileName: OleVariant; aPos, aMonitor: Integer);
procedure Button1Click(Sender :TObject);
begin
//Open the templatekb_compact001.kbl using the file name, as a floating keyboard on 2nd monitor procedure Button2Click(Sender :TObject); begin
//Open the template kb_medium002.kbl using its ID, as a bottom appbar on the 1st monitor Reload keyboards templatesIn some circonstances, like modifying the touchit.ini file, it is necessary to restart keyboards for the modifications to take effect.procedure Reload;
procedure SpinEditChange(Sender :TObject);
In some circumstances, the docked templates may become invisible. In this case it is better to close and reopen Touch-It as follow:
begin TIServer.Reload; end;
procedure Button2Click(Sender :TObject);
begin
SendMessage(FindWindow(nil, PChar('Touch-It Keyboard'), WM_CLOSE, 0, 0); Floating keyboard positionDelphi example of how to set the keyboard on screen position.1. SetPossets absolute keyboard position.procedure SetPos (aLeft, aTop: integer);
procedure SpinEditChange(Sender :TObject);
begin TIServer.SetPos(SpinEdit1.Value, SpinEdit2.Value); end;2. SetBoundsPossets keyboard position above or beneath an edit control without hidding it.procedure SetBoundsPos (aLeft, aTop, aRight, aBottom: integer);
procedure Button2Click(Sender :TObject);
begin
//ClientToScreen retreives screen coordinates of the control TIServer.SetBoundsPos(x, y, x +Width, y +Height); end;Optimize painting process (Layered only)Painting can be rather long when the Windows style is set to Layered (See Setup\Advance). To optimize the process when a few lights states or texts must change, Touch-It implements procedures to lock the keyboards update and to flush all modification at once.A Lock counter is used. Updating is performed only when the couter equals 0. Thus it is possible to have recursive call to the Lock/Unlock procedures. procedure Lock; Keep the keyboard from updating, increase the lock counter. procedure Unlock; Decrease the counter and update if the counter equals 0. procedure ResetLock; In case of exceptions in your application, call ResetLock from your exception handler to clear the lock counter and update if needed. You don't need to call Lock/Unlock if you use LightOne or LightRange as they already implement these calls. |
| Copyright © 2011 Chessware SA |