Old 10-13-2018, 02:32 PM   #1
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default js_ReaScriptAPI extension

I have uploaded a new extension that may be of interest to other scripters: "js_ReaScriptAPI".

It can be installed via ReaPack (the ReaTeam/Extensions repository will soon be listed among the default repositories; in the meantime, use this URL to add the repository), or via direct download.

The idea behind this extension is to make all the useful and powerful functions that are available to C++ extensions available to ReaScripts too. (The resulting ReaScript API is therefore not the result of my own amazing programming skills, but is mostly just an interface to existing C++ functions.)

The online documentation for the corresponding C++ functions is probably the best place to learn how to use these functions. For example, Window messages and Drawing with GDI.

I have tried to make most functions cross-platform applicable, but I am not able to test the extension on MacOS and Linux, so let me know if anything doesn't work as expected.

Many thanks to cfillion, Xenakios and nofish, who helped me a *lot* to figure out the esoteric mysteries of REAPER extensions.


Here are a few examples:


Attach "pin on top" button to script GUIs

FR: add 'always on top' pin for EEL script GUI's

Code:
w = reaper.JS_Window_Find("MIDI Inspector", true)
if w then reaper.JS_Window_AttachTopmostPin(w) end




Drawing inside REAPER windows

FR: Lasso Select for midi notes





Load custom cursors

FR: ReaScript: Allow scripts to change mouse cursor

Code:
-- Load REAPER's native "arpeggiate" cursor
reaper.JS_Mouse_SetCursor(reaper.JS_Mouse_LoadCursor(502)) 
-- Prevent REAPER from changing cursor back, by intercepting "SETCURSOR" messages
reaper.JS_WindowMessage_Intercept(window, "WM_SETCURSOR", false)




Take control of mouse clicks and mousewheel

By intercepting mouse and mousewheel messages, scripts can be controlled with the mouse, without activating REAPER's own mouse modifier actions.

For example, in my own "Mouse editing" CC scripts, I use code like the following to block the mouse from interacting with the piano roll while the script is running:
Code:
tIntercepts = { WM_LBUTTONDOWN   = false,
	        WM_LBUTTONUP     = false,
	        WM_LBUTTONDBLCLK = false,
	        WM_MBUTTONDOWN   = false,
	        WM_MBUTTONUP     = false,
	        WM_MBUTTONDBLCLK = false,
	        WM_RBUTTONDOWN   = false,
	        WM_RBUTTONUP     = false,
	        WM_RBUTTONDBLCLK = false,
	        WM_MOUSEWHEEL    = false,
	        WM_MOUSEHWHEEL   = false,
	        WM_MOUSEMOVE     = false,
	        WM_SETCURSOR     = false
	      }
midiview = reaper.JS_Window_FromPoint(reaper.GetMousePosition())
for key, value in pairs(tIntercepts) do
    OK = reaper.JS_WindowMessage_Intercept(midiview, key, value)
end
The scripts can then use JS_WindowMessage_Peek to track mouse events while running:
Code:
peekOK, _, time, keys, rotate, x, y = reaper.JS_WindowMessage_Peek(midiview, "WM_MOUSEWHEEL")
if peekOK and time ~= prevTime then
    -- mousewheel has moved since last defer cycle
end
peekOK, _, time, keys, _, x, y = reaper.JS_WindowMessage_Peek(midiview, "WM_LBUTTONDOWN")
if peekOK and time ~= prevTime then
    -- Left button has been pressed
end


MediaExplorer_OnCommand

Send commands to any window, similar to Main_OnCommand and MIDIEditor_OnCommand:
Code:
-- Action 1011 = Autoplay: Toggle on/off
me = reaper.JS_Window_Find("Media Explorer", true)
reaper.JS_WindowMessage_Send(me, "WM_COMMAND", 1011, 0, 0, 0)


Keep the Mixer window out of the way

FR: Plugin windows always on top, Mixer window always behind

The API offers several functions for getting and setting the Z order and focus of windows, so one possible solution for the FR is discussed here:
Move Mixer out of the way: example of Win32/SWELL in ReaScript.



Track mouse events outside script GUI

FR: Exposure of mouse state-functions for non gfx.ini-created windows

