Old 10-01-2019, 01:57 PM   #721
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

You can try using JS_Mouse_GetCursur to get the current cursor when your script starts, and then restore that cursor with JS_Mouse_SetCursor when the script exits.
juliansader is offline   Reply With Quote
Old 10-01-2019, 02:00 PM   #722
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

How cool! JS_Mouse_GetCursor exists! Didn't know! As usual I scanned Xraym's API website, but couldn't find it there. Checking if that works...

EDIT: Woooop, it worked!!!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-02-2019, 08:14 AM   #723
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

This script looks awesome Stevie!
reapero is offline   Reply With Quote
Old 10-02-2019, 02:34 PM   #724
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Hah thanks man! Still need to take care of a few corner cases, but otherwise it comes along nicely.
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-11-2019, 06:52 AM   #725
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

An idea I had for some days now, as I see so many useful examples and snippets, what about adding an example-folder to the repository, so the examples don't get lost in this thread?
That can be filled by all of us, who have examples posted in here.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-12-2019, 01:42 AM   #726
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 517
Default

Mespotine yes!! That would surely encourage most of us noob coders to try things out and learn from you guys. At the same time, i guess this would make this thread more relevant (deeper sort of posts so to speak), since a lot of the simpler questions could be answered just by digging in the examples.

+1000! Great idea!
reapero is offline   Reply With Quote
Old 10-12-2019, 06:49 AM   #727
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

I also like this suggestion.
'ReaTeam' has something similar I find helpful too:
https://github.com/ReaTeam/ReaScripts-Templates
nofish is offline   Reply With Quote
Old 10-12-2019, 02:42 PM   #728
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Good idea.

I created a new "js_ReaScriptAPI" folder in the ReaTeam repository that nofish linked to above.
juliansader is offline   Reply With Quote
Old 10-20-2019, 07:34 AM   #729
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Code:
retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( windowHWND )


* On macOS, screen coordinates are relative to the *bottom* left corner  of the primary display, and the positive Y-axis points upward.

Does that mean that on MacOs we get actually this order of output? :
Code:
retval, left, bottom, right, top = reaper.JS_Window_GetClientRect( windowHWND )
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 10-20-2019 at 07:40 AM.
amagalma is offline   Reply With Quote
Old 10-20-2019, 01:54 PM   #730
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

No. You get the same order of output, but on Mac "top" will be a larger number than "bottom", whereas on PC and Linux, "top" will be a smaller number.
juliansader is offline   Reply With Quote
Old 10-22-2019, 02:21 PM   #731
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Me again!

I don't mean to pester, but I'm having an issue with my current WIP script.

https://forum.cockos.com/showthread.php?t=226217

