|
|
|
11-21-2019, 10:58 AM
|
#801
|
Human being with feelings
Join Date: Oct 2014
Posts: 77
|
Help using JS_ReascriptAPI
Hi there.
I would like to use some of the functions like JS_Dialog_BrowseForFolder with Python.
I installed the package from Reapack and restarted Reaper. The functions are listed in the Reascript documentation generated by my current Reaper setup.
As far as I understand I only have to call it as it is, without the usual RPR_ prefix.
So I would simply call:
Code:
( retval, caption, initialFolder, folderOutNeedBig, folderOutNeedBig_sz ) = JS_Dialog_BrowseForFolder("hop", "./C", "", "" )
This gives the following error:
---
Script execution error
Traceback (most recent call last):
File "testFolderSelect.py", line 4, in <module>
( retval, caption, initialFolder, folderOutNeedBig, folderOutNeedBig_sz ) = JS_Dialog_BrowseForFolder("hop", "./C", "", "" )
NameError: name 'JS_Dialog_BrowseForFolder' is not defined
---
What am I missing?
C
|
|
|
11-21-2019, 11:03 AM
|
#802
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by Cedrik0s
As far as I understand I only have to call it as it is, without the usual RPR_ prefix.
|
Try with the RPR_ prefix. (It could be possible that the JS extension has not been tested to work with Python, though.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
11-21-2019, 11:05 AM
|
#803
|
Human being with feelings
Join Date: Oct 2014
Posts: 77
|
Quote:
Originally Posted by Xenakios
Try with the RPR_ prefix.
|
Thanks for your answer Xenakios.
I did with RPR_JS_, RPR_, JS_ ...
Always the same error.
|
|
|
11-21-2019, 11:23 AM
|
#804
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Xenakios
Try with the RPR_ prefix. (It could be possible that the JS extension has not been tested to work with Python, though.)
|
I haven't yet used Python with REAPER, and unfortunately have no idea whether the extension is compatible with Python.
|
|
|
11-21-2019, 12:24 PM
|
#805
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
Afaik, there's a file for that, which needs to be added and includes all functions-declarations.
There's already one included with SWS and Reaper:
reaper_python.py
sws_python.py
sws_python64.py
so I think, one like that would be needed for JS-extension too.
Somewhere in this thread, someone made such a file, but it's for an older version and I don't remember, which post it had...
|
|
|
11-21-2019, 12:51 PM
|
#806
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,109
|
Quote:
Originally Posted by mespotine
Afaik, there's a file for that, which needs to be added and includes all functions-declarations.
There's already one included with SWS and Reaper:
reaper_python.py
sws_python.py
sws_python64.py
so I think, one like that would be needed for JS-extension too.
Somewhere in this thread, someone made such a file, but it's for an older version and I don't remember, which post it had...
|
This one is the latest I think (at least I haven't spotted any newer ones here):
https://stash.reaper.fm/v/36404/js_ReaScriptAPI.py
@juliansader
If you consider providing the Python function wrappers in the future, as mentioned in the related post they are quite straightforward to generate using the Perl scripts SWS is also using to generate them.
edit:
@Cedrik0s
Where to put that file and a simple Python test script can also be found in above post.
Last edited by nofish; 11-21-2019 at 03:00 PM.
|
|
|
11-21-2019, 05:17 PM
|
#807
|
Human being with feelings
Join Date: Oct 2014
Posts: 77
|
Since the JS functions are listed in the generated documentation, I took it for granted it was supported for python.
Anyway it is great news to see it somehow is, and I will check the other thread as soon as I can.
Thank you all!
PS : if there is any other way to get basic select file/folder dialog from a python reascript, I'd be glad to know!
|
|
|
11-21-2019, 05:25 PM
|
#808
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,630
|
For file, you can use:
https://mespotin.uber.space/Ultrasch...ileNameForRead
It only allows selecting one file and you cannot use it for selecting non-existant files(which is essential for file-save).
For folder, nothing of that exists.
But, if you only need that for your own scripts, you could use GetUserFileNameForRead, select a file and extract the path from the selected file. Would be a hack, though, but could work, unless the folder is empty.
|
|
|
11-24-2019, 04:23 AM
|
#809
|
Human being with feelings
Join Date: Oct 2014
Posts: 77
|
Thanks mespotine.
GetUserFileNameForRead could be a solution for single file selection indeed.
Btw, your documentation with comments (i.e. documention ) is nice!
I have yet to try the js_ReaScriptAPI.py.
Will do.
Thanks all.
C
|
|
|
12-05-2019, 04:21 AM
|
#810
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,175
|
Hi Julian,
I'm trying to overlay part of a JSFX GUI over one of my script GUIs. I've currently tried a lot of things and none are perfect.
Most success has been had by creating a an 'overlay' window and GDI blitting between the JSFX window and the new overlay window and keeping that on top of my script gui using TOPMOST. But this isn't ideal as it sits over other windows that I don't want it to sit over - I simply want it to sit above just my script GUI window and no others. I've tried writing code to release the TOPMOST flag of the created window when other windows have the focus - but it's clunky and doesn't work perfectly - depending on what window has focus - the overlay window sometimes falls behind the script GUI - especially when it's docked.
I've tried the Composite LICE bitmap method - but being on WindowsOS - this is headache inducing with the amount of flicker.
So I've had another idea and I don't know if it is feasible - but you might. Is it possible to set the overlay window as a child of my script GUI window using something like SetParent Windows API? I don't know whether this would work as it may depend on the window process ownership of the window. Any thoughts? Obviously the SetParent API isn't available in your API - and I wondered if there was any reason? If the overlay window was able to be made a child window - could it somehow be hooked into keeping it's relative location with the parent script GUI window?
Can you think of any other way of keeping the overlay window just above my script GUI without using TOPMOST which might work more consistently?
Cheers,
L.
Overlay window :
I also created a LICE gif of the flickery Composite method - but interestingly the GIF doesn't show the flicker (possibly framerate or LICE related).
|
|
|
12-07-2019, 03:35 PM
|
#811
|
Human being with feelings
Join Date: Feb 2017
Posts: 54
|
JS api calls into other C++ extensions?
@Julian
Julian, your API is awesome!!! I use it everyday. I was wondering, do you have any thoughts on letting us add your API to other c++ extensions? I have a reaper extension right now that I'm trying to figure out how to take away the reaconsole window. I know ultraschall does it, but it would be in lua and not through c++. I see he is using your JS window functions to get this to work, but I can't call your functions in c++ without somehow adding your library somewhere. Are you thinking of exposing an API list directly from c++ sometime?
Thanks for all the magic work!
|
|
|
12-07-2019, 03:41 PM
|
#812
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,968
|
You can just use the Win32 API directly in C++. (You can use extension-provided API functions too, as long as you import them after they were registered.)
Last edited by cfillion; 12-07-2019 at 04:23 PM.
|
|
|
12-07-2019, 03:56 PM
|
#813
|
Human being with feelings
Join Date: Feb 2017
Posts: 54
|
@Julian
Nevermind! I found Julian's github repository!
Yeah, I just wanted to see how Julian was going about getting the window information as a starting point!
|
|
|
12-08-2019, 12:14 PM
|
#814
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by lb0
So I've had another idea and I don't know if it is feasible - but you might. Is it possible to set the overlay window as a child of my script GUI window using something like SetParent Windows API? I don't know whether this would work as it may depend on the window process ownership of the window. Any thoughts? Obviously the SetParent API isn't available in your API - and I wondered if there was any reason? If the overlay window was able to be made a child window - could it somehow be hooked into keeping it's relative location with the parent script GUI window?
Can you think of any other way of keeping the overlay window just above my script GUI without using TOPMOST which might work more consistently
|
Unfortunately I don't know if the SetParent approach will work, but it is worth a try! I will add SetParent to the next update of the extension.
|
|
|
12-09-2019, 08:11 AM
|
#815
|
Human being with feelings
Join Date: Aug 2011
Posts: 522
|
Peeps,
Wouldnt it be nice if we could zoom in/out on different things with the same mousewheel shortcut inside the midi editor? So if your mouse cursor is on the regular midi view you zoom horizontally as usual, but if you hover over the piano keys on the left you do vertical zooming with the same mousewheel+key combination, if you are on a certain MIDI lane you just increase/decrease the height of that CC lane only, etc.
I was trying to find the different windows with Spy++ but all the left frame (midipianoview) of the midi editor is the same window (so, there´s no difference between the piano notes and the velocity/CC lanes). Also looks like the central part(midiview) is a big block as well - no difference between the piano and the cc/vel editing area.
So is that an unfeasible task with Reascript and this extension?
|
|
|
12-09-2019, 10:29 AM
|
#816
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
This is indeed how I have set up my own mousewheel in the MIDI editor.
However, you don't need the js_ReaScriptAPI extension -- only SWS: Use BR_GetMouseCursorContext() and BR_GetMouseCursorContext_MIDI() to get the part of the MIDI editor under the mouse, and then call the appropriate action from the Actions list with MIDIEditor_OnCommand.
|
|
|
12-09-2019, 03:33 PM
|
#817
|
Human being with feelings
Join Date: Oct 2014
Posts: 77
|
Quote:
Originally Posted by Cedrik0s
I have yet to try the js_ReaScriptAPI.py.
|
I finally tried and it just works!
Thanks everyone!
C
|
|
|
12-09-2019, 04:58 PM
|
#818
|
Human being with feelings
Join Date: Apr 2014
Posts: 4,175
|
Quote:
Originally Posted by juliansader
Unfortunately I don't know if the SetParent approach will work, but it is worth a try! I will add SetParent to the next update of the extension.
|
Oh wow - thanks!
I have my doubts as to whether it will work without further involvement with the OSs API - but if it's not too much hassle for you to add the SetParent option - then I'll give it a try.
It's a real shame the elegant Composite bitmap solution doesn't work for Windows (in my use case) - as if it wasn't for the flicker - it would be perfect!
Another wish would be for LICE bitmaps to be compatible with Reascripts native bitmaps (ie. blittable into one of the 1024 script bitmaps) - that would also solve the problem - but knowing nothing about the two formats - I guess they're not easily interchangeable (although how different can bitmap formats be assuming they are not compressed in any way and use the same bit depth?).
Anyway - I look forward to trying SetParent... Thanks again.
|
|
|
12-11-2019, 05:02 AM
|
#819
|
Human being with feelings
Join Date: Dec 2018
Posts: 39
|
Dear friends! Please tell me. How to send ctrl+alt+left mouse click to specified window.I`ve tried this but only click is sent (
Code:
x,y = reaper.GetMousePosition()
frompoint = reaper.JS_Window_FromPoint(x,y)
trw=frompoint
x_trw, y_trw = reaper.JS_Window_ScreenToClient( trw, x, y )
reaper.JS_Window_SetFocus(trw)
reaper.JS_WindowMessage_Post(trw, "WM_KEYDOWN", 17, 0, 0, 0)
reaper.JS_WindowMessage_Post(trw, "WM_KEYDOWN", 18, 0, 0, 0)
reaper.JS_WindowMessage_Post(trw , "WM_LBUTTONDOWN", 8, 0, x_trw, y_trw)
reaper.JS_WindowMessage_Post(trw , "WM_LBUTTONUP", 8, 0, x_trw, y_trw)
|
|
|
12-11-2019, 11:32 AM
|
#820
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
Is there a way to know on a text field at which character position the TEXT CARRET "ⵊ" cursor is ?
Thx!
|
|
|
12-11-2019, 01:37 PM
|
#821
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
|
Quote:
Originally Posted by X-Raym
Is there a way to know on a text field at which character position the TEXT CARRET "ⵊ" cursor is ?
Thx!
|
Maybe Try EM_GETSEL, something like this, using search box in explorer as test....
Code:
EM_GETSEL = "0x00B0"
local explorer = reaper.OpenMediaExplorer("", false)
if explorer then
local search = reaper.JS_Window_FindChildByID(explorer, 1015)
local retval = reaper.JS_WindowMessage_Send(search, EM_GETSEL, 0,0,0,0)
local caret_pos = retval & 0xFFFF
msg(caret_pos)
end
|
|
|
12-11-2019, 06:02 PM
|
#822
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@edgemeal
Many thanks !!
What do you think of that ? :P
(edit: just noticed SWS window dont refresh but I found a way)
(subtitle workflow)
Note to get the SWS notes window I simply use
Code:
local sws_notes_hwnd = reaper.JS_Window_Find( "Notes", true )
if sws_notes_hwnd then
local sws_notes_edit_hwnd = reaper.JS_Window_FindChildByID(sws_notes_hwnd, 1096)
if not sws_notes_edit_hwnd then return end
Do you think it is enough or that I should use a more solid solution ?
|
|
|
12-11-2019, 06:45 PM
|
#823
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
|
Quote:
Originally Posted by X-Raym
Do you think it is enough or that I should use a more solid solution ?
|
If 'Notes' is never docked then you could use 'reaper.JS_Window_ FindTop', which may be hair faster/more efficient, otherwise should be fine.
Edit, Thats assuming Julian's code is optimized , not sure what he's using for Find and FindTop.
Last edited by Edgemeal; 12-12-2019 at 06:57 AM.
|
|
|
12-12-2019, 09:04 AM
|
#824
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,900
|
@Edgemeal
Just a precision on the Carret pos thing,
the pos consider UTF8 length,
So I used UTF-8 compatible sub and length function,
the native Lua ones didn't work well.
(these functions can be found in my Set uppercase scripts).
|
|
|
12-13-2019, 05:49 AM
|
#825
|
Human being with feelings
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
|
Does any one know if the Move Mixer out of the way function (mentionned by julian in OP) has support in the builtin sws new release?
|
|
|
12-13-2019, 12:05 PM
|
#826
|
Human being with feelings
Join Date: Dec 2018
Posts: 39
|
Guys please! Is this even possible? To send ctrl+alt+left mouse click to an window with js_ReaScriptAPI
Two days of search returned no results (
|
|
|
12-13-2019, 01:05 PM
|
#827
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by AndrewFalcon
Guys please! Is this even possible? To send ctrl+alt+left mouse click to an window with js_ReaScriptAPI
Two days of search returned no results (
|
The standard WM_LBUTTONDOWN window message can include flags for Shift and Ctrl, but unfortunately not for Alt.
I'm not sure if Alt can be sent via WM_KEYDOWN messages -- I've tried sending keystrokes to REAPER windows before, but without much success.
|
|
|
12-13-2019, 01:10 PM
|
#828
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by D Rocks
Does any one know if the Move Mixer out of the way function (mentionned by julian in OP) has support in the builtin sws new release?
|
Are you referring to a new SWS function, or to the ReaScriptAPI code?
|
|
|
12-13-2019, 02:23 PM
|
#829
|
Human being with feelings
Join Date: Dec 2018
Posts: 39
|
Quote:
Originally Posted by juliansader
The standard WM_LBUTTONDOWN window message can include flags for Shift and Ctrl, but unfortunately not for Alt.
I'm not sure if Alt can be sent via WM_KEYDOWN messages -- I've tried sending keystrokes to REAPER windows before, but without much success.
|
Thank you Julian!
I will try it.
Some stackoverflow answers advice to use keybd_event instead SendMessage
https://docs.microsoft.com/en-us/win...er-keybd_event
Can we do it via js_ReaScriptAPI?
|
|
|
12-14-2019, 05:46 AM
|
#830
|
Human being with feelings
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
|
Quote:
Originally Posted by juliansader
Are you referring to a new SWS function, or to the ReaScriptAPI code?
|
Im not so sure but I ask because I remember that in the time you posted it (Move mixer behind FX script), the script you provided needed your custom SWS release.
So I am wondering if that custom part of you is now integrated in the latest SWS version that we can download from the website?
|
|
|
12-14-2019, 06:57 AM
|
#831
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by D Rocks
Im not so sure but I ask because I remember that in the time you posted it (Move mixer behind FX script), the script you provided needed your custom SWS release.
So I am wondering if that custom part of you is now integrated in the latest SWS version that we can download from the website?
|
I moved everything to the separate ReaScriptAPI extension, so the custom SWS version is not required any more.
|
|
|
12-14-2019, 08:46 AM
|
#832
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
|
Quote:
Originally Posted by juliansader
|
But I don't think those flags cause any actual key messages, I've never seen them have any effect on any software. Doing a quick test in vb.net shows no sign of the target window receiving any key msgs either.
|
|
|
12-14-2019, 08:07 PM
|
#833
|
Human being with feelings
Join Date: May 2019
Location: Los Angeles, CA
Posts: 161
|
For this one:
Code:
reaper.JS_VKeys_GetState(number cutoffTime)
I'm having difficulty divining what the "cutoff time" actually is. The API docs say it can be either absolute/relative, but what does this mean in practice? My gut feels that it's listening to see if the state of the particular byte has changed since the cutoff time (i.e. it's buffering strokes, and then examining their timestamps retroactively) - but I'm not able to get meaningful results by altering this value.
The snippets out there perform a lot of formatting to the value that gets passed in, which makes it tough to tell what it is. Any pointers appreciated
|
|
|
12-14-2019, 08:33 PM
|
#834
|
Human being with feelings
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
|
Quote:
Originally Posted by juliansader
I moved everything to the separate ReaScriptAPI extension, so the custom SWS version is not required any more.
|
Thx for your reply.
Although I wonder why the script does not work any more?
Code:
-- Move Mixer window (undocked) to the back when shortcut is pressed
MixerWindow = reaper.Window_Find("Mixer", true)
if MixerWindow then reaper.Window_SetZOrder(MixerWindow, "INSERT_AFTER", reaper.GetMainHwnd(), 0x0010) end
reaper.defer(function() end)
How would I make it work since it can't find reaper.Window_Find fonction ?
|
|
|
12-15-2019, 10:50 AM
|
#835
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
|
Quote:
Originally Posted by D Rocks
How would I make it work since it can't find reaper.Window_Find fonction ?
|
Look in the Reascript docs... REAPER menu > Help > Reascript documentation. Search for the functions by name, IIRC Julian's extension function names are prefixed with 'JS_', that's why that code can't find them. Also the code you show may need to be updated to work since some of the functions have changed, either way you need to read the documentation.
|
|
|
12-15-2019, 12:01 PM
|
#836
|
Human being with feelings
Join Date: May 2019
Location: Los Angeles, CA
Posts: 161
|
Quote:
Originally Posted by TabbyCat
For this one:
Code:
reaper.JS_VKeys_GetState(number cutoffTime)
I'm having difficulty divining what the "cutoff time" actually is.
|
OK Grandpa figured it out - don't use LUA's os.time, use Reaper's time_precise()...unless you like polling in 1000ms intervals
Sorry, familiar with programming but new to LUA. Didn't think the native function would have such a dull resolution.
[slinks back under woodpile]
Thanks for the API Julian, it's great! I can do all my fav Win32 acrobatics!
|
|
|
12-15-2019, 12:19 PM
|
#837
|
Human being with feelings
Join Date: Dec 2017
Location: Quebec, Canada
Posts: 550
|
Quote:
Originally Posted by Edgemeal
Look in the Reascript docs... REAPER menu > Help > Reascript documentation. Search for the functions by name, IIRC Julian's extension function names are prefixed with 'JS_', that's why that code can't find them. Also the code you show may need to be updated to work since some of the functions have changed, either way you need to read the documentation.
|
thanks
|
|
|
12-23-2019, 10:29 AM
|
#838
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
Are there any changes to WindowMessage_PassThrough API?
Code:
if track_part == "LOWER" then
reaper.JS_WindowMessage_PassThrough(track_window, "WM_LBUTTONDOWN", false)
elseif track_part == "UPPER" then
reaper.JS_WindowMessage_PassThrough(track_window, "WM_LBUTTONDOWN", true)
end
This does not do anything ? Should be blocking mouse click. Its looped while the mouse is down so not sure why its not working.
|
|
|
12-23-2019, 11:45 AM
|
#839
|
Human being with feelings
Join Date: May 2019
Location: Los Angeles, CA
Posts: 161
|
May be obvious, but - do you have a valid intercept already set to that handle?
It's not clear to me what the purpose of that PassThrough function is, since it has exactly the same number of args as reaper.JS_WindowMessage_Intercept and they both return an integer. I'm not sure if there's any performance/readability difference between trying to set the flag on an existing intercept, vs creating/destroying one outright...so I've just been using the latter function.
|
|
|
12-23-2019, 12:03 PM
|
#840
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,689
|
This code worked as is in my script,not sure if something updated broke it
EDIT:
Really not sure what I'm doing wrong... I cannot do any intercept of any kind (mouse).
Any example how to block LMB ?
Last edited by Sexan; 12-23-2019 at 02:05 PM.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 11:16 PM.
|