Skip to main content

overwolf.games.inputTracking API

Provides keyboard and mouse activity information while the user is in-game.

Methods Reference

Events Reference

Types Reference

getActivityInformation(callback)

Version added: 0.92

Returns input activity information.

ParameterTypeDescription
callback(Result:GetActivityResult) => voidCallback 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.

danger

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.

ParameterTypeDescription
callback(Result:GetActivityResult) => voidCallback 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).

ParameterTypeDescription
callback(Result:GetMousePositionResult) => voidCallback 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.

ParameterTypeDescription
callback(Result) => voidReturns 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

ParameterTypeDescription
aTimenumberactive time. total active time in minutes
iTimenumberidle time
apmnumberactions per minute
mouseobject{ total: number, dist: number, keys: any }
keyboardobject{ total: number, keys: any }

MousePosition Object

ParameterTypeDescription
xnumber
ynumber
onGameboolean
handleobject{ value: number }

GetActivityResult Object

ParameterTypeDescription
successboolean
errorstringnull if success is true
activityInputActivity objectthe 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

ParameterTypeDescription
successboolean
errorstringnull if success is true
mousePositionMousePosition objectthe input activity information

Example data: Success

{
"success": true,
"mousePosition": {
"x": 1741,
"y": 656,
"onGame": true,
"handle": {
"value": 526402
}
}
}

KeyEvent Object

ParameterTypeDescriptionNotes
keystring
onGameboolean

Event data example: Success

{
"key": "81",
"onGame": true
}

MouseEvent Object

ParameterTypeDescriptionNotes
buttonstring
xnumber
ynumber
onGameboolean

Event data example: Success

{
"button": "xbutton2",
"x": 177,
"y": 529,
"onGame": true
}

WheelEvent Object

ParameterTypeDescriptionNotes
deltanumber
xnumber
ynumber
onGameboolean

Event data example: Success

{
"delta": "13",
"x": 177,
"y": 529,
"onGame": true
}