overwolf.games.inputTracking API
Provides keyboard and mouse activity information while the user is in-game.
Methods Reference
- overwolf.games.inputTracking.getActivityInformation()
- overwolf.games.inputTracking.getMatchActivityInformation()
- overwolf.games.inputTracking.getMousePosition()
- overwolf.games.inputTracking.init()
Events Reference
- overwolf.games.inputTracking.onKeyUp
- overwolf.games.inputTracking.onKeyDown
- overwolf.games.inputTracking.onMouseUp
- overwolf.games.inputTracking.onMouseDown
- overwolf.games.inputTracking.onMouseWheel
Types Reference
- overwolf.games.inputTracking.InputActivity Object
- overwolf.games.inputTracking.MousePosition Object
- overwolf.games.inputTracking.GetActivityResult Object
- overwolf.games.inputTracking.GetMousePositionResult Object
- overwolf.games.inputTracking.KeyEvent Object
- overwolf.games.inputTracking.MouseEvent Object
getActivityInformation(callback)
Version added: 0.92
Returns input activity information.
Parameter | Type | Description |
---|---|---|
callback | (Result:GetActivityResult) => void | Callback with input activity information |
Notes
- The information includes key presses and clicks for keyboard/mouse, total session time, idle time and overall actions-per-minute. This information resets between game executions.
- When a new game starts, we reset the entire session - when the game ends, the last activity information is available until the next game session.
- You have to play for 5 minutes and have at least 30 keys to be eligible.
getMatchActivityInformation(callback)
Version added: 0.92
Returns input activity information (similar to getActivityInformation()), however, when this is supported, it will return data only for the latest match of the current game.
This function is currently not working as expected. As a workaround, you can use getctivityInformation() and manually identify matches and calculate the deltas between them.
Parameter | Type | Description |
---|---|---|
callback | (Result:GetActivityResult) => void | Callback with input activity information |
In order to get the information:
- The latest match must have lasted for more than 5 minutes.
- The user must have clicked more than 30 times on either keyboard or mouse.
getMousePosition(callback)
Version added: 0.93
Returns the last mouse position in game.
The data includes the mouse position and a boolean stating whether the click was in the game or on an Overwolf widget (onGame).
Parameter | Type | Description |
---|---|---|
callback | (Result:GetMousePositionResult) => void | Callback with input activity information |
Note that you need to call init() before calling this function, OR, register to one of the events: onMouseUp, onMouseDown, onMouseWheel.
Otherwise, you will get an error:
{status: "error", reason: "Input tracking not initialized."}`
init(callback)
Version added: 0.160
For using getMousePosition without pre-register to events.
Parameter | Type | Description |
---|---|---|
callback | (Result) => void | Returns with the result |
onKeyUp
Version added: 0.78
Fired when a keyboard key has been released, with the following structure: KeyEvent Object.
The event information includes the virtual key code (key) and a boolean stating whether the keypress was in the game or on an Overwolf widget (onGame).
Using the onKeyUp event
We will use it to catch the user's keypress release, for example, catch the tab release:
overwolf.games.inputTracking.onKeyUp.addListener(function(info) {
if(info.key == "9") //9=tab
console.log("Tab key released: " + JSON.stringify(info));
});
onKeyDown
Version added: 0.78
Fired when a keyboard key has been pressed, with the following structure: KeyEvent Object.
Using the onKeyDown event
We can use it to catch the user's keypress, for example, catch the tab keypress:
overwolf.games.inputTracking.onKeyDown.addListener(function(info) {
if(info.key == "9") //9=tab
console.log("Tab key pressed: " + JSON.stringify(info));
});
The event also returns a boolean stating whether that keypress happened in the game or outside of it.
Note that it's not recommended to use this method (catching user keypresses) for hotkeys.
For that, use the overwolf.settings.hotkeys API.
onMouseUp
Version added: 0.78
Fired when a mouse key has been released, with the following structure: MouseEvent Object.
The event information includes whether the left or right mouse button was clicked (button), x and y coordinates (x, y) and a boolean stating whether the keypress was in the game or on an Overwolf widget (onGame).
onMouseDown
Version added: 0.78
Fired when a mouse key has been pressed, with the following structure: MouseEvent Object.
onMouseWheel
Version added: 0.158
Fired when a mouse wheel has been used, with the following structure: WheelEvent Object.
InputActivity Object
Parameter | Type | Description |
---|---|---|
aTime | number | active time. total active time in minutes |
iTime | number | idle time |
apm | number | actions per minute |
mouse | object | { total: number, dist: number, keys: any } |
keyboard | object | { total: number, keys: any } |
MousePosition Object
Parameter | Type | Description |
---|---|---|
x | number | |
y | number | |
onGame | boolean | |
handle | object | { value: number } |
GetActivityResult Object
Parameter | Type | Description |
---|---|---|
success | boolean | |
error | string | null if success is true |
activity | InputActivity object | the input activity information |
Example data: Success
{
"success":true,
"activity":{
"mouse":{
"total":424,
"dist":111176,
"keys":{
"M_Right":413,
"M_Left":11
}
},
"keyboard":{
"total":83,
"keys":{
"4":1,
"Q":20,
"W":20,
"E":19,
"R":10,
"SPACE":4,
"LCONTROL+TAB":2,
"TAB":2,
"ESCAPE":2,
"LMENU+F4":1,
"F":1,
"OEM_3":1
}
},
"aTime":4.36,
"iTime":1.31,
"apm":116
}
}
GetMousePositionResult Object
Parameter | Type | Description |
---|---|---|
success | boolean | |
error | string | null if success is true |
mousePosition | MousePosition object | the input activity information |
Example data: Success
{
"success": true,
"mousePosition": {
"x": 1741,
"y": 656,
"onGame": true,
"handle": {
"value": 526402
}
}
}
KeyEvent Object
Parameter | Type | Description | Notes |
---|---|---|---|
key | string | ||
onGame | boolean |
Event data example: Success
{
"key": "81",
"onGame": true
}
MouseEvent Object
Parameter | Type | Description | Notes |
---|---|---|---|
button | string | ||
x | number | ||
y | number | ||
onGame | boolean |
Event data example: Success
{
"button": "xbutton2",
"x": 177,
"y": 529,
"onGame": true
}
WheelEvent Object
Parameter | Type | Description | Notes |
---|---|---|---|
delta | number | ||
x | number | ||
y | number | ||
onGame | boolean |
Event data example: Success
{
"delta": "13",
"x": 177,
"y": 529,
"onGame": true
}