BTD
build-test-deploy Development Environment

IupRobot.lua

Lua interface to the raw native functions. Besides providing several convenience functions, it also provides timing of events (motion tracking of mouse for example) and inserts a wait time after generating the event(s) to allow the window manager to process the eventqueue. The IupRobot functions return true while the functions are active and false when they are done. The actual options and methods are :
: THE EXAMPLE CODE IS PSEUDO CODE AND MIGHT NOT ACTUALLY WORK, SEE GuiSequencer.lua AND DOCUMENTATION IUP
general
new
Initialises screensize and timing parameters.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
With default update time = 20 ms and wait time = 100 ms. Or :
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot(0.05,0.5) -- update time = 50 ms, wait time = 500 ms
demo flag
By default no visual feedback is generated, only the wait time is inserted after a method call. This is fine for unattended testing, but a bit difficult to follow on screen...
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot(0.05,0.5) -- update time = 50 ms, wait time = 500 ms
robot.demo = true -- activate demo mode
mouse
xxxDown
Wrapper around the corresponding native functions. Only inserts a wait time.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:leftDown() -- press left mouse button
xxxUp
Wrapper around the corresponding native functions. Only inserts a wait time.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:middleUp() -- release middle mouse button
xxxClick
Press and release the specified mouse button, wait the specified time for visual feedback.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:leftClick(2) -- press left button 2 s and release
xxxClickDbl
Press and release the specified mouse button twice, half the specified time is for visual feedback of each click.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:leftClickDbl(2) -- press left button 1 s, release, press again 1 s and release
goto
Moves the mouse from the current position to the desired position in the designated time frame.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:goto(500,100,5) -- goto x = 500, y = 100 in 5 s
gotoCenter
Moves the mouse from the current position to the center of the desired screen element in the designated time frame.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

local button = iup.button{title = 'this is a button'}
robot:gotoCenter(button,5) -- goto center of button in 5 s
keyboard
xxxDown
Wrapper around the corresponding native functions. Only inserts a wait time (see further).
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:keyDown('a') -- press 'a' key
xxxUp
Wrapper around the corresponding native functions. Only inserts a wait time (see further).
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:shiftUp() -- release shift key
xxxClick
Press and release the specified key, wait the specified time for visual feedback (see further).
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:keyClick('s',1) -- press 's' key, wait 1 s and release it
keyString
Press and release all keys in the specified string, no visual feedback of key clicks.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:keyString('abcdefgh') -- press and release the specified keys one by one
timer
Wait the specified time.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:goto(500,100,5) -- goto x = 500, y = 100 in 5 s
robot:timer(2) -- wait 2 s
robot:goto(20,400,1) -- goto x = 20, y = 400 in 1 s
The keys are organised in different groups :
normal
Has methods keyDown, keyUp, keyClick, which all work on the first character of the provided string.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:keyDown('a') -- press 'a' key

robot:keyUp('abcdefg') -- release 'a' key

robot:keyClick('x',0.1) -- press 'x' key and release after 100 ms
modifier
Has methods xxxDown and xxxUp (xxx = alt, ctrl or shift).
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times

...

robot:altDown() -- press alt key

robot:shiftUp() -- release shift key
functional
Has methods funcDown, funcUp, funcClick, which all work on the provided string code.
local IupRobot = require('btd.lua.iuprobot')
local robot = IupRobot() -- default values for update and wait times
robot.demo = true

...

robot:funcClick('F1',1) -- press 'F1' key and release after 1 s
The string codes are identical to the virtual key codes (see also source code _IupRobot.c).