In addition to the WindowMessage functions, which are specific to a single target window, the mouse can be tracked using JS_Mouse_GetState:
Code:
-- Flag 0b00000001+0b00010000 = left mouse button + alt key
if reaper.JS_Mouse_GetState(0x0011) = 0x0011 then
   --...
end


Frameless script GUIs

FR: Stylish ReaScript GUIs: Transparent backgrounds and no titlebars

Unfortunately, even with C++ functions, I have not been able to change script GUIs' window style to "frameless" without getting ugly artefacts. However, scripts can fake a frameless style by using the GDI functions to draw over the entire window area, including the frame:


Last edited by juliansader; 10-16-2018 at 03:22 AM.
juliansader is offline   Reply With Quote
Old 10-13-2018, 02:32 PM   #2
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default js_ReaScriptAPI extension

JS_Byte
JS_Double
JS_GDI_Blit
JS_GDI_CreateFillBrush
JS_GDI_CreateFont
JS_GDI_CreatePen
JS_GDI_DeleteObject
JS_GDI_DrawText
JS_GDI_FillEllipse
JS_GDI_FillPolygon
JS_GDI_FillRect
JS_GDI_FillRoundRect
JS_GDI_GetClientDC
JS_GDI_GetScreenDC
JS_GDI_GetSysColor
JS_GDI_GetTextColor
JS_GDI_GetWindowDC
JS_GDI_Line
JS_GDI_Polyline
JS_GDI_ReleaseDC
JS_GDI_SelectObject
JS_GDI_SetPixel
JS_GDI_SetTextBkColor
JS_GDI_SetTextBkMode
JS_GDI_SetTextColor
JS_GDI_StretchBlit
JS_Int
JS_LICE_Arc
JS_LICE_Bezier
JS_LICE_Blit
JS_LICE_Circle
JS_LICE_Clear
JS_LICE_CreateBitmap
JS_LICE_CreateFont
JS_LICE_DestroyBitmap
JS_LICE_DestroyFont
JS_LICE_DrawChar
JS_LICE_DrawText
JS_LICE_FillCircle
JS_LICE_FillPolygon
JS_LICE_FillRect
JS_LICE_FillTriangle
JS_LICE_GetDC
JS_LICE_GetHeight
JS_LICE_GetPixel
JS_LICE_GetWidth
JS_LICE_GradRect
JS_LICE_IsFlipped
JS_LICE_Line
JS_LICE_LoadPNG
JS_LICE_PutPixel
JS_LICE_Resize
JS_LICE_RotatedBlit
JS_LICE_RoundRect
JS_LICE_ScaledBlit
JS_LICE_SetFontBkColor
JS_LICE_SetFontColor
JS_LICE_SetFontFromGDI
JS_MIDIEditor_ArrayAll
JS_MIDIEditor_ListAll
JS_Mouse_GetState
JS_Mouse_LoadCursor
JS_Mouse_LoadCursorFromFile
JS_Mouse_SetCursor
JS_Mouse_SetPosition
JS_PtrFromStr
JS_ReaScriptAPI_Version
JS_WindowMessage_Intercept
JS_WindowMessage_InterceptList
JS_WindowMessage_ListIntercepts
JS_WindowMessage_Peek
JS_WindowMessage_Post
JS_WindowMessage_Release
JS_WindowMessage_ReleaseAll
JS_WindowMessage_ReleaseWindow
JS_WindowMessage_Send
JS_Window_AddressFromHandle
JS_Window_ArrayAllChild
JS_Window_ArrayAllTop
JS_Window_ArrayFind
JS_Window_AttachResizeGrip
JS_Window_AttachTopmostPin
JS_Window_ClientToScreen
JS_Window_Destroy
JS_Window_Enable
JS_Window_Find
JS_Window_FindChild
JS_Window_FromPoint
JS_Window_GetClientRect
JS_Window_GetFocus
JS_Window_GetForeground
JS_Window_GetLongPtr
JS_Window_GetParent
JS_Window_GetRect
JS_Window_GetRelated
JS_Window_GetScrollInfo
JS_Window_GetTitle
JS_Window_HandleFromAddress
JS_Window_IsChild
JS_Window_IsVisible
JS_Window_IsWindow
JS_Window_ListAllChild
JS_Window_ListAllTop
JS_Window_ListFind
JS_Window_Move
JS_Window_RemoveXPStyle
JS_Window_Resize
JS_Window_ScreenToClient
JS_Window_SetFocus
JS_Window_SetForeground
JS_Window_SetPosition
JS_Window_SetScrollPos
JS_Window_SetTitle
JS_Window_SetZOrder
JS_Window_Show