Do you think it's possible that you may ever add vertical zoom control to your API extension? On a related note, I know the guys from SWS managed to code several actions that can accurately control REAPER's vertical arrange zoom, but I haven't managed to get in contact with them regarding whether or not they could assist with this issue I'm having (I'm sure they could).
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-22-2019, 02:39 PM   #732
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by Dafarkias View Post
I haven't managed to get in contact with them
16 hours is not a lot of time...
cfillion is offline   Reply With Quote
Old 10-22-2019, 10:35 PM   #733
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

cfillion

It's not. But I didn't mean to offend you by making that statement. I'm simply trying to get results quickly while attempting not to pester any one source entirely too much.

Obviously, I read the forums enough to know that you are a crucial member of the SWS crew. Can I PM you with more questions regarding my predicament?
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-23-2019, 07:51 AM   #734
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

@Dafarkias
The zoom-problem, at lest the zoom-factor, is one I also have trouble with. I tried to make this happen in my Ultraschall-API but there's some tricky conversion needed, that I couldn't figure out yet.
So the only way to make it is currently using BR_GetArrangeView and BR_SetArrangeView for horizontal zoom.

You can, however, check my Ultraschall-API and the functions:
https://mespotin.uber.space/Ultrasch...etVerticalZoom
https://mespotin.uber.space/Ultrasch...etVerticalZoom

for the vertical zoom. Maybe that helps you.
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-23-2019, 09:16 AM   #735
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Fudge.

After a little more investigation, it even seems that there is a little bit of undesirable behavior from the SWS action, SWS: Vertical zoom to selected tracks.

It seems that REAPER uses some sort of algorithm that determines a non-linear 'track-gap' at the far-north of the arrange view, which makes things all the more difficult to codify.

This is very frustrating to me, because I really like the concept of the 'project map' script I'm working on, but these limitations regarding the vertical zoom/dependable positioning are somewhat crippling.
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-23-2019, 12:36 PM   #736
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Dafarkias View Post
Do you think it's possible that you may ever add vertical zoom control to your API extension? On a related note, I know the guys from SWS managed to code several actions that can accurately control REAPER's vertical arrange zoom, but I haven't managed to get in contact with them regarding whether or not they could assist with this issue I'm having (I'm sure they could).
I have asked Justin himself about this, long ago, since I too wanted to add zoom functions to the extension. Unfortunately, REAPER's windows do not respond reliably to zoom messages, and Justin recommended using native actions such as "Toggle zoom to selected items".


Quote:
Originally Posted by mespotine View Post
So the only way to make it is currently using BR_GetArrangeView and BR_SetArrangeView for horizontal zoom.
These functions have been deprecated since REAPER got the native GetSet_ArrangeView2 function.
juliansader is offline   Reply With Quote
Old 10-23-2019, 12:42 PM   #737
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

He (Justin) didn't happen to mention whether or not he would every consider incorporating such a function into the API, did he?

Obviously I know they are insanely busy and whatnot, so I'm sure it's not even a passing thought.


Bummer...
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-23-2019, 01:09 PM   #738
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I didn't ask, but it would be a very useful Feature Request.

(My original attempts at zooming are in WDL/SWELL/CoolScrollBar: How to zoom windows?.)
juliansader is offline   Reply With Quote
Old 10-23-2019, 10:02 PM   #739
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Thanks for sharing that.

I actually did create a feature request, it's just not very dynamic (https://forum.cockos.com/showthread.php?t=226217).

I'll stop pestering you now about this
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-24-2019, 02:26 AM   #740
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by amagalma View Post
Code:
 retval, left, top, right, bottom = reaper.JS_Window_GetClientRect( windowHWND )


* On macOS, screen coordinates are relative to the *bottom* left corner   of the primary display, and the positive Y-axis points upward.
Does that mean that on MacOs we get actually this order of output? :
Code:
retval, left, bottom, right, top = reaper.JS_Window_GetClientRect( windowHWND )

Quote:
Originally Posted by juliansader View Post
No. You get the same order of output, but on Mac "top" will be a larger number than "bottom", whereas on PC and Linux, "top" will be a smaller number.

Thanks but I tried it and I think, for the sake of simplicity, it is easier to say that they are just returned in a different order.


Code:
local OSX = string.match(reaper.GetOS(), "OSX") and true or false
if OSX then
    _, left, bottom, right, top = reaper.JS_Window_GetClientRect( hwnd )
else
    _, left, top, right, bottom = reaper.JS_Window_GetClientRect( hwnd )
end

Worked for me
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 10-24-2019, 06:12 PM   #741
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

I've been playing with the new JS_Window_SetStyle() function and I'm running into an issue where when I specify the default style of CAPTION,SIZEBOX,SYSMENU, JS_Window_AttachTopmostPin() fails to work.

By itself, this works:

Code:
reaper.JS_Window_AttachTopmostPin(hwnd)
However this doesn't work inasmuch as the pin is not attached:

Code:
reaper.JS_Window_SetStyle(hwnd, 'CAPTION,SIZEBOX,SYSMENU')
reaper.JS_Window_AttachTopmostPin(hwnd)
Any thoughts?

On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?

Thanks!
tack is offline   Reply With Quote
Old 10-25-2019, 05:46 AM   #742
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by tack View Post
On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?
JS_Window_SetZOrder() I'd assume (didn't use myself yet though).
nofish is offline   Reply With Quote
Old 10-25-2019, 05:57 AM   #743
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by nofish View Post
JS_Window_SetZOrder() I'd assume (didn't use myself yet though).
That's just a one time action though, isn't it? It can move the window to top but doesn't make it sticky such that it's always on top, I thought.
tack is offline   Reply With Quote
Old 10-25-2019, 06:00 AM   #744
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Ah yes, I think you're right. I somehow missed that you want to make it sticky, sorry.
nofish is offline   Reply With Quote
Old 10-25-2019, 02:29 PM   #745
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by tack View Post
On a related note, is there an API to directly control the always-on-top window behavior that is managed via the pin button?

