Old 02-17-2019, 03:29 PM   #241
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 960
Default

@ juliansader
Any plans to add support for ComboBox list like you did for ListView?
Edgemeal is offline   Reply With Quote
Old 02-18-2019, 03:20 AM   #242
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 110
Default

Quik question: would it be possible to get render path - getting it from the first textbox in the Output section of the Render dialgo - using this API?

Or maybe its possible even without using the js_extension? I searched for this on the regular API but couldnt find anything.
reapero is offline   Reply With Quote
Old 02-18-2019, 06:24 AM   #243
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 736
Default

I'm working on that for the Ultraschall-Api. Just some minor bugs to be fixed, I can give you even the rendered-filenames you can expect for a project.
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 02-18-2019, 06:40 AM   #244
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,633
Default

That's pretty awesome, thanks mespo!
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 02-18-2019, 08:40 AM   #245
nappies
Human being with feelings
 
nappies's Avatar
 
Join Date: Dec 2017
Posts: 60
Default Strange thing

Guys what am i doing wrong? JS_Window_ListAllChild return empty string.

Last version JS API installed and Reaper also last version.




Code:
function msg(m)
  reaper.ShowConsoleMsg(tostring(m) .. "\n")
end


main_wnd = reaper.GetMainHwnd()
local retval, list = reaper.JS_Window_ListAllChild(main_wnd)
msg(list)
nappies is offline   Reply With Quote
Old 02-18-2019, 12:14 PM   #246
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,397
Default

@nappies
I don't have much help to offer but can only say your code is working here.
No idea what could be going wrong, sorry.

nofish is offline   Reply With Quote
Old 02-18-2019, 02:56 PM   #247
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,268
Default

Quote:
Originally Posted by Edgemeal View Post
@ juliansader
Any plans to add support for ComboBox list like you did for ListView?
Communication with ComboBoxes are through standard window messages, using JS_WindowMessage_Send. The ComboBox message names, such as "CB_GETCOUNT" aren't automatically recognized by the current version of the extension, but I can easily add these to the next update.

In the meantime, you can use message numbers such as "0x0146" instead of "CB_GETCOUNT", for example, when accessing ComboBoxes.
juliansader is offline   Reply With Quote
Old 02-18-2019, 03:03 PM   #248
nappies
Human being with feelings
 
nappies's Avatar
 
Join Date: Dec 2017
Posts: 60
Default

nofish, thank you man! I thought I was going crazy) On the new reinstalled reaper everything is ok.
nappies is offline   Reply With Quote
Old 02-18-2019, 04:18 PM   #249
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 960
Default

Quote:
Originally Posted by juliansader View Post
Communication with ComboBoxes are through standard window messages, using JS_WindowMessage_Send. The ComboBox message names, such as "CB_GETCOUNT" aren't automatically recognized by the current version of the extension, but I can easily add these to the next update.

In the meantime, you can use message numbers such as "0x0146" instead of "CB_GETCOUNT", for example, when accessing ComboBoxes.
I tried but not sure how to get the text, the last API call says param #4 should be a number but pretty sure Win32 API expects a string buffer. What am I doing wrong?

Code:
function msg(str)
  reaper.ShowConsoleMsg(tostring(str) .. '\n')
end

CB_GETCOUNT = "0x0146"
CB_GETLBTEXT = "0x0148"
CB_GETLBTEXTLEN = "0x0149"

reaper.ClearConsole()

local title = reaper.JS_Localize("VST: ReaEQ", "common") --< Floating FX window
local hwnd = reaper.JS_Window_Find(title, false)
if not hwnd then return end

 -- get presets combobox
local container = reaper.JS_Window_FindChildByID(hwnd, 0)
local presets = reaper.JS_Window_FindChildByID(container, 1000)

local itemCount = reaper.JS_WindowMessage_Send(presets, CB_GETCOUNT, 0,0,0,0)
msg(itemCount)

for i = 0, itemCount-1 do
  local itemLength = reaper.JS_WindowMessage_Send(presets, CB_GETLBTEXTLEN, i, 0,0,0) 
  local buffer = string.rep(" ", itemLength) 
  reaper.JS_WindowMessage_Send(presets, CB_GETLBTEXT, i, buffer, 0,0) 
  msg(buffer)
end

Last edited by Edgemeal; 02-18-2019 at 04:28 PM.
Edgemeal is offline   Reply With Quote
Old 02-19-2019, 11:30 PM   #250
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,268
Default