New by Xenakios!
Xen_AudioWriter_Create
Xen_AudioWriter_Destroy
Xen_AudioWriter_Write

Last edited by juliansader; 10-14-2018 at 08:49 AM.
juliansader is offline   Reply With Quote
Old 10-13-2018, 02:35 PM   #3
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,197
Default

Interesting, looks cool!
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 10-13-2018, 03:08 PM   #4
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,299
Default

Holy cow, didn't see THAT coming! Mouse lasso, always on top... Geez Julian, you never cease to amaze me!
__________________
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 10-13-2018, 03:56 PM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,217
Default

Many thx ! This may bring a lot of useful things !



C++ function were recently exposed in SWS but because pull request are very long to be merged, having your extension will definitly be useful
Though I dont see the function for getting bitdepth, which is accessible for C++ and was wating for mege in SWS, is it missing ?



Ill try to add your functions in my reascript doc.
X-Raym is offline   Reply With Quote
Old 10-13-2018, 03:59 PM   #6
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,299
Default

Quote:
Originally Posted by X-Raym View Post
Ill try to add your functions in my reascript doc.
Merci X-Raym!!!
__________________
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 10-13-2018, 04:31 PM   #7
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

AMAZING!!! :O


Well done! A lot of useful stuff in there opening great possibilities!
amagalma is offline   Reply With Quote
Old 10-13-2018, 05:37 PM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,217
Default

js_function v0.93 added to my ReaScript doc !


@_Stevie_
:P
X-Raym is offline   Reply With Quote
Old 10-13-2018, 07:48 PM   #9
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,299
Default

Wow that was fast X-Raym, formidable!!! This is like Xmas in October!
__________________
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 10-13-2018, 08:01 PM   #10
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,299
Default

@Julian: haven't tried it yet, but is it possible to show/hide dockers with your window function? Would love to independently show/hide the left and right docker.
__________________
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 10-13-2018, 09:49 PM   #11
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

WOW!!!

Last edited by NextLevel; 10-13-2018 at 10:16 PM.
NextLevel is offline   Reply With Quote
Old 10-13-2018, 11:21 PM   #12
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

AMAZING !

Can (some of) this also be used with JSFX ?

-Michael
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Old 10-14-2018, 02:42 AM   #13
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

Quote:
Originally Posted by mschnell View Post
Can (some of) this also be used with JSFX ?
JSFX do not have support for 3rd party extensions.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-14-2018, 03:33 AM   #14
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,141
Default

That is rather sad

-Michael
__________________
www.boa-sorte.de
mschnell is offline   Reply With Quote
Old 10-14-2018, 03:57 AM   #15
InfiniteDimensionality
Human being with feelings
 
Join Date: Jun 2017
Posts: 122
Default

Cool,

I wonder if you could extend it a little bit?

Writing in some languages sucks or does not offer as much performance.

Could you potentially extend your plugin to load other plugin compiled in other languages(such as c++/d/haskell/etc)?

The idea is this:

1. You have a context variable that allows any plugin to use to access the methods and variables(an interface basically).

2. You compile the source code when it changes by monitoring any changes and recompiling and loading(this might work only when restarting reaper without some special hot plugging capabilities). You just run a compile string on the code.

3. You load the code, run any setup routines(similar to dll loading). Run some main function(possibly in another thread) and pass it the context.

This then makes it much easier to write programs and even debug them(e.g., with windows one could use VS to debug the program while it is in reaper).

