Old 05-21-2020, 06:51 PM   #1
Human being with feelings
Join Date: Jan 2020
Posts: 4
Default Script to track action execution


I'm trying to figure out how to do a script to record action usage statistics.
I'm looking for something that helps me listen to the new action events and writing the action name in a file with two collections:
[{action_name : trigger_count}]
[{action_name : time_stamp}]

The issue is that I can't figure out how to do any of those.
Any pointers?

I'm planning in the long run to try and make a last used and most used UI element.

Another option for the statistics is an external script that listens for reaper close events and then searches for the undo files so that it can parse them. I'm still trying to discover if there are any action names stored in that file.
obogz is offline   Reply With Quote
Old 05-21-2020, 06:55 PM   #2
Human being with feelings
cfillion's Avatar
Join Date: May 2015
Location: Québec, Canada
Posts: 3,145

An extension plugin can do that (they can be directly notified just before any action is run). ReaScripts can only watch the undo state for changes and attempt to guess which action caused it.

EDIT: Or amagalma's suggestion below.

Last edited by cfillion; 05-22-2020 at 08:13 AM.
cfillion is offline   Reply With Quote
Old 05-22-2020, 02:52 AM   #3
Human being with feelings
amagalma's Avatar
Join Date: Apr 2011
Posts: 2,071

Try this as a starting point:
(requires JS_ReaScriptAPI and SWS)
local MainWindow = reaper.GetMainHwnd()
reaper.JS_WindowMessage_Intercept( MainWindow, "WM_COMMAND", true )
local _, _, p_time = reaper.JS_WindowMessage_Peek( MainWindow, "WM_COMMAND" )

function StopIntercept()
  reaper.JS_WindowMessage_Release( MainWindow, "WM_COMMAND" )
  return reaper.defer(function() end)


function main()
  local _, _, time, actionID = reaper.JS_WindowMessage_Peek( MainWindow, "WM_COMMAND" )
  if time ~= p_time then
    local name = reaper.CF_GetCommandText( 0, actionID )
    reaper.ShowConsoleMsg((name or "unnamed") .. " ( " .. actionID .. " )\n")
    p_time = time

amagalma is offline   Reply With Quote
Old 05-23-2020, 11:57 AM   #4
Human being with feelings
Join Date: Jan 2020
Posts: 4

Cool! thanks for the hints! I'll start coding
obogz is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 06:15 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.