B4J Question KeyPress - KeyRelease robot class

micro

Well-Known Member
Licensed User
Hi to all
I have some problems sending some characters by simulating the keyboard with robot class.
The character Ascii '@' has a decimal code = 65 but if I send this code I do not write anything.
B4X:
Dim robot As JavaObject
Dim jo As JavaObject
jo.InitializeStatic("com.sun.glass.ui.Application")
robot = jo.RunMethodJO("GetApplication",Null).RunMethodJO("createRobot",Null)
'Send @
Dim i As Int =  lb.Tag  ' Tag = 65
robot.RunMethod("keyPress", Array As Object(i))
Sleep(50)
robot.RunMethod("keyRelease", Array As Object(i))

I can use RobotPaste but this not work on raspberry, with windows it's ok.
Thanks
 

Daestrum

Well-Known Member
Licensed User
I think to send @ you need to (assuming windows keyboard with @ over ' )

1, send keyPress shift code (16)
2, send keyPress ' code (192)
3, send keyRelease ' code (192)
4, send keyRelease shift code (16)
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
I didn't notice that this post existed until after I posted my question that you can find here

Please shed some light upon it, thanks

btw what is lb.Tag in post #1 ?
 
Upvote 0

ThRuST

Well-Known Member
Licensed User
Is it possible to send a combination of keypresses using the above code?

I want to send CTRL+V that should work on both PC and Mac.

I found a ASCII table that might be useful. Go here

14+21, 2A for copy and paste (CTRL+C, CTRL+V)
 
Last edited:
Upvote 0
Top