Old 10-15-2018, 08:35 AM   #41
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 584
Default

@nofish
Thnx, missed that one amog the 100+functions

@JS
I found some issues yesterday while experimenting, but I'm still not sure, whether it's me not getting it or a bug.

Some of the functions want "void" as datatype in their functions(at least, the error-message tells that), I found that with several functions that want HDCs or HWNDs as parameters.
They should return as error-message the type they actually want, even if it's called "Identifier" or something to make debugging easier.
Will check that more in detail to give you a more detailed report.


JS_LICE_Blit()
When passing a HWND as parameter destBitmap, the script crashes Lua, and I can't restart the script anymore, that includes that faulty line, until I restart Reaper.
Maybe it would be a good idea to include a check, if the parameter is a valid bitmap, to prevent such things.


Is there a way to remove the pin from a window again?

Is there a chance to include another function, that returns keyboard inputs, maybe for UNICODe characters and for multiple keys as well? The gfx.getchar doesn't support multikey-inputs and has big problems with UNICODE-stuff

And is there a documentation on how to build it on Win and Mac? I would love to attempt adding some more functions myself but want to check the builds before submitting any commits...
__________________
Lua Coders of the world: UNITE!
This Saturday, 11am NewYorkCity time, head over to this thread:
https://forum.cockos.com/showthread....98#post2067798
mespotine is online now   Reply With Quote
Old 10-15-2018, 09:49 AM   #42
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.
Was wondering if you could post an example?
My goal is to be able to send a mouse click to a vst parameter(it's a button that can't normally be automated), however the vst's gui may be located in a different place each time the script is ran.

Thank you
NextLevel is offline   Reply With Quote
Old 10-15-2018, 12:37 PM   #43
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by mespotine View Post
Some of the functions want "void" as datatype in their functions(at least, the error-message tells that), I found that with several functions that want HDCs or HWNDs as parameters.
They should return as error-message the type they actually want, even if it's called "Identifier" or something to make debugging easier.
...
Maybe it would be a good idea to include a check, if the parameter is a valid bitmap, to prevent such things.
This is a known problem: The API can only pass void* and cannot distinguish between the different pointer types. The script coder must be very careful!
FR: Extension API: Validation for custom pointer types
SWS ReaScript: How to pass HWND from Lua to C++: Unknown type HWND

I'll think about ways to safely test pointers. In the case of HWNDs, it is possible to check using IsWindow, but this function is relatively slow on Mac and Linux, so I thought it would be better to leave it in the hands of the scripter.


Quote:
JS_LICE_Blit()
When passing a HWND as parameter destBitmap, the script crashes Lua, and I can't restart the script anymore, that includes that faulty line, until I restart Reaper.
LICE_Blit blits between LICE bitmaps, and GDI_Blit blits between two device contexts (retrieved by LICE_GetDC for a system bitmap, or GDI_GetWindowDC and GDI_GetClientDC for windows on the screen).


Quote:
Is there a way to remove the pin from a window again?
Not AFAIK. (I haven't thought about this, though.)


Quote:
Is there a chance to include another function, that returns keyboard inputs, maybe for UNICODe characters and for multiple keys as well? The gfx.getchar doesn't support multikey-inputs and has big problems with UNICODE-stuff
Capturing keyboard input is one of the things that I couldn't get working. REAPER doesn't seem to send keyboard input into the normal message queue. (If anyone has advice on how to capture keyboard input, please let me know!)


Quote:
And is there a documentation on how to build it on Win and Mac? I would love to attempt adding some more functions myself but want to check the builds before submitting any commits...
1) Check out the threads in the developer subforum, where I asked many questions about this.
2) Clone the files at https://github.com/juliansader/js_ReaScriptAPI, where I have uploaded the minimum necessary files, as well as the build commands for Mac and Linux in the .travis.yml file.
juliansader is online now   Reply With Quote
Old 10-15-2018, 12:39 PM   #44
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by doppelganger View Post
Helloo, will there be a 64 bit version for linux?
I am pleased to see some Linux users around here! I uploaded a x64 build for Linux.


Quote:
Or may some instruction for newbies, how to build it on different OSes? I tried to build 64 bit, but reaper doesn't see functions anyway. Thanks!
See my answer to mespotine above. I myself am building "blind", since I can't test on Mac and Linux. Please let me know whether the Linux build actually works.

Last edited by juliansader; 10-15-2018 at 01:26 PM.
juliansader is online now   Reply With Quote
Old 10-15-2018, 02:02 PM   #45
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by NextLevel View Post
Was wondering if you could post an example?
My goal is to be able to send a mouse click to a vst parameter(it's a button that can't normally be automated), however the vst's gui may be located in a different place each time the script is ran.
To do this, you don't need to move the mouse: instead, post a "WM_LBUTTONDOWN" message with the button coordinates to the window to simulate a mouse click, and then a "WM_LBUTTONUP" to lift the mouse button again.

AFAIK, you must send the message to the child window that contains the button, not the top-level VST window. To get this window -- as long as the VST window is not hidden behind other windows -- user JS_Window_FromPoint, using the coordinates of the button.

So, if you know the relative position of the button to the VST window, you can do the following:
(I didn't include any checks, such as checking that the VSTWindow is actually found.)
Code:
-- First, get VST position on screen
VSTWindow = reaper.JS_Window_Find("title of VST", true)
rOK, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(VSTWindow)

-- Calculate button screen coordinates
buttonX = leftX + somethingX
buttonY = leftY + somethingY

-- Get button window
buttonWindow = reaper.JS_Window_FromPoint(buttonX, buttonY)
rOK, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(buttonWindow)

-- Post click message
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONDOWN", 0x0001, 0, buttonX-leftX, buttonY-topY)
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONUP", 0x0000, 0, buttonX-leftX, buttonY-topY)
juliansader is online now   Reply With Quote
Old 10-15-2018, 11:03 PM   #46
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

cool!!! so we can use it to set focus back to script gui when using keyboard shortcuts (window find)?
Sexan is offline   Reply With Quote
Old 10-15-2018, 11:34 PM   #47
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

@juliansader,

Thank you so much!
The way I was doing this before was with AHK which was way easier to program.
I would then use lua to execute the AHK script via a midi command, however this is way better from an organizational standpoint., one less script to keep track of.

By the way is there any way to manipulate the transparency of non-script windows with your extension?
NextLevel is offline   Reply With Quote
Old 10-16-2018, 05:58 AM   #48
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: USA
Posts: 765
Default

@juliansader,
Awesome work!

Possible to add, GetClassName ?
Edgemeal is offline   Reply With Quote
Old 10-16-2018, 07:38 AM   #49
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by Edgemeal View Post
Possible to add, GetClassName ?
Will do. (GetClassName has just recently been added to REAPER's cross-platform functions.)


Quote:
Originally Posted by NextLevel View Post
By the way is there any way to manipulate the transparency of non-script windows with your extension?
Look what's coming in the next update!



For the time being, this function will only work on Windows. I submitted a FR for a cross-platform version.
juliansader is online now   Reply With Quote
Old 10-16-2018, 07:53 AM   #50
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,296
Default

YAY!!!
__________________
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 online now   Reply With Quote
Old 10-16-2018, 08:10 AM   #51
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,293
Default

Quote:
Originally Posted by juliansader View Post
For the time being, this function will only work on Windows. I submitted a FR for a cross-platform version.
Why not add that code directly into the extension in the meantime? (For non-mac it'd probably be best to use gdk_window_set_opacity instead of talking directly to Xorg though.)

Code:
// macOS (Objective-C!)
if ([(id)hwnd isKindOfClass:[NSWindow class]])
{
  NSWindow *window = (NSWindow *)hwnd;
}

// Others (swell-generic)
#include <swell/swell-internal.h> // to get the definition of HWND__
GdkWindow *window = hwnd->os_window;
(This will fail badly if the SWELL implementation provided by the application – REAPER – ever changes its inner workings in the future.)

Last edited by cfillion; 10-17-2018 at 12:01 AM.
cfillion is online now   Reply With Quote
Old 10-16-2018, 10:21 AM   #52
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 282
Default

Still doesn't open in linux:
Code:
swell: dlopen() failed: /home/Pc24/.config/REAPER/UserPlugins/reaper_js_ReaScriptAPI64.so: undefined symbol: GetWindowDC
Error loading /home/Pc24/.config/REAPER/UserPlugins/reaper_js_ReaScriptAPI64.so: (null)

Last edited by doppelganger; 11-03-2018 at 04:50 AM.
doppelganger is offline   Reply With Quote
Old 10-16-2018, 11:25 AM   #53
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by cfillion View Post
Why not add that code directly into the extension in the meantime?
Thanks! Your examples answered my biggest question: how to convert from HWND to NSWindow and GdkWindow. (I only had to change ->os_window to ->m_oswindow.)

I will therefore try include all OS versions in the next update. I can only test on Windows, but at least all different the OS versions seem to build OK.
juliansader is online now   Reply With Quote
Old 10-16-2018, 11:39 AM   #54
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by doppelganger View Post
Still doesn't open in linux:
swell: dlopen() failed: /home/Pc24/.config/REAPER/UserPlugins/reaper_js_ReaScriptAPI64.so: undefined symbol: GetWindowDC
I have no idea why GetWindowDC would give a problem...
juliansader is online now   Reply With Quote
Old 10-16-2018, 12:13 PM   #55
doppelganger
Human being with feelings
 
Join Date: Feb 2017
Posts: 282
Default

Quote:
Originally Posted by juliansader View Post
I have no idea why GetWindowDC would give a problem...
maybe it's a problem is on my side, maybe i need to install some dependencies, don't know,
instead of using your .so file, tried to build it right now, excluded all GDI functions, builds ok,
but on REAPER run get this:

Code:
swell: dlopen() failed: /home/Pc24/.config/REAPER/UserPlugins/reaper_js_ReaScriptAPI64.so: undefined symbol: _Z14SetDlgItemTextP6HWND__iPKc
Error loading /home/Pc24/.config/REAPER/UserPlugins/reaper_js_ReaScriptAPI64.so: (null)
Anyway, if it's a problem, then nevermind, i don't want to waste your time
doppelganger is offline   Reply With Quote
Old 10-16-2018, 12:48 PM   #56
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by doppelganger View Post
maybe it's a problem is on my side, maybe i need to install some dependencies, don't know,
Does SWS load correctly?
juliansader is online now   Reply With Quote
Old 10-16-2018, 01:52 PM   #57
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,342
Default

Woah.
IXix is offline   Reply With Quote
Old 10-17-2018, 03:59 AM   #58
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 584
Default

I'm not sure if this works, but I had an idea not letting me loose:

Can you somehow provide a function, that creates a new window? And can you do that to create a window that is Retina/HiDPI-compatible?
If drawing into such a window would work, we could have at least Retina/HiDPI-gfx-windows then...
__________________
Lua Coders of the world: UNITE!
This Saturday, 11am NewYorkCity time, head over to this thread:
https://forum.cockos.com/showthread....98#post2067798
mespotine is online now   Reply With Quote
Old 10-17-2018, 02:54 PM   #59
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

v0.95 uploaded:
* New function: JS_Window_SetOpacity.
* New function: JS_Window_GetClassName.
* Extension loads properly in Linux.

EDIT: Next update will include a safety check for JS_Window_SetOpacity in Linux, to prevent crashes when trying to change the opacity of child windows.

Last edited by juliansader; 10-19-2018 at 01:53 AM.
juliansader is online now   Reply With Quote
Old 10-17-2018, 04:08 PM   #60
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

Quote:
Originally Posted by juliansader View Post
v0.95 uploaded:
* New function: JS_Window_SetOpacity.
* New function: JS_Window_GetClassName.
* Extension loads properly in Linux.
YAY! Opacity, now my windows can actually be windows.
Thank you.
NextLevel is offline   Reply With Quote
Old 10-17-2018, 10:11 PM   #61
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 6,123
Default


Since which version does Windows have windows ???

-Michael
__________________
www.boa-sorte.de
mschnell is online now   Reply With Quote
Old 10-18-2018, 08:38 AM   #62
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: USA
Posts: 765
Default

Quote:
Originally Posted by juliansader View Post
v0.95 uploaded:
* New function: JS_Window_SetOpacity.
* New function: JS_Window_GetClassName.
* Extension loads properly in Linux.
Thanks for adding JS_Window_GetClassName, but I can't figure how to use it , everything I try says, 'attempt to call a nil value'


Code:
function print(str)
  reaper.ShowConsoleMsg(tostring(str) .. "\n")
end

-- get handles to windows with title "FX:" -- (e.g., FX: Track 1)
hWnd_array = reaper.new_array({}, 100)
reaper.JS_Window_ArrayFind("FX: ", false, hWnd_array) 
tHandles = hWnd_array.table()
-- display title and classname,
for i = 1, #tHandles do
  tHandles[i] = reaper.JS_Window_HandleFromAddress(tHandles[i])
  -- get window text - OK!
  t = reaper.JS_Window_GetTitle(tHandles[i], "")
  print(t)
   -- get classname text - ??
   classname = JS_Window_GetClassName(tHandles[i], "") -- < ERROR!
   print(classname)
end
Edgemeal is offline   Reply With Quote
Old 10-18-2018, 08:43 AM   #63
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

Quote:
Originally Posted by Edgemeal View Post
Thanks for adding JS_Window_GetClassName, but I can't figure how to use it , everything I try says, 'attempt to call a nil value'

classname = JS_Window_GetClassName(tHandles[i], "") -- < ERROR!
Remember the "reaper." in front.
juliansader is online now   Reply With Quote
Old 10-18-2018, 08:57 AM   #64
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: USA
Posts: 765
Default

Quote:
Originally Posted by juliansader View Post
Remember the "reaper." in front.
Geez, I feel like a fool!

THANKS!

Reset VU Meters
https://forum.cockos.com/showthread.php?p=2020008

Last edited by Edgemeal; 10-18-2018 at 10:44 AM.
Edgemeal is offline   Reply With Quote
Old 10-19-2018, 04:22 AM   #65
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

Lua example for using the WAV-writer functions in the plugin :

Code:
function test_wav_write(outfn)
local writebufsize = 512
local numoutchans = 4
local arr = reaper.new_array(writebufsize*numoutchans+numoutchans) -- need some extra space because of how the indexing works for the arrays
local b = arr
local writer = reaper.Xen_AudioWriter_Create(outfn,numoutchans,44100)
if writer~=nil then
  local phase = 0
  for i=0,999 do -- write 1000 buffers to disk
    -- fill interleaved buffer data, note that buffer data has to be written from index 1, not index 0
    for j=1,writebufsize do
      for k=0,numoutchans-1 do
        arr[j*numoutchans+k]=0.5*math.sin(2*3.141593/44100.0*phase*(100.0+k*10.0))
      end
      phase=phase+1
    end
    -- offset 1 here tells writer the data starts at array index 1
    local result = reaper.Xen_AudioWriter_Write(writer,writebufsize,arr,1)
    if result == 0 then reaper.ShowConsoleMsg("Fail during writing\n") break end
  end
  reaper.Xen_AudioWriter_Destroy(writer) -- file is only finalized when the writer is destroyed
else
  -- Can fail if file directory path does not exist, no write permissions, disk full...
  reaper.ShowConsoleMsg("Could not create writer\n")
end
end
I have not tested the functions with Python and Eel yet. It would also be useful to have a test the writer works with buffers that come from Reaper's AudioAccessors.
__________________
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-19-2018, 11:11 AM   #66
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 584
Default

Thnx for your hard work JS and Xen
__________________
Lua Coders of the world: UNITE!
This Saturday, 11am NewYorkCity time, head over to this thread:
https://forum.cockos.com/showthread....98#post2067798
mespotine is online now   Reply With Quote
Old 10-21-2018, 12:37 AM   #67
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

juliansader would you mind showing code example of "lasso select" drawing from the first page? (I want to draw rectangle)

Last edited by Sexan; 10-21-2018 at 02:21 AM.
Sexan is offline   Reply With Quote
Old 10-21-2018, 01:52 AM   #68
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 410
Default

@juliansader,

Do you happen to know if the api allows for any access to stylus and tablet.
I often use a drawing tablet and mouse at the same time.

I can't help but to think how cool it would be to have access to some of the pens functions, and possibly have independent control using win10 since it supports multiple input devices with multiple cursors.
How cool would it be to use a mouse on one monitor and pen on monitor 2?
NextLevel is offline   Reply With Quote
Old 10-21-2018, 04:09 AM   #69
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

I'm not sure if forum is ready for this

Last edited by Sexan; 10-21-2018 at 04:47 AM.
Sexan is offline   Reply With Quote
Old 10-21-2018, 05:00 AM   #70
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 1,296
Default

Area selection!!!!
__________________
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 online now   Reply With Quote
Old 10-21-2018, 06:47 AM   #71
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

Sexan!!! :O

Give it a bit of transparency and a way to know what is underneath and set it selected and there it is!

But first.. finish the Versions script!
amagalma is online now   Reply With Quote
Old 10-21-2018, 07:12 AM   #72
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

it already knows whats under it . few more days till release of PL,have some minor issues to fix
Sexan is offline   Reply With Quote
Old 10-22-2018, 12:32 AM   #73
InfiniteDimensionality
Human being with feelings
 
Join Date: Jun 2017
Posts: 122
Default

Quote:
Originally Posted by Sexan View Post
it already knows whats under it . few more days till release of PL,have some minor issues to fix
As much work as you guys put in to building up reaper you could have made an open source DAW that actually isn't build as if it were for windows 3.1.
InfiniteDimensionality is offline   Reply With Quote
Old 10-23-2018, 01:40 PM   #74
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,484
Default

Quote:
Originally Posted by Sexan View Post
I'm not sure if forum is ready for this
Why not using hackey patterns?
TonE is offline   Reply With Quote
Old 10-23-2018, 01:48 PM   #75
TonE
Human being with feelings
 
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 1,484
Default

Quote:
Originally Posted by juliansader View Post
I have uploaded a new extension that may be of interest to other scripters: "js_ReaScriptAPI".
Does this allow docking of trackey hackey and patterns in wine? Now lua scripts can not be docked in wine.
TonE is offline   Reply With Quote
Old 10-25-2018, 07:09 AM   #76
nappies
Human being with feelings
 
nappies's Avatar
 
Join Date: Dec 2017
Posts: 49
Default

Very useful and promising thing! Thank you for your hard work juliansader!
I didn’t really dive into the new API, but what I saw was very impressive!
Is it possible to intercept the left mouse click on TCP solo button and make an exclusive solo( by deafult while code running ) for example?
nappies is online now   Reply With Quote
Old 10-26-2018, 01:01 PM   #77
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,328
Default

Julian, I followed your example in post #46 trying to mimick mouseclicks but it works the first time and fails all the other times. Any idea why?
This is the test code:


Code:
reaper.ShowConsoleMsg("This message should always be cleared\n")
local RSwindow = reaper.JS_Window_Find("ReaScript console output", true)
local _, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(RSwindow)
-- "clear" button
local buttonX = rightX - 114
local buttonY = bottomY -27
-- Get button window
local buttonWindow = reaper.JS_Window_FromPoint(buttonX, buttonY)
_, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(buttonWindow)
-- Post click message
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONDOWN", 0x0001, 0, buttonX-leftX, buttonY-topY)
reaper.JS_WindowMessage_Post(buttonWindow, "WM_LBUTTONUP", 0x0000, 0, buttonX-leftX, buttonY-topY)
P.S. If I close the Console window and run the script again, it works. But if I keep running the script with the console window being open, then it fails.
P.S.2. Ok, I found it.. For it to work, I must first focus the button window using
Code:
reaper.ShowConsoleMsg("This message should always be cleared\n")
local RSwindow = reaper.JS_Window_Find("ReaScript console output", true)
local _, leftX, topY, rightX, bottomY = reaper.JS_Window_GetRect(RSwindow)
-- Get "clear" button window
local buttonWindow = reaper.JS_Window_FromPoint(rightX - 114, bottomY -27)
-- Post click message
reaper.JS_Window_SetFocus( buttonWindow )
reaper.JS_WindowMessage_Send(buttonWindow, "WM_LBUTTONDOWN", 0x0001, 0, 10, 10)
reaper.JS_WindowMessage_Send(buttonWindow, "WM_LBUTTONUP", 0x0000, 0, 10,10)
before the WindowMessage Posts

Last edited by amagalma; 10-26-2018 at 01:11 PM.
amagalma is online now   Reply With Quote
Old 10-27-2018, 03:19 PM   #78
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

Is this possible without flickering?


Code:
W,H = 5000,5000
local bmp = reaper.JS_LICE_CreateBitmap( true, W, H )
local bmpDC = reaper.JS_LICE_GetDC(bmp )
reaper.JS_LICE_FillRect( bmp, 0, 0, W, H, 0x99009999, 1, "ADD" )

local track_window = reaper.Window_Find("trackview", true) -- GET TRACK VIEW
local track_window_dc =  reaper.JS_GDI_GetWindowDC( track_window )

function main()
reaper.JS_GDI_Blit(track_window_dc, X_start, Y_start, bmpDC, 0, 0, W, H )
reaper.defer(main)
end
main()
This is the short versions of whats going on,but rectangle is constantly updated when window is moved,scrolled etc
Sexan is offline   Reply With Quote
Old 10-27-2018, 04:20 PM   #79
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,192
Default

I also posted about this some time ago:
SWELL/GDI and LICE: Is it possible to draw inside REAPER's window without flickering?, but I didn't get any answers, so I asked Justin on askjf.com:
Quote:
Question: Is it possible for a REAPER script or extension to use swell/GDI to draw basic shapes such as lines inside other REAPER/swell windows, without flickering? Flickering is not unexpected, since the script and window paint their stuff alternately and separately. I have tried blocking WM_PAINT messages, and then sending my own WM_PAINT once per defer cycle, but t
Asked by Julian (54.39.119.x) on September 20 2018, 9:41am
Reply on September 20 2018, 2:20pm:

It's probably possible via subclassing, but it would get messy/tricky.
juliansader is online now   Reply With Quote
Old 10-27-2018, 04:49 PM   #80
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 2,052
Default

ah,shame..... Just one more question, when drawing rectangle dynamically it does not refresh if you resize (to lower number) until the mouse is released.View is updated only if the rectangle has expanded,but not if its shrinked. Is this my error somewhere?


Thank you very much for this magical APIs
Sexan 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 11:24 AM.


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