B4J Question SendKeys

magarcan

Active Member
Licensed User
Longtime User
I'm working over this sample code in order to make it send keys:
B4X:
Starter.Connector1.SendCommand(CreateRobotCommand("RobotSpecialKeyPress", Array("shift")))
    Starter.Connector1.SendCommand(CreateRobotCommand("RobotKeyPress", Array("f")))
    Starter.Connector1.SendCommand(CreateRobotCommand("RobotDelay", Array(10)))
    Starter.Connector1.SendCommand(CreateRobotCommand("RobotKeyRelease", Array("f")))
    Starter.Connector1.SendCommand(CreateRobotCommand("RobotSpecialKeyRelease", Array("shift")))
The problem is that sometimes it's send an "F" but others "f". Any idea why??? I need to make some combinations with ctrl, alt and shift.

Cheers!!
 

Harris

Expert
Licensed User
Longtime User
I had this issue, but dang if I can recall how I resolved it.... Chr() or Asc()????
Seems to me "f" and another character were "special" chars....
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
If you are getting an "F" pressed instead of an "f" when you intended an "f" (or vice-versa), that means that the desktop computer thought the Shift key was still depressed. This can happen because the desktop never received the command to release the Shift key. If you are using UDP, note that it is not as reliable as as other network protocols, which is why it can be faster. The downside is the commands might get lost in transmission. You can always send another command to release the Shift key, it won't break anything.

"Escaping" characters won't work, as you've found out.
 
Upvote 0

magarcan

Active Member
Licensed User
Longtime User
I've tried "releasing" shift key even 4 times and it's sometimes showing an "f" so this is not even working properly. I will try using TCP to se if it works better.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
As @Roycefer said try TCP, as UDP packets can arrive in any order and can be completely dropped, whereas TCP packets will arrive in the order sent, and if one is lost will be resent.
 
Upvote 0
Top