Old 09-29-2019, 09:21 AM   #721
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,112
Default

You could compare against previous state and only execute if state has changed compared to previous state, something like this:

Code:
prevState = -1

function main()
  A=reaper.JS_Mouse_GetState(-1)
  reaper.defer(main)
  if prevState ~= A then
   if A == 5 then
      reaper.ShowConsoleMsg("CMD+Click")
    end
  end
  prevState = A
end

main()
Makes use of a global variable though, not sure if there'd be a way around it..
nofish is offline   Reply With Quote
Old 09-29-2019, 09:38 AM   #722
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
Default

Thanks nofish, I was thinking of something like that, but my brain is so much out of coding... Need to warm up again
__________________
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 09-30-2019, 03:25 PM   #723
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
Default

As explained by nofish, in previous versions of the extension, you could detect new key pressed by comparing the current state with the previous state. My own scripts also use such comparisons.

There were two complications that required careful coding:

* If the defer cycles are slow, a key can be pressed and released in-between your script's defer cycles, so VKeys_GetState may overlook some quick key presses.

* If a key is held down, multiple KEYDOWN messages will be sent, so to distinguish new key presses, a comparison of VKeys_GetDown states is required.

The new v0.993 of the extension handles auto-repeated KEYDOWN messages better: All auto-repeated messages are disregarded, and the two complications are therefore hopefully solved.

It is now possible to check for new key presses (since the previous defer cycle) with a single VKeys_GetDown, using cutoffTime = time_precise() of the previous cycle.
juliansader is online now   Reply With Quote
Old 10-01-2019, 01:32 PM   #724
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
Default

Thanks Julian, something to digest!


Thanks for all your help guys. My script comes along nicely.
I'm coding a "glue tool" script. I got the intercepting and mouse cursor loading
working fine.

But as you can see in my GIF, after terminating the script, a yellow arrow cursor appears, since I'm setting the default cursor. Only when moving the mouse, the correct pencil cursor appears.

Is there a way to set it to the cursor that was used BEFORE the script was executed?
Or will I need to make a 1 pixel movement back and forth to force update the cursor?



__________________
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-01-2019, 01:57 PM   #725
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
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 online now   Reply With Quote
Old 10-01-2019, 02:00 PM   #726
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
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 | 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-02-2019, 08:14 AM   #727
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 232
Default

This script looks awesome Stevie!
reapero is online now   Reply With Quote
Old 10-02-2019, 02:34 PM   #728
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
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 | 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-11-2019, 06:52 AM   #729
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,614
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.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is online now   Reply With Quote
Old 10-12-2019, 01:42 AM   #730
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 232
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 online now   Reply With Quote
Old 10-12-2019, 06:49 AM   #731
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,112
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   #732
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
Default

Good idea.

I created a new "js_ReaScriptAPI" folder in the ReaTeam repository that nofish linked to above.
juliansader is online now   Reply With Quote
Old 10-20-2019, 07:34 AM   #733
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,509
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 )

Last edited by amagalma; 10-20-2019 at 07:40 AM.
amagalma is offline   Reply With Quote
Old 10-20-2019, 01:54 PM   #734
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
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 online now   Reply With Quote
Old 10-22-2019, 02:21 PM   #735
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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).
Dafarkias is online now   Reply With Quote
Old 10-22-2019, 02:39 PM   #736
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,811
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 online now   Reply With Quote
Old 10-22-2019, 10:35 PM   #737
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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?
Dafarkias is online now   Reply With Quote
Old 10-23-2019, 07:51 AM   #738
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,614
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.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is online now   Reply With Quote
Old 10-23-2019, 09:16 AM   #739
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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.
Dafarkias is online now   Reply With Quote
Old 10-23-2019, 12:36 PM   #740
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
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 online now   Reply With Quote
Old 10-23-2019, 12:42 PM   #741
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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...
Dafarkias is online now   Reply With Quote
Old 10-23-2019, 01:09 PM   #742
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,801
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 online now   Reply With Quote
Old 10-23-2019, 10:02 PM   #743
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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
Dafarkias is online now   Reply With Quote
Old 10-24-2019, 02:26 AM   #744
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,509
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
amagalma is offline   Reply With Quote
Old 10-24-2019, 06:12 PM   #745
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 831
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   #746
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,112
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   #747
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 831
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   #748
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 9,112
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   #749
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,178
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:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 10-25-2019, 02:40 PM   #750
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 831
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   #751
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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
Dafarkias is online now   Reply With Quote
Old 10-26-2019, 05:53 AM   #752
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,178
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:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 10-26-2019, 12:37 PM   #753
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
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 | 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-26-2019, 12:51 PM   #754
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 831
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   #755
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,938
Default

Woah, awesome, thank you tack!!!
__________________
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-26-2019, 01:43 PM   #756
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,433
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   #757
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
Default

@lb0

One for the books! Thank you!
Dafarkias is online now   Reply With Quote
Old 10-26-2019, 06:05 PM   #758
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 3,178
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:
LBX Stripper | LBX Chaos Engine | LBX Floating FX Positioner | LBX SRD Smart Knobs
Donate via Paypal
lb0 is offline   Reply With Quote
Old 10-26-2019, 06:20 PM   #759
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,433
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   #760
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 270
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)
Dafarkias is online now   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 09:42 AM.


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