Using

function you can generate a number between 5 and 10, give it to in int variable, then you could do a while loop to press your buttons, counting your variable down, when it reaches 0 you press that special button, and generate a new number
something like this:
Code:
procedure Clickbuttons;
var
c: Integer;
begin
c := RandomRange(5, 10);
While True do
begin
// Press your Buttons here
dec(c);
if c = 0 then
begin
//Press the special button here
c := RandomRange(5, 10);
end;
end;
end;