Thanks!
If my memory serves me correct:

In JS_Window_SetPosition API

Add "TOPMOST" or "NOTOPMOST" for zOrder parameter.

I've only tried this on Windows - no idea if it works for a different OS.
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 10-25-2019, 02:40 PM   #746
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by lb0 View Post
If my memory serves me correct:

In JS_Window_SetPosition API

Add "TOPMOST" or "NOTOPMOST" for zOrder parameter.

I've only tried this on Windows - no idea if it works for a different OS.
Much obliged! Works on both Mac and Windows. Thanks lb0.

Edit: Looks like JS_Window_SetZOrder() is even more convenient if all you want to do is toggle that behaviour.
tack is offline   Reply With Quote
Old 10-26-2019, 01:38 AM   #747
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Dafarky again. Different topic.

Is there currently a way to remove a window titlebar from a preexisting Reascript gfx window? Specifically:

https://forum.cockos.com/showthread.php?t=226263
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-26-2019, 05:53 AM   #748
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by Dafarkias View Post
Dafarky again. Different topic.

Is there currently a way to remove a window titlebar from a preexisting Reascript gfx window? Specifically:

https://forum.cockos.com/showthread.php?t=226263
yep:

From my Stripper script I use (along these lines):

Code:
local win = reaper.JS_Window_Find('- LBX Stripper -', true)
if win then
  local style = reaper.JS_Window_GetLong(win, 'STYLE')
  if style then
    style = style & (0xFFFFFFFF - 0x00C40000)
    reaper.JS_Window_SetLong(win, "STYLE", style)
  end
end
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 10-26-2019, 12:37 PM   #749
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-26-2019, 12:51 PM   #750
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,618
Default

Quote:
Originally Posted by _Stevie_ View Post
Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
There will be a proper implementation in the next pre-release (RSN).
tack is offline   Reply With Quote
Old 10-26-2019, 12:52 PM   #751
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Woah, awesome, thank you tack!!!
__________________
My Reascripts forum thread | My Reascripts on GitHub
If you like or use my scripts, please support the Ukraine: Ukraine Crisis Relief Fund | DirectRelief | Save The Children | Razom
_Stevie_ is offline   Reply With Quote
Old 10-26-2019, 01:43 PM   #752
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by _Stevie_ View Post
Thanks lb0! Used the code to make Reaticulate borderless, now I have everything nicely fitting on the screen
Doesn't this do the same thing? (haven't tested yet)
Code:
reaper.JS_Window_SetStyle(hwnd, "POPUP")
Edgemeal is offline   Reply With Quote
Old 10-26-2019, 03:52 PM   #753
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

@lb0

One for the books! Thank you!
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-26-2019, 06:05 PM   #754
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by Edgemeal View Post
Doesn't this do the same thing? (haven't tested yet)
Code:
reaper.JS_Window_SetStyle(hwnd, "POPUP")
Looks like it does - - If there's a long winded approach available - I'm sure to use it

...don't think JS_SetStyle was available when I coded this (could be wrong though).
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website
lb0 is offline   Reply With Quote
Old 10-26-2019, 06:20 PM   #755
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by lb0 View Post
Looks like it does - - If there's a long winded approach available - I'm sure to use it

