SRL Archive - S.M.A.R.T. Questions and Answers.

SMART and keyboard Input


bg5

2012-01-09 02:31:58

Today I used first time in my script keyboard simulation and I realized that something is wrong with it. Sometimes it misses to press a key ,press 2/3 times or dont press any key at all. I run script again and it works fine ,then in next loop it has problem again.
Next thing I see is when SMART is enabled ,user keyboard input can be enabled too and you can switch it by re-minimalizing SMART:redface: It's really unpredictible.
I'm looking for stable way to simulate pressing keys ,because now my script is still crushing on it.
It's my procedure I use for pressing keys:

program new;
{$DEFINE SRL5}
{$DEFINE SMART}
{$I SRL/srl.simba}
const
ARR_UP = 38; // ASCII Arrow Keys
ARR_DOWN = 40;
ARR_LEFT = 37;
ARR_RIGHT = 39;

var

team:integer;

procedure Test (var team : integer) ;
var a, b : integer;
Key : word;

begin
b:= 2;
case team of
0: begin
b:= 3
key:= ARR_DOWN
end;
1: key:= ARR_LEFT;
2: begin
b:= 3
key:= ARR_UP
end;
3: key:= ARR_RIGHT;
end;
wait2 (500,500);
for a:=1 to b do
begin
KeyDown(key);
wait(10,random(20));
KeyUp(key);
wait(2000,random(500));
writeln(inttostr(a));
end;
end;

begin
team:=3;
Test(team);
end.