loading
 
vbscript
Fax from Estonia  [1 posts]
15 year
Hello,
I´m using this code:

x = GetVariable("HIGHEST_MIDDLE_X")
midx = GetVariable("IMAGE_WIDTH") / 2
leftThreshold = midx - 50
rightThreshold = midx + 50

if x <= leftThreshold then
  SetVariable "left_motor", 0
  SetVariable "right_motor", 255
else
  if x >= rightThreshold then
    SetVariable "left_motor", 255
    SetVariable "right_motor", 0
  else
    SetVariable "left_motor", 255
    SetVariable "right_motor", 255
  end if
end if

And i have a problem.
What i need:
if:   SetVariable "left_motor", 0
  SetVariable "right_motor", 255
i need to send key R
And if
    SetVariable "left_motor", 255
    SetVariable "right_motor", 0
i need to send key L
I have tried putting some vbscript sendkey commands what i found from google. Like:
objShell.SendKeys "L"
But these dont work.
I´m not very good at coding these languages. Wish it would use php.
Fax from Estonia  [1 posts] 15 year
Bump. Thanks.
Anonymous 15 year
Ok, try using

x = GetVariable("HIGHEST_MIDDLE_X")
midx = GetVariable("IMAGE_WIDTH") / 2
leftThreshold = midx - 50
rightThreshold = midx + 50

if x <= leftThreshold then
  SetVariable "key_to_send", "R"
else
  if x >= rightThreshold then
  SetVariable "key_to_send", "L"
  else
    SetVariable "key_to_send", ""
  end if
end if

and then in the key_to_send variable in the Keyboard_Send module

http://www.roborealm.com/help/Keyboard_Send.php

I.e. the variable created above has the value to use in the Keyboard_Send module. Think of the VBScript as creating parameters for other modules that are then specified using the GUI. So by changing the variable you change what keys are sent.

Make sense?

STeven.

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index