It would allow for much more freedom than using reapers built in scripting, which isn't bad but isn't great(mainly the dev part such as using IDE's and such).

It would also make writing plugins easier in some ways.

Most of the work shouldn't be too difficult(it can be done easily but might be hard to do well).
InfiniteDimensionality is online now   Reply With Quote
Old 10-14-2018, 04:46 AM   #16
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

@juliansader,

Noticed a little typo in the "MediaExplorer_OnCommand" example.

The line "m = reaper.JS_Window_Find("Media Explorer", true)"
should be "me = reaper.JS_Window_Find("Media Explorer", true)"

This extension is going to open up some nice possibilities, so thank you so much!

Just added your "pin to top" example to Lokasenna's Radial Menu.., yea!!!
NextLevel is offline   Reply With Quote
Old 10-14-2018, 04:50 AM   #17
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,217
Default

Quote:
Could you potentially extend your plugin to load other plugin compiled in other languages(such as c++/d/haskell/etc)?
ReaScript already supports Lua and Python, I don't think there is a lot of demand for other languages.



Quote:
Most of the work shouldn't be too difficult
You seems to have a lot of knowledge about programming, so why no you take a try to do this ?
Juliansader extension is open source, you can work from there.
X-Raym is offline   Reply With Quote
Old 10-14-2018, 05:13 AM   #18
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

Quote:
Originally Posted by X-Raym View Post
js_function v0.93 added to my ReaScript doc !

Where are they? I can't find them
amagalma is offline   Reply With Quote
Old 10-14-2018, 05:16 AM   #19
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

In case someone has been confused : "js" here comes from "Julian Sader", it has nothing to do with JesuSonic or JavaScript...

The extension plugin adds new API functions that can be used with ReaScript, no new features visible for the end user are added by only installing the plugin.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-14-2018, 06:38 AM   #20
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

Is there a way to set mouse position relative to a specific window?
Meaning that even if the window is in a different position each time the script is executed it will always set the mouse to the same position within that window.
NextLevel is offline   Reply With Quote
Old 10-14-2018, 06:54 AM   #21
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Amazing. Kudos for the work you've put into this!

Quote:
Originally Posted by juliansader View Post
Attach "pin on top" button to script GUIs

FR: add 'always on top' pin for EEL script GUI's
I'd tend to suggest all ReaScripters having scripts with GUI's to update their scripts to add the 'always on top' pin.

Last edited by nofish; 10-14-2018 at 07:36 AM.
nofish is offline   Reply With Quote
Old 10-14-2018, 07:10 AM   #22
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by X-Raym View Post
Though I dont see the function for getting bitdepth, which is accessible for C++ and was wating for mege in SWS, is it missing ?
This came from cfillion and is still waiting for merge in SWS.
https://github.com/reaper-oss/sws/pull/1011
nofish is offline   Reply With Quote
Old 10-14-2018, 08:31 AM   #23
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by amagalma View Post
Where are they? I can't find them
nofish is offline   Reply With Quote
Old 10-14-2018, 09:21 AM   #24
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Updated to v0.94 with new WAV writer functions by Xenakios, and a bugfix in JS_Window_GetRelated.


Quote:
Originally Posted by NextLevel View Post
Is there a way to set mouse position relative to a specific window?
Meaning that even if the window is in a different position each time the script is executed it will always set the mouse to the same position within that window.
Sure: Get the window's screen coordinates using JS_Window_GetRect or JS_Window_GetClientRect, and then move the mouse using JS_Mouse_SetPosition.


Quote:
Originally Posted by _Stevie_ View Post
@Julian: haven't tried it yet, but is it possible to show/hide dockers with your window function? Would love to independently show/hide the left and right docker.
I'll have to check -- I have never tried this before via scripts.
juliansader is offline   Reply With Quote
Old 10-14-2018, 09:48 AM   #25
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,299
Default

@Julian

The problem seems, that Reaper does not differentiate between lower, upper, left or right docker.
https://forum.cockos.com/showpost.ph...9&postcount=19

But I will give it a shot, when I got a bit more time!
__________________
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 10-14-2018, 09:58 AM   #26
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

Quote:
Originally Posted by juliansader View Post
Updated to v0.94 with new WAV writer functions by Xenakios,
I will post a Lua ReaScript example for using this soon somewhere.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-14-2018, 10:34 AM   #27
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

Strange... Here the page opens with v5.95 without the js functions.. I wonder why...

Quote:
Originally Posted by nofish View Post
Cleaning the history and re-opening the browser, fixed it Well-done X-Raym!
amagalma is offline   Reply With Quote
Old 10-14-2018, 10:46 AM   #28
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by _Stevie_ View Post
@Julian

The problem seems, that Reaper does not differentiate between lower, upper, left or right docker.
https://forum.cockos.com/showpost.ph...9&postcount=19

But I will give it a shot, when I got a bit more time!
As Breeder noted, "under the hood", REAPER does distinguish between the dockers and they have different window HWNDs, so it should be possible to selectively access them.

Two other useful remarks that I noticed in the other thread:
Quote:
Originally Posted by Garrick View Post
So as it stands, the only way a dock position is hidden is if it contains no tabs.
Quote:
Originally Posted by Breeder View Post
and exists even if you don't use it, it's just hidden...windows are called "REAPER_dock", have a look yourself if you don't believe me
So I guess you can find specific dockers in at least two ways:
1) Find all the windows named "REAPER_dock", get their coordinates, and check which are positioned at the edges of the main window.
2) If specific windows (such as Actions) are always docked in specific dockers (such as the left docker), you can instead find the window, then find the REAPER_dock that is its parent.

