SRL Archive - OSR Help

Really Quick Question!


goodlife

2012-06-05 16:58:48

Hey guys, I am trying to write some code and I am just wondering how do you write code to use the left and right arrow keys in pascal? I want to use the arrow keys all the way on the right of the keyboard. (left-#4 and right-#6). I just need really simple code using readkey and all that ( I was thinking maybe a case statement somewhere in there?)..

Le Jingle

2012-06-05 17:00:52

Do you mean like this?

Procedure HandleArrowKeys;
Begin
KeyDown(VK_Left);
Wait(100);
KeyUp(VK_Left);
End;

This will hold down the left arrow key for 100 ms and then release the key. You can also use VK_right, VK_up, and VK_down

Sex

2012-06-05 17:05:33

VK_NUMPAD4 // (Right)
VK_NUMPAD2 // (Down)
VK_NUMPAD6 // (Left)
VK_NUMPAD8 // (Up)

goodlife

2012-06-05 18:38:43

Actually, I know the simba commands are different…do you think you could show me the regular commands?

Runaway

2012-06-05 18:43:52

I'm fairly certain the ones Sex posted are universal.

Edit: Hex values are 62, 64, 66 and 68, respectively.

goodlife

2012-06-05 18:48:58

No I meant the way I could actually get it to work in a program..

Runaway

2012-06-05 18:49:33

http://wiki.freepascal.org/LCL_Key_Handling

Le Jingle

2012-06-05 18:51:05


Program New;
{$DEFINE SRL5}
{$i SRL/srl.simba}

Procedure ToggleScreenAngle(TotalKeys, WaitPeriod: Integer);
Var
clicks, i: Integer;
Begin
Repeat
Begin
i:= Random(4);
Case (i) Of
1: begin
KeyDown(VK_Left);
Wait((WaitPeriod)+random(50));
KeyUp(VK_Left);
IncEx(clicks, 1);
End;
2: Begin
KeyDown(VK_Right);
Wait((WaitPeriod)+random(50));
KeyUp(VK_Right);
IncEx(clicks, 1);
End;
3: Begin
KeyDown(40);
Wait((WaitPeriod)+random(50));
KeyUp(40);
IncEx(clicks, 1);
End;
4: Begin
KeyDown(38);
Wait((WaitPeriod)+random(50));
KeyUp(38);
IncEx(clicks, 1);
End;
end;
End;
Until (clicks = TotalKeys)
If (clicks = TotalKeys) Then
Wait(100+Random(50));
MakeCompass('W');
SetAngle(SRL_ANGLE_HIGH);
End;

Begin
SetupSRL;
ToggleScreenAngle(27, 250);
End.


E: ^ That was a little fun thing I made, however I think this is easier to understand;


Program New;
{$DEFINE SRL5}
{$i SRL/srl.simba}

Procedure MoveArrowKeys;
Begin
KeyDown(VK_Left);
Wait(100);
KeyUp(VK_Left);
End;

Begin
SetupSRL;
MoveArrowKeys;
End.


E2: If you're trying to move the RS compass, there's better ways to go about / pre-made ways to move your RS compass angel already in simba

E3: This is all for PascalScript, used within simba, not Pascal.

goodlife

2012-06-05 18:54:31

Thanks so much Le Jingle! Exactly what I was looking for. Yeah the simba code is a little tough to translate as I am new to it. If anyone knows regular pascal coding, feel free to contribute!