Simulates a key event on an app object.
Example - Infinite Monkey
function OnStart()
{
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
edt = app.CreateTextEdit( "", 0.8, 0.3, "nokeyboard" );
lay.AddChild( edt );
app.AddLayout( lay );
app.Animate( SimulateKey, 2 );
}
function SimulateKey()
{
var ran = 65 + Math.floor(Math.random() * 26);
var char = String.fromCharCode( ran );
app.SimulateKey( edt, char );
}
from native import app
import math
import random
def OnStart():
global edt
lay = app.CreateLayout( "linear", "VCenter,FillXY" )
edt = app.CreateTextEdit( "", 0.8, 0.3, "nokeyboard" )
lay.AddChild( edt )
app.AddLayout( lay )
app.Animate( SimulateKey, 2 )
def SimulateKey(time, dtime):
ran = 65 + math.floor(random.random() * 26)
char = chr( ran )
app.SimulateKey( edt, char )