Quote:
Originally Posted by Edgemeal View Post
I tried but not sure how to get the text, the last API call says param #4 should be a number but pretty sure Win32 API expects a string buffer. What am I doing wrong?
That window message requires the address of a buffer into which it can write a string, and it should be passed to the API function as a Lua number. Pointers can be converted to address numbers by JS_Window_AddressFromHandle (or a simple tostring on the handle).

Lua strings are fixed, so aren't editable buffers into which functions can write new strings. I am not aware of any Lua function in REAPER that allocates such memory, except new_array(). Perhaps I should add some functions for allocating memory buffers to the extension?

I haven't been able to get CB_GETLBTEXT and CB_GETLBTEXTLEN to work either, even with properly allocated buffers. CB_GETLBTEXTLEN returns wildly exaggerated values, and CB_GETLBTEXT just returns an error code.

For most of REAPER's comboboxes, this shouldn't be a problem, since their contents are known and fixed: as long as CB_GETCURSEL (or even JS_Window_GetTitle) and CB_SETCURSEL work, you can get and set combobox selection.

For comboboxes with variable contents, such as the ReaEQ presets, I don't have a good solution yet, unfortunately. Perhaps you can activate each preset one-by-one and use GetTitle to get the name?

Last edited by juliansader; 02-19-2019 at 11:55 PM.
juliansader is offline   Reply With Quote
Old Yesterday, 01:37 AM   #251
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 960
Default

Quote:
Originally Posted by juliansader View Post
Perhaps you can activate each preset one-by-one and use GetTitle to get the name?
I didn't expect CB_SETCURSEL to work better then REAPER's API.
If I try doing this same thing with REAPER API (example, see MPL's reabank script) on say 'Guitar Rig 5' I don't get any preset text and REAPER gets really slow and will crash if I don't stop the script right away.
Some plugins don't like when the presets are changed really fast and crash, But this works!
Code:
-- TEST: Create Reabank file for 'Guitar Rig 5' --

fx_name = 'Guitar Rig 5' -- floating FX window

function Main()
  local CB_GETCOUNT = "0x0146"
  local CB_GETCURSEL = "0x0147"
  local CB_SETCURSEL = "0x014E"
  -- Find VST floating FX window
  local title = reaper.JS_Localize("VST: ".. fx_name, "common")
  local hwnd = reaper.JS_Window_Find(title, false)
  if not hwnd then return end
   -- get presets combobox
  local container = reaper.JS_Window_FindChildByID(hwnd, 0)
  local presets = reaper.JS_Window_FindChildByID(container, 1000)
  local itemCount = reaper.JS_WindowMessage_Send(presets, CB_GETCOUNT, 0,0,0,0)
  -- save current index
  local cur_index = reaper.JS_WindowMessage_Send(presets, CB_GETCURSEL, 0,0,0,0)
  local listStart = 3
  -- build reabank
   local str = 
  [[
  // .reabank bank/program (patch) information
  // A bank entry lists the MSB, LSB, and bank name
  // for all the patches that follow, until the next bank entry.
  ]]..'\n'..'Bank 0 0 '.. fx_name ..' 001-'..tostring(itemCount-listStart)..'\n'
  -- get preset names
  for i = listStart, itemCount-1 do
    reaper.JS_WindowMessage_Send(presets, CB_SETCURSEL, i, 0,0,0)
    str = str..'\n'..(i-listStart)..' '..reaper.JS_Window_GetTitle(presets,"")
  end
  -- restore index
  reaper.JS_WindowMessage_Send(presets, CB_SETCURSEL, cur_index, 0,0,0)
  -- get file path from user for reabank file
  local initialFolder = reaper.GetResourcePath()..[[\Data]] 
  local initialFile = fx_name .. ".reabank" 
  local extensionList = "ReaBank files (*.reabank)\0*.reabank\0\0" 
  local ret, filename = reaper.JS_Dialog_BrowseForSaveFile("Save As Reabank", initialFolder, initialFile, extensionList)
  -- write data to file
  if ret then
    local f = io.open(filename, "w")
    f:write(str)
    f:close()
  end
end
-- begin
if not reaper.APIExists("JS_Localize") then
  reaper.MB("js_ReaScriptAPI extension is required for this script.", "Missing API", 0)
else
  Main()
end
-- end
reaper.defer(function () end)

Last edited by Edgemeal; Yesterday at 03:22 PM.
Edgemeal is offline   Reply With Quote
Reply

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 09:11 AM.


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