To hide the docker, you can't destroy the docker itself (or its necessary child windows), but must instead destroy the tabs.

I checked the docker's child windows, and it seems that its frame is named "Custom" something.

The following code seems to work to close the docker under the mouse:

Code:
w = reaper.JS_Window_FromPoint(reaper.GetMousePosition())
::getParentDock::
    if not w then return end
    t = reaper.JS_Window_GetTitle(w, "")
    if t == "REAPER_dock" then goto gotDock end
    w = reaper.JS_Window_GetParent(w)
    goto getParentDock
::gotDock::

a = reaper.new_array({}, 100)
reaper.JS_Window_ArrayAllChild(w, a)
tHandles = a.table()
tTitles = {}
for i = 1, #tHandles do
    tHandles[i] = reaper.JS_Window_HandleFromAddress(tHandles[i])
    tTitles[i]  = reaper.JS_Window_GetTitle(tHandles[i], "")
end
for i = 1, #tHandles do
    if not tTitles[i]:match("Custom") then reaper.JS_Window_Destroy(tHandles[i]) end
end
* Alternatively, you can probably JS_WindowMessage_Send some WM_COMMAND message to simulate the menu item "Close all windows in dock".

* JS_Window_Show(dockerHWND, "HIDE") can hide the docker and JS_Window_Show(dockerHWND, "SHOW") can show it again, but the track view doesn't expand after hiding the docker, so these functions alone aren't enough.

We will have to experiment some more...

Last edited by juliansader; 10-14-2018 at 12:29 PM.
juliansader is offline   Reply With Quote
Old 10-14-2018, 02:21 PM   #29
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 587
Default

This! Is! Awesome!

Thank you for your work

Under which license do you release the Plugin? Opensource-MIT-license or something similar? Couldn't find a reference to it in the sources.

Do you intend to expose the OSC-related functions as well?

And is there a chance for adding the pending API-SWS-functions from nf or cf to this plugin as well?

And a small little request: Could you add a "GetJSReaScriptAPIVersion()"-function? So I can check, whether a version of your plugin is supported by my script.

Again..fantastic work
__________________
Lua Coders of the world: UNITE!
This Saturday, 11am NewYorkCity time, head over to this thread:
https://forum.cockos.com/showthread....98#post2067798

Last edited by mespotine; 10-14-2018 at 02:27 PM.
mespotine is offline   Reply With Quote
Old 10-14-2018, 04:47 PM   #30
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Quote:
Originally Posted by mespotine View Post
And a small little request: Could you add a "GetJSReaScriptAPIVersion()"-function?
https://www.extremraym.com/cloud/rea...iptAPI_Version
nofish is offline   Reply With Quote
Old 10-14-2018, 05:06 PM   #31
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

I didn't have the time yet to try things.. But is it possible now to get somehow what is selected?

amagalma is offline   Reply With Quote
Old 10-14-2018, 07:27 PM   #32
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

Quote:
Originally Posted by juliansader View Post

Sure: Get the window's screen coordinates using JS_Window_GetRect or JS_Window_GetClientRect, and then move the mouse using JS_Mouse_SetPosition.
Awesome, thank you.
NextLevel is offline   Reply With Quote
Old 10-15-2018, 12:38 AM   #33
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 2,746
Default

Just WOW!! Thank you - I'll be looking into this soon.

Before I've managed to have a detailed look - is there a way of telling if the extension is installed or not to know whether a script can use the new available functions? I guess this would need to be a native Reaper function.

I like the look of Window_Resize and Move - does this mean a script can resize it's own GUI window?

EDIT: Oooh - just also notice MOUSE_SetPosition - one I've been wanting for a loooong time

Thank you again! This is going to be massively useful!
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal

Last edited by lb0; 10-15-2018 at 12:51 AM.
lb0 is offline   Reply With Quote
Old 10-15-2018, 02:30 AM   #34
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,304
Default

Quote:
Originally Posted by lb0 View Post
Before I've managed to have a detailed look - is there a way of telling if the extension is installed or not to know whether a script can use the new available functions? I guess this would need to be a native Reaper function.
Nonexistent API functions evaluate to nil (also there's APIExists).
cfillion is online now   Reply With Quote
Old 10-15-2018, 03:18 AM   #35
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 2,746
Default

Quote:
Originally Posted by cfillion View Post
Nonexistent API functions evaluate to nil (also there's APIExists).
Aha - of course! Thank you. Remind me to wake up properly and engage brain before asking questions. I knew about and use the API_Exists function already - but did not know about the evaluate to nil - so have learned something
__________________
Projects - Reascripts - Lua:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 10-15-2018, 04:24 AM   #36
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

Just did an experiment and found that Parameter Modulation windows can be made to have a "pin to top" added.., how awesome is that?!!!
I always hated having those windows get lost behind other windows.

Now, perhaps someone with better reascript skills than myself could find a way to aggregate any open Param. Mod. windows and add a "pin to top" to all at once?
NextLevel is offline   Reply With Quote
Old 10-15-2018, 05:01 AM   #37
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by lb0 View Post
I like the look of Window_Resize and Move - does this mean a script can resize it's own GUI window?
Yep.

Besides checking and resetting window size and position in each defer cycle, you can prevent a user from changing the size or position of the window by dragging on the frame by blocking "WM_NCLBUTTONDOWN" mouse events:
Code:
iOK = reaper.JS_WindowMessage_Intercept(window, "WM_NCLBUTTONDOWN", false)
If you block these messages, you will probably have to check for clicks on the "Close" button yourself.

(There may be other, better ways to prevent resizing that I am not familiar with. Unfortunately, window frame styles don't seem to be cross-platform applicable.)

Last edited by juliansader; 10-15-2018 at 05:17 AM.
juliansader is offline   Reply With Quote
Old 10-15-2018, 05:06 AM   #38
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,217
Default

Quote:
Now, perhaps someone with better reascript skills than myself could find a way to aggregate any open Param. Mod. windows and add a "pin to top" to all at once?

This really should be handle by REAPER natively IMHO, we will end up with a looooot of defer background scripts and start up actions if we start adding small things like that ^^
X-Raym is offline   Reply With Quote
Old 10-15-2018, 05:31 AM   #39
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

Quote:
Originally Posted by X-Raym View Post
This really should be handle by REAPER natively IMHO, we will end up with a looooot of defer background scripts and start up actions if we start adding small things like that ^^
Yeah, one should not go crazy with the background scripts. They run in the GUI thread with a timer and will eat up GUI CPU cycles from Reaper and audio plugins...
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 10-15-2018, 05:56 AM   #40
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

Quote:
Originally Posted by X-Raym View Post
This really should be handle by REAPER natively IMHO, we will end up with a looooot of defer background scripts and start up actions if we start adding small things like that ^^
It wouldn't need to be a deferred script, it would just run once and gather a list of all open Param. Mod. windows then add a pin to them, the script would then end. Obviously if you close any of them and reopen you lose the pin and have to rerun the script, but that's no big deal.

Anyone want to give it a shot?
NextLevel 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 07:46 PM.


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