...don't think JS_SetStyle was available when I coded this (could be wrong though).
Julian added soon after that.
Edgemeal is offline   Reply With Quote
Old 10-30-2019, 11:10 AM   #756
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Please let me preemptively apologize for my ignorance:

When setting a borderless window on an an existing window via reaper.JS_Window_SetStyle(hwnd, "POPUP"), this is only Windows compatible, no? (I.e., does not work with OSX)
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 10-30-2019, 11:24 AM   #757
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

With JS_Window_Create, what is the purpose of parameter classname? Does this mean, I can create a hwnd with a certain, already existing class or does this create a new class of the name "className"?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 10-30-2019, 12:32 PM   #758
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Any clue why this code runs OK on v0.990 and 991 but instantly crashes REAPER using v0.992 or 993? (on Windows 10).

Code:
-- Runs OK on v0.990 and 991 but instantly crashes REAPER using v0.992 or 993!
--

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

btnX=30 btnY=30 btnW=120 btnH=33 txt = "Hello World!"
winW=300 winH=200

window = reaper.JS_Window_Create("Test", "myClass", 120, 120, winW, winH,"POPUP")
bm = reaper.JS_LICE_CreateBitmap(true, winW, winH)
reaper.JS_Composite(window, 0, 0, winW, winH, bm, 0, 0, winW, winH)
reaper.JS_LICE_Clear(bm, 0xFFFFFF00)
reaper.JS_LICE_FillRect(bm, btnX, btnY, btnW, btnH, 0xFABB00FF, 1, "COPY")
reaper.JS_Window_InvalidateRect(window, 0, 0, winW, winH, true)
    
function loop()
  if reaper.ValidatePtr(window, "HWND") then
    hDC = reaper.JS_GDI_GetWindowDC(window)
    reaper.JS_GDI_SetTextBkColor(hDC, 0xFABB00FF) -- set text back color same as btn rect area.
    reaper.JS_GDI_DrawText(hDC, txt, string.len(txt), btnX, btnY, btnX+btnW, btnY+btnH, 'VCENTER HCENTER SINGLELINE') -- center text
    reaper.JS_GDI_ReleaseDC(window, hDC)
    -------------------------------------------------------
    
    if reaper.JS_Mouse_GetState(1) == 1 then -- Left mouse button down
      -- Is mouse over area, like a button?
      if ContainsMouse(window, btnX,btnY,btnW,btnH) then
        msg('Mouse down over fake button') 
      end
    end
    --------------------------------------------------------

    reaper.defer(loop)
  end
end

function ContainsMouse(hwnd,x,y,w,h)
  local mX, mY = reaper.GetMousePosition() 
  local cx, cy = reaper.JS_Window_ScreenToClient(hwnd, mX, mY)
  if (cx >= x) and (cx <= x+w) and (cy <= y+h) and (cy >= y) then
    return true
  end
end

function exit()
  reaper.JS_Window_Destroy(window) 
  reaper.JS_LICE_DestroyBitmap(bm)
end

reaper.atexit(exit)
reaper.defer(loop)
Edgemeal is offline   Reply With Quote
Old 10-30-2019, 01:03 PM   #759
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Dafarkias View Post
When setting a borderless window on an an existing window via reaper.JS_Window_SetStyle(hwnd, "POPUP"), this is only Windows compatible, no? (I.e., does not work with OSX)
It is *supposed* to work on OSX and Linux, but if anything doesn't, please let me know!
juliansader is offline   Reply With Quote
Old 10-30-2019, 01:03 PM   #760
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by mespotine View Post
With JS_Window_Create, what is the purpose of parameter classname? Does this mean, I can create a hwnd with a certain, already existing class or does this create a new class of the name "className"?
It does both. If you give it a class name that doesn't exist, it internally creates a new window class and then creates a window instance out of it. I don't know what purpose that would serve within the context of ReaScript, I am just looking at the extension's code. Maybe it's required for creating new top level windows? (My win32 is getting quite rusty at this point...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios 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:42 AM.


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