Old 12-19-2018, 05:17 AM   #161
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

Quote:
Originally Posted by Edgemeal View Post
If you call actions from a lua script its a hassle to copy their ID/convert IDs, etc. Using this script you just highlight the action(s) you want and call this script from a shortcut and it generates the code for you, at least I hope it does.

Code:
-- Command ID Code Generator v0.04 --
-- Testing: x64, Windows 7, REAPER v5.963+dev1213, js_ReaScriptAPI v0.961.
-- v0.04 - Support multiple selected LV items.

local app_name = "Cmd_ID Code Gen"
local code = ""

local hWnd_action = reaper.JS_Window_Find("Actions", true)
if hWnd_action == nil then
  reaper.MB("Please open the Actions list!", app_name, 0)
  return
end  

local hWnd_LV = reaper.JS_Window_FindChildByID(hWnd_action, 1323)
if reaper.JS_ListView_GetItemText(hWnd_LV, 0, 3) == "" then
  reaper.MB("Please enable 'Show action IDs' in Actions list!", app_name, 0)
  return
end

-- get selected count & selected indexes
sel_count, sel_indexes = reaper.JS_ListView_ListAllSelItems(hWnd_LV)
if sel_count == 0 then
  reaper.MB("Please select one or more actions.", app_name, 0)
  return
end 

-- generate code lines for *Main*
for index in string.gmatch(sel_indexes, '[^,]+') do 
  local desc = reaper.JS_ListView_GetItemText(hWnd_LV, tonumber(index), 1)
  local cmd = reaper.JS_ListView_GetItemText(hWnd_LV, tonumber(index), 3)
  if tonumber(cmd) ~= nil then -- reaper action
    code = code .. "reaper.Main_OnCommand(" .. cmd .. ", 0) -- " .. desc .. '\r\n'
  else -- custom scripts require a lookup
    code = code .. "reaper.Main_OnCommand(reaper.NamedCommandLookup('" .. cmd .. "'), 0) -- " .. desc .. '\r\n'
  end
end -- for index

reaper.CF_SetClipboard(code)-- copy generated code to clipboard

I wanted to combine it with this script of Edgemeal so that the action gets automatically typed in the open IDE window.


Your code works and now I can achieve it. Thank you! The only problem is the messed up undo (an undo point for each character), which makes it not practical.. So, I 'll just use the script in Edgemeal's original version, and do the pasting manually.
amagalma is offline   Reply With Quote
Old 12-19-2018, 10:37 AM   #162
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

On another note, it is great that with the latest additions we can now get the selected FX in a visible Chain :



Code:
function GetSelectedFXinChain()
  local FX_win = reaper.JS_Window_Find("FX: ", false )
  local sel_FX = {}
  if FX_win then
    local title = reaper.JS_Window_GetTitle( FX_win, "" )
    if title:match("FX: Track ") or title:match("FX: Master Track") or title:match("FX: Item ") then
      local list = reaper.JS_Window_FindChildByID(FX_win, 1076)
      local _, sel_fx = reaper.JS_ListView_ListAllSelItems(list)
      local a = 0
      for i in sel_fx:gmatch("%d+") do
        sel_FX[a+1] = {id = tonumber(i), name = reaper.JS_ListView_GetItemText(list, tonumber(i), 0)}
        a = a + 1
      end
    end
  end
  return sel_FX
end

-- TEST CODE -- 
local fx = GetSelectedFXinChain()
if #fx == 0 then return end
reaper.ClearConsole()
reaper.ShowConsoleMsg("The selected FX in the visible FX chain are:\n\n")
for i = 1, #fx do
  reaper.ShowConsoleMsg(i .. ") " .. fx[i].name .. "   - - -   fxid: " .. fx[i].id .. "\n\n")
end
local w = reaper.JS_Window_Find("ReaScript console output", true )
reaper.JS_Window_SetFocus( reaper.JS_Window_FindChildByID(w, 3) )
reaper.defer(function () end )
And do this :


Last edited by amagalma; 12-24-2018 at 02:06 PM.
amagalma is offline   Reply With Quote
Old 12-21-2018, 02:02 PM   #163
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

v0.962 by juliansader – December 21 2018
* New functions: Browse for files and folders.
* New functions: Various ListView.
* New function: FindChildByID.
* Changed functions: Functions that previously stored strings in ExtStates, now return the strings directly.
* Requirements: On Windows OS, C++ redistributable not required anymore.
* Requirements: REAPER v5.965 or later.
Edgemeal is offline   Reply With Quote
Old 12-21-2018, 05:10 PM   #164
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,324
Default

Updated my ReaScript doc page with REAPER v5.965 and js_Extension v0.962 :P
(link in signature)
X-Raym is offline   Reply With Quote
Old 12-21-2018, 07:55 PM   #165
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by amagalma View Post
I wanted to combine it with this script of Edgemeal so that the action gets automatically typed in the open IDE window.
This is crazy, I added this to that script, set the script to use a shortcut with Control key, I'm using Control+F12 and it works LOL! Its like the IDE sees the Control key is down + the V key this script is sending so it does a paste!

Code:
...
reaper.CF_SetClipboard(code) -- copy generated code to clipboard

-- sends text to IDE if open
local hWnd_IDE = reaper.JS_Window_Find(" - ReaScript Development Environment", false)
if hWnd_IDE ~= nil then
 local wdl = reaper.JS_Window_FindChildByID(hWnd_IDE, 1106) 
 reaper.JS_Window_SetFocus(wdl)
 reaper.JS_WindowMessage_Post(wdl, "WM_KEYDOWN", 0x0056, 0, 0, 0) -- V key
 reaper.JS_WindowMessage_Post(wdl, "WM_KEYUP", 0x0056, 0, 0, 0)
end
Edgemeal is offline   Reply With Quote
Old 12-22-2018, 05:41 AM   #166
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

Quote:
Originally Posted by Edgemeal View Post
This is crazy, I added this to that script, set the script to use a shortcut with Control key, I'm using Control+F12 and it works LOL! Its like the IDE sees the Control key is down + the V key this script is sending so it does a paste!

Code:
...
reaper.CF_SetClipboard(code) -- copy generated code to clipboard

-- sends text to IDE if open
local hWnd_IDE = reaper.JS_Window_Find(" - ReaScript Development Environment", false)
if hWnd_IDE ~= nil then
 local wdl = reaper.JS_Window_FindChildByID(hWnd_IDE, 1106) 
 reaper.JS_Window_SetFocus(wdl)
 reaper.JS_WindowMessage_Post(wdl, "WM_KEYDOWN", 0x0056, 0, 0, 0) -- V key
 reaper.JS_WindowMessage_Post(wdl, "WM_KEYUP", 0x0056, 0, 0, 0)
end

It is crazy! It works! :O ... I don't see why it should, but it works!
amagalma is offline   Reply With Quote
Old 12-23-2018, 08:18 AM   #167
D Rocks
Human being with feelings
 
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 435
Default

JulianSader, thank you again for the implementation of the "Mixer Window visibility improvement"
__________________
Alex | www.drocksrecords.com | Thanks for REAPER
D Rocks is offline   Reply With Quote
Old 12-23-2018, 03:02 PM   #168
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 103
Default

Would it be possible using this API to implement Ctrl+F on the Media Explorer to set the cursor in the search field?
reapero is offline   Reply With Quote
Old 12-23-2018, 03:38 PM   #169
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by reapero View Post
Would it be possible using this API to implement Ctrl+F on the Media Explorer to set the cursor in the search field?
I see an edit box on the top-right of the explorer window, is that the search box? You should be able to set focus on it like this,..

Code:
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end  

local search = reaper.JS_Window_FindChildByID(hWnd, 1015)
if search == nil then return end  

reaper.JS_Window_SetFocus(search)
Edgemeal is offline   Reply With Quote
Old 12-23-2018, 09:37 PM   #170
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,325
Default

^^ Where / how do you get the 1015 for the search box ID?
(or IDs of child windows in general for that matter)
nofish is offline   Reply With Quote
Old 12-23-2018, 11:38 PM   #171
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by nofish View Post
^^ Where / how do you get the 1015 for the search box ID?
(or IDs of child windows in general for that matter)
MS SPY++ or similar apps.
I made this quick little app for Windows too,..
https://stash.reaper.fm/v/35034/Get%...er%20Mouse.zip
Edgemeal is offline   Reply With Quote
Old 12-24-2018, 02:15 AM   #172
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 103
Default

Quote:
Originally Posted by Edgemeal View Post
I see an edit box on the top-right of the explorer window, is that the search box? You should be able to set focus on it like this,..

Code:
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end  

local search = reaper.JS_Window_FindChildByID(hWnd, 1015)
if search == nil then return end  

reaper.JS_Window_SetFocus(search)
Awesome! Thanks!
reapero is offline   Reply With Quote
Old 12-24-2018, 06:17 AM   #173
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,325
Default

Quote:
Originally Posted by Edgemeal View Post
MS SPY++ or similar apps.
I made this quick little app for Windows too,..
https://stash.reaper.fm/v/35034/Get%...er%20Mouse.zip
Thanks (for your app also).
nofish is offline   Reply With Quote
Old 12-24-2018, 10:22 AM   #174
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

Quote:
Originally Posted by Edgemeal View Post
v0.962 by juliansader – December 21 2018
* New functions: Browse for files and folders.
* New functions: Various ListView.
* New function: FindChildByID.
* Changed functions: Functions that previously stored strings in ExtStates, now return the strings directly.
* Requirements: On Windows OS, C++ redistributable not required anymore.
* Requirements: REAPER v5.965 or later.
That's nice
Finally I can use the dialogs for selection/saving of folders and multiple files. Fantastic

By the way, how stable from an API-call-perspective would you describe your plugin? Do you plan to make some more extensive changes to some functions, like the ones where you changed from returning into an extstate to directly into a string or do you consider this mostly done at this point? I would love to add some functions to my API that make heavy use of your plugin, but need I some stability in the parameters and retvals to do that.
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; 12-24-2018 at 10:31 AM.
mespotine is offline   Reply With Quote
Old 12-27-2018, 01:17 PM   #175
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,220
Default

Quote:
Originally Posted by mespotine View Post
By the way, how stable from an API-call-perspective would you describe your plugin? Do you plan to make some more extensive changes to some functions, like the ones where you changed from returning into an extstate to directly into a string or do you consider this mostly done at this point? I would love to add some functions to my API that make heavy use of your plugin, but need I some stability in the parameters and retvals to do that.
I do not foresee any further major changes, since the extstate workaround was the only element of the interface that I was unhappy with.
juliansader is offline   Reply With Quote
Old 12-31-2018, 11:22 PM   #176
Breeder
Human being with feelings
 
Breeder's Avatar
 
Join Date: Nov 2010
Location: Croatia
Posts: 1,869
Default

Any of you wizards got a clue how to approach this with js_ReaScriptAPI?
Any idea how to resize dockers through scripts?
Breeder is offline   Reply With Quote
Old 01-01-2019, 09:14 PM   #177
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 484
Default

This API is enabling some really cool stuff. Thanks Julian!

Is there a way to get and set the pin state of a given hwnd?
tack is offline   Reply With Quote
Old 01-05-2019, 11:06 AM   #178
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by tack View Post
This API is enabling some really cool stuff. Thanks Julian!

Is there a way to get and set the pin state of a given hwnd?
If you mean the topmost pins REAPER adds to most windows? then, If there is I couldn't do it, all I could seem to do was close, hide or move them.

Last edited by Edgemeal; 01-05-2019 at 02:27 PM.
Edgemeal is offline   Reply With Quote
Old 01-05-2019, 02:45 PM   #179
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,325
Default

https://www.extremraym.com/cloud/rea...tachTopmostPin ?

(seems there's missing a function to remove it though)
nofish is offline   Reply With Quote
Old 01-05-2019, 02:55 PM   #180
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 484
Default

Quote:
Originally Posted by nofish View Post
https://www.extremraym.com/cloud/rea...tachTopmostPin ?

(seems there's missing a function to remove it though)
That function is to add a pin widget to a window that doesn't normally have one (e.g. an undocked reascript), not to get/set the pin state of a window (whether one that that normally has it like a floating FX window or one to which a pin was added via JS_Window_AttachTopmostPin)
tack is offline   Reply With Quote
Old 01-05-2019, 03:09 PM   #181
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,325
Default

Ah yes, misunderstood, sorry.
nofish is offline   Reply With Quote
Old 01-05-2019, 03:27 PM   #182
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,220
Default

Quote:
Originally Posted by nofish View Post
https://www.extremraym.com/cloud/rea...tachTopmostPin ?

(seems there's missing a function to remove it though)
It's a bit of a workaround, but the button creates its own HWND, so you can remove it with JS_Window_Destroy.


Quote:
Originally Posted by tack View Post
Is there a way to get and set the pin state of a given hwnd?
Not that I know of, unfortunately.

Last edited by juliansader; 01-05-2019 at 03:33 PM.
juliansader is offline   Reply With Quote
Old 01-05-2019, 04:28 PM   #183
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

Quote:
Originally Posted by juliansader View Post
Quote:
Originally Posted by tack View Post
Is there a way to get and set the pin state of a given hwnd?
Not that I know of, unfortunately.
Yeah.. I tried this method but it does not work:

Code:
local w = reaper.JS_Window_Find( "FX: Track 1", true )
if w then
  local ok, left, top, right = reaper.JS_Window_GetRect( w )
  if ok then
    local button = reaper.JS_Window_FromPoint( right-34, top+11 )
    local _, leftX, topY = reaper.JS_Window_GetRect(button)
    reaper.JS_Mouse_SetPosition( leftX+8, topY+8 ) -- just to check visually the point
    reaper.JS_WindowMessage_Post(button, "WM_LBUTTONDOWN", 0x0001, 0, leftX+8, topY+8)
    reaper.JS_WindowMessage_Post(button, "WM_LBUTTONUP", 0x0000, 0, leftX+8, topY+8)
  end
end
amagalma is offline   Reply With Quote
Old 01-05-2019, 05:00 PM   #184
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by amagalma View Post
Yeah.. I tried this method but it does not work:
If you're trying to click the pin to change its state the old mouse_event function works, but its not in this API, I did it from windows app.

BTW, to click a button/checkbox just send a bm_click message directly to the control,..
Code:
-- Send button click message, aka "BM_CLICK".
reaper.JS_WindowMessage_Send(hWnd, "0x00F5", 0, 0, 0, 0)
But those pins don't support that message either.

Last edited by Edgemeal; 01-05-2019 at 05:52 PM.
Edgemeal is offline   Reply With Quote
Old 01-06-2019, 11:50 AM   #185
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

Thanks! BM_CLICK requires the mouse cursor to be positioned at the position to be clicked. In my previous snippet of code I used JS_Mouse_SetPosition, just to assert visually that I was going to post the WM_LBUTTON messages at the correct position.
amagalma is offline   Reply With Quote
Old 01-06-2019, 12:17 PM   #186
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by amagalma View Post
Thanks! BM_CLICK requires the mouse cursor to be positioned at the position to be clicked. .
No it doesn't, I use it all the time in Windows, no mouse BS. Used that code to click a button on FX, and worked.

--- Click "+" button on 'FX:' window..
Code:
local hwnd = reaper.JS_Window_Find("FX: Track ", false)
local contanier = reaper.JS_Window_FindChildByID(hwnd, 0)
local control = reaper.JS_Window_FindChildByID(contanier, 1014) -- "+" button
reaper.JS_WindowMessage_Send(control, "0x00F5", 0, 0, 0, 0)
Target may need to be a button class, though I've sent it to other controls and it worked( in Windows apps), but those REAPER pins are not buttons ??? Or just don't support these messages?

Edit According to MSDN for BM_CLICK ,
causes the button to receive the WM_LBUTTONDOWN and WM_LBUTTONUP messages,

But when I tried send those messages to a button (using this API) it doesn't click the button, but sending a BM_CLICK message does.
EDIT Well I take that back, this does work similar to BM_CLICK, I must of had something else wrong before.

Code:
function JS_LMouseDownUp(hWnd)
  reaper.JS_WindowMessage_Post(hWnd, "WM_LBUTTONDOWN", 1, 0, 0, 0)
  reaper.JS_WindowMessage_Post(hWnd, "WM_LBUTTONUP", 0, 0, 0, 0)
end

Last edited by Edgemeal; 01-06-2019 at 12:49 PM. Reason: Add BM_CLICK example
Edgemeal is offline   Reply With Quote
Old 01-06-2019, 12:48 PM   #187
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,455
Default

I see! Thank you for the info!
amagalma is offline   Reply With Quote
Old 01-16-2019, 08:33 AM   #188
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

@Juliansader

What kind of limitations are currently, when thinking about cross-platform-developing with the JS-plugin?
I remember, that some window-stuff is possible only on Windows(transparent windows, AFAIK?) and that not all windows have a HWND on all platforms.

So, do you already know, which windows don't have a HWND?
I tested and found, ReaScript-console is missing a HWND on Mac.

And what else is only possible on windows?


And a small FeatureRequest: JS_Dialog_BrowseForSaveFile, in the docs, it is not mentioned, how I can set the parameter extensionList. I tried several variations like "*.gif" or "*.gif|*.jpg" but it didn't work. The latter even added some weird additional entry into the extension-dropdownlist of the dialog.
Tested on Windows 7 with Reaper 5.965, SWS 2.7.9 and your plugin 0.962.
Could you add some hints for using that parameter?
__________________
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 01-16-2019, 08:35 AM   #189
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

Oh, anyone interested in a code-snippet for getting the HWND of an opened gfx.init-window in Lua?

I've built me some code that does that for my API and will be released in the next version, but maybe, some of you need something like that right now...
__________________
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 01-16-2019, 09:05 AM   #190
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 2,790
Default

Quote:
Originally Posted by mespotine View Post
how I can set the parameter extensionList. I tried several variations like "*.gif" or "*.gif|*.jpg" but it didn't work. The latter even added some weird additional entry into the extension-dropdownlist of the dialog.
Tested on Windows 7 with Reaper 5.965, SWS 2.7.9 and your plugin 0.962.
Could you add some hints for using that parameter?
The default (I checked the source code) extension format is like this

Code:
"All files (*.*)\0*.*\0\0"
if that helps?
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is online now   Reply With Quote
Old 01-16-2019, 10:14 AM   #191
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,220
Default

Quote:
Originally Posted by mespotine View Post
What kind of limitations are currently, when thinking about cross-platform-developing with the JS-plugin?
I'm not quite sure, unfortunately, since I can't test on MacOS.
Please let me know if you find anything else that doesn't work on all three platforms!

AFAIK, GDI isn't properly implemented on Linux. (I should probably submit a bug report to Justin in the WDL subforum.)


Quote:
Originally Posted by mespotine View Post
I remember, that some window-stuff is possible only on Windows(transparent windows, AFAIK?)
Making the entire window transparent should work on all platforms, but making a single color transparent is Windows-only.


Quote:
Originally Posted by mespotine View Post
and that not all windows have a HWND on all platforms.

So, do you already know, which windows don't have a HWND?
I tested and found, ReaScript-console is missing a HWND on Mac.
I am surprised. I expected that all REAPER windows would have HWNDs.

What code did you use to get the console's HWND?



Quote:
Originally Posted by mespotine View Post
And a small FeatureRequest: JS_Dialog_BrowseForSaveFile, in the docs, it is not mentioned, how I can set the parameter extensionList. I tried several variations like "*.gif" or "*.gif|*.jpg" but it didn't work. The latter even added some weird additional entry into the extension-dropdownlist of the dialog.
Tested on Windows 7 with Reaper 5.965, SWS 2.7.9 and your plugin 0.962.
Could you add some hints for using that parameter?
I will add info to the docs:

extensionList is a string containing pairs of \0-terminated substrings. The last substring must be terminated by two \0 characters.

Each pair defines one filter pattern: The first substring in each pair describes the filter in user-readable form (for example, "Lua script files (*.lua)") and will be displayed in the dialog box.

The second substring specifies the filter that the operating system must use to search for the files (for example, "*.txt"). To specify multiple extensions for a single display string, use a semicolon to separate the patterns (for example, "*.lua;*.eel").

The filter substring can be a combination of valid file name characters (excluding spaces) and the asterisk (*) wildcard character. In Windows, an extension without * is valid (for example ".txt\0") but other platforms may require the full pattern with wildcard ("*.txt\0").

An example of a extensionList string:
"ReaScript files\0*.lua;*.eel\0Lua files (.lua)\0*.lua\0EEL files (.eel)\0*.eel\0\0".

If the extensionList string is empty, it will display the default "All files (*.*)" filter.


P.S.: Microsoft's online documentation for the corresponding C++ functions is probably the best way to find out how to use the API functions.

Last edited by juliansader; 01-16-2019 at 10:37 AM.
juliansader is offline   Reply With Quote
Old Today, 09:09 AM   #192
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

Quote:
Originally Posted by juliansader View Post
Making the entire window transparent should work on all platforms, but making a single color transparent is Windows-only.
So that means, I can make a window transparent, but the stuff I draw into that window will also be transparent?



Quote:
I am surprised. I expected that all REAPER windows would have HWNDs.

What code did you use to get the console's HWND?
I wrote into my API a function to close the ReaConsole-window:

Code:
function ultraschall.CloseReaConsole()
  local retval,Adr=reaper.JS_Window_ListFind("ReaScript console output", true)

  if retval>1 then ultraschall.AddErrorMessage("CloseReaConsole", "", "Multiple windows are open, that are named \"ReaScript console output\". Can't find the right one, sorry.", -1) return false end
  if retval==0 then ultraschall.AddErrorMessage("CloseReaConsole", "", "ReaConsole-window not opened", -2) return false end
  local B=reaper.JS_Window_HandleFromAddress(Adr)
  reaper.JS_Window_Destroy(B)
  return true
end
It works only on Windows, but not on Mac, as if it can't find the HWND.
I haven't checked yet, if there's a way to get the HWND in a different way or if the ReaConsole has a slightly different title on Mac.
I'm currently digging through the way, HWNDs work in Reaper and which HWNDs are provided and which are not.


Quote:
I will add info to the docs:

extensionList is a string containing pairs of \0-terminated substrings. The last substring must be terminated by two \0 characters.
...
Thank you



BTW: under which license is your plugin? SWS is MIT-licensed and it would be great, if that would be the case for your plugin too.
I'm asking, as we would love to use your plugin in our distribution of Ultraschall and don't want to run into licensing conflicts.
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; Today at 09:51 AM.
mespotine is offline   Reply With Quote
Old Today, 09:13 AM   #193
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

For whom it may concern, I wrote a function, that opens the gfx.init-window AND returns its HWND. Use that, if you need to work with the HWND of a gfx-window.
It will be part of the next update of my Ultraschall-API.
The parameters are the exact same way as gfx.init.

Requires(of course) the JS-plugin installed and works on Mac and Windows (linux untested yet).

Code:
ultraschall={}

function ultraschall.GFX_Init(...)
  local parms={...}
  local temp=parms[1]

  -- check, if the given windowtitle is a valid one, 
  -- if that's not the case, use "" as name
  if temp==nil or type(temp)~="string" then temp="" end  
  if type(parms[1])~="string" then parms[1]="" 
  end
  
  -- check for a window-name not being used yet, which is 
  -- windowtitleX, where X is a number
  local freeslot=0
  for i=0, 65555 do
    if reaper.JS_Window_Find(parms[1]..i, true)==nil then freeslot=i break end
  end
  -- use that found, unused windowtitle as temporary windowtitle
  parms[1]=parms[1]..freeslot
  
  -- open window  
  local retval=gfx.init(table.unpack(parms))
  
  -- find the window with the temporary windowtitle and get its HWND
  local HWND=reaper.JS_Window_Find(parms[1], true)
  
  -- rename it to the original title
  if HWND~=nil then reaper.JS_Window_SetTitle(HWND, temp) end
  ultraschall.GFX_WindowHWND=HWND
  return retval, HWND
end
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635

Last edited by mespotine; Today at 09:48 AM.
mespotine is offline   Reply With Quote
Old Today, 11:44 AM   #194
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,220
Default

Quote:
Originally Posted by mespotine View Post
So that means, I can make a window transparent, but the stuff I draw into that window will also be transparent?
I haven't tried this on macOS, but I expect that the entire window and everything in it would become transparent.


Quote:
Originally Posted by mespotine View Post
It works only on Windows, but not on Mac, as if it can't find the HWND.
I haven't checked yet, if there's a way to get the HWND in a different way or if the ReaConsole has a slightly different title on Mac.
When finding windows by title, it is always safer to use JS_Localize to get the localized title text. I'm not sure if this will solve the problem, but it is worth a try.

Perhaps do a Window_ListAllTop and check the titles of the all the windows in the list?


Quote:
Originally Posted by mespotine View Post
BTW: under which license is your plugin? SWS is MIT-licensed and it would be great, if that would be the case for your plugin too.
I'm asking, as we would love to use your plugin in our distribution of Ultraschall and don't want to run into licensing conflicts.
I haven't really thought about licensing terms or what the different licenses entail, but everyone is very welcome to use this API in any of their scripts (and I would be glad if they do!).
juliansader is offline   Reply With Quote
Old Today, 11:46 AM   #195
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Please correct me if this is wrong.
Scripts run on the single GUI thread correct? So if a script (no defer loops) opens a window the script waits until that window finishes loading and then the script continues onto the next line of code right? Which means I can get the handle of a window I just opened from the script simply using GetForegroundWindow ?

Example,..
Code:
local title, x, y, w, h = "Adjust Envelopes", 200, 100, 300, 50
gfx.init(title, x, y, 0, w, h)
gfx.x, gfx.y = 12, 40
gfx.drawstr("Press Esc when done!")
gfx.update()

hwnd=reaper.JS_Window_GetForeground()
reaper.ShowConsoleMsg(tostring(hwnd) .. "\n")
I was actually surprised opening plugins from scripts the code can find the handle of the window right after opening them, so it must be single threaded, for example in my VS apps I have to actually wait/sleep to give the other window time to load and draw,etc before I can get its window handle.

Last edited by Edgemeal; Today at 12:31 PM.
Edgemeal is offline   Reply With Quote
Old Today, 11:59 AM   #196
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 679
Default

As far as I understood, you can access all windows opened in Windows at least, not only Reaper-windows.

So you can't be sure of what the user does. Opening a gfx-window doesn't necessarily mean, the foreground window is that gfx-window, but can be a texteditor or such.

My code circumvents that. I might add other safety-mechanisms as well to make wrong hwnds even more unlikely.


@juliansader

Quote:
When finding windows by title, it is always safer to use JS_Localize to get the localized title text. I'm not sure if this will solve the problem, but it is worth a try.

Perhaps do a Window_ListAllTop and check the titles of the all the windows in the list?
Good to know. I'm also trying to find a way to get all HWNDs for all Reaper-windows without accidentally getting the wrong one due same-naming and such. So this hopefully helps.
__________________
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 Today, 12:09 PM   #197
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 883
Default

Quote:
Originally Posted by mespotine View Post
As far as I understood, you can access all windows opened in Windows at least, not only Reaper-windows.

So you can't be sure of what the user does. Opening a gfx-window doesn't necessarily mean, the foreground window is that gfx-window, but can be a texteditor or such.
I understand that, was bad example, just really wanted to know if scripts and calling functions from extensions are all running on the same thread.
Edgemeal is offline   Reply With Quote
Old Today, 02:40 PM   #198
tparker24
Human being with feelings
 
Join Date: Dec 2017
Posts: 36
Default Can't get started

I wanted to try ReaScriptAPI, but am having problems just getting started:

1) I couldn't find it on ReaPack.

2) I saw the files on GitHub, but don't know how/where to install them.

3) I want to use this from python, but couldn't find the normal .py interface file.


Can you help me out?
tparker24 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 04:50 PM.


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