Old 09-03-2019, 10:51 AM   #681
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I'm using the compress & stretch script on my Mac. Not sure if this has been a known bug, but have a look what's happening:

__________________
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 09-03-2019, 10:55 AM   #682
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Similar to Stephan above, I'm on a Mac also but in my case I have no custom mouse icons showing up.

Any ideas?

__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 09-03-2019, 12:10 PM   #683
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

These are not problems that I have ever noticed before. I quickly tested the scripts on macOS Mojave with REAPER v5.983 and the most recent dev version, and everything seems fine on my setup.

When did this start happening, and which versions of REAPER, scripts and the extension are you using? Does it happen to all CC lanes, and to docked as well as undocked MIDI editors?

In Andrew's case, it also seems that the guidelines are flickering, which they are not supposed to. I wonder if the script is perhaps stopping and restarting with each flicker. How are you running the script?
juliansader is offline   Reply With Quote
Old 09-03-2019, 02:06 PM   #684
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,719
Default

Quote:
Originally Posted by juliansader View Post
These are not problems that I have ever noticed before. I quickly tested the scripts on macOS Mojave with REAPER v5.983 and the most recent dev version, and everything seems fine on my setup.

When did this start happening, and which versions of REAPER, scripts and the extension are you using? Does it happen to all CC lanes, and to docked as well as undocked MIDI editors?

In Andrew's case, it also seems that the guidelines are flickering, which they are not supposed to. I wonder if the script is perhaps stopping and restarting with each flicker. How are you running the script?
Thanks Julian,

Since this is my firs time speaking with you (tat I recall), let me start by saying just how amazing your scripts are. Really…Next level.

I think the flickering is not really that bad… I think that may be how the screen capture program made it look.My main concern is why I am not seeing any of the mouse icons. The flickering does not seem any more pronounced on your scripts than any other deep scripts.

I am simply invoking your script with a key command. That's it. Nothing special.

v4.20 by juliansader – May 08 2019

I will see if I can replicate this on my MacBook Pro.

Thanks for all your help.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 09-03-2019 at 02:28 PM.
Thonex is offline   Reply With Quote
Old 09-04-2019, 02:44 PM   #685
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by _Stevie_ View Post
Btw, this can't be used to remove the frame/borders from an existing window, right?:
Quote:
Originally Posted by deeb View Post
excuse me guys! is there any way to remove this from a window GUI?

I haven't had any success doing this on Windows (with Aero theme) or on Linux -- which is why I haven't yet added a JS_Window_SetStyle function.

AFAIK, the usual steps are to set the style using the C++ function SetWindowLongPtr and then update the window using SetWindowPos with FRAMECHANGED flag. But as soon as I try to remove the frame of a window that expects a frame, I see all kinds of artefacts, such as white borders, blank windows, mouse events that pass through to lower windows, etc. Perhaps one of the C++ experts here knows of a better way?

But deeb is in luck!

To my surprise, when I tried to do this on macOS, everything seems to work fine (though I haven't tested it extensively). Simply do this:
Code:
reaper.JS_Window_SetLong(w, "STYLE", 0x80000000) -- Sets "POPUP" style. 0xC40000 to return the title bar and border.
reaper.JS_WindowMessage_Send(w, "WM_NCCALCSIZE", 0, 0, 0, 0) -- Recalculates border size
juliansader is offline   Reply With Quote
Old 09-04-2019, 02:56 PM   #686
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Thonex View Post
Similar to Stephan above, I'm on a Mac also but in my case I have no custom mouse icons showing up.

Any ideas?

This Arch and Tilt function uses a custom cursor that should be downloaded automatically when you install the script via ReaPack. If you are using ReaPack, please try reinstalling the script and check if the file "js_Mouse editing - Arch and Tilt.cur" was downloaded. If not, you can download it manually from the GitHub repository.
juliansader is offline   Reply With Quote
Old 09-04-2019, 04:29 PM   #687
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by juliansader View Post
AFAIK, the usual steps are to set the style using the C++ function SetWindowLongPtr and then update the window using SetWindowPos with FRAMECHANGED flag.
Back in the WinXP days I think that worked just fine, but last time I tried changing style (Win7?) I had to hide window, change style, show window for it to work.

I don't understand how your api works but this removes the maximize/restore/close/context menu on the window in Win10,..

Code:
window = reaper.JS_Window_Create("Ed's WINDOW Test", "myClass", 120, 120, 300, 300)
reaper.JS_Window_Show(window, "HIDE")
reaper.JS_Window_SetLong(window, "STYLE", 0x00C00000) -- WS_CAPTION = 0x00C00000
reaper.JS_Window_Show(window, "SHOW")
Edgemeal is offline   Reply With Quote
Old 09-05-2019, 01:05 AM   #688
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Quote:
Originally Posted by juliansader View Post
When did this start happening, and which versions of REAPER, scripts and the extension are you using? Does it happen to all CC lanes, and to docked as well as undocked MIDI editors?
It's hard to say, when it started. On this machine, I only recently installed your scripts, because this is not my main rig (using a PC as DAW).

Reaper 5.983 dev0903, the latest SWS from landoleet, happens with docked and undocked ME. iMac 2011 + Mojave. It only seems to be happen, when the guides are visible.
__________________
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 09-05-2019, 01:18 AM   #689
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by _Stevie_ View Post
It's hard to say, when it started. On this machine, I only recently installed your scripts, because this is not my main rig (using a PC as DAW).

Reaper 5.983 dev0903, the latest SWS from landoleet, happens with docked and undocked ME. iMac 2011 + Mojave. It only seems to be happen, when the guides are visible.
It seems that the script's bitmap overwrites the window contents, and per-pixel alpha values are ignored. I wonder if there is a bug in the macOS version of the WDL/swell blitting function? A similar bug in the Linux version was fixed a while ago, before I implemented the Compositing functions.

What happens when you run the MIDI Inspector script?
juliansader is offline   Reply With Quote
Old 09-05-2019, 03:56 AM   #690
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I get this:

__________________
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 09-05-2019, 05:53 AM   #691
Arthur McArthur
Human being with feelings
 
Arthur McArthur's Avatar
 
Join Date: Sep 2016
Location: Toronto
Posts: 744
Default

What code would one need to add to a simple Lokasenna GUI script to use VKEYS to intercept all keyboard input and pass it through to the main REAPER window?
Arthur McArthur is offline   Reply With Quote
Old 09-05-2019, 06:35 AM   #692
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by Edgemeal View Post
Back in the WinXP days I think that worked just fine, but last time I tried changing style (Win7?) I had to hide window, change style, show window for it to work.

I don't understand how your api works but this removes the maximize/restore/close/context menu on the window in Win10,..

Code:
window = reaper.JS_Window_Create("Ed's WINDOW Test", "myClass", 120, 120, 300, 300)
reaper.JS_Window_Show(window, "HIDE")
reaper.JS_Window_SetLong(window, "STYLE", 0x00C00000) -- WS_CAPTION = 0x00C00000
reaper.JS_Window_Show(window, "SHOW")
Hi, I had very limited success using the SetLong API - until I realised it doesn't work like AutoHotKey (which I am used to) - which simply allows you to add/remove bits from the current style setting.

So to remove say the entire window border and title - I found this code works:

Code:
  local style = reaper.JS_Window_GetLong(window, "STYLE")
  style = style & (0xFFFFFFFF - 0x00C40000) --0x00C40000 remove title and border bits
  reaper.JS_Window_SetLong(window, "STYLE", style)
ie. The style value you set with SetLong must be the complete style value and not just the bits you want to set or unset (which is how AHK works).

EDIT: AHK sort of works like how I suggested - but you do actually still provide the complete style value and the adjustment as a separate value.
__________________
Projects - Reascripts - Lua:
Smart Knobs 2 | LBX Stripper | LBX Floating FX Positioner
Donate via Paypal | LBX Tools Website

Last edited by lb0; 09-05-2019 at 09:05 AM.
lb0 is offline   Reply With Quote
Old 09-05-2019, 06:40 AM   #693
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by _Stevie_ View Post
I get this:
I was actually wondering how the Inspector looks when docked inside the piano roll, since it uses LICE/Compositing when docked, but this screenshot is even more interesting: Why is the GUI blank? The GUI uses plain native gfx graphics.

Could you perhaps check other script GUIs, such as my LFO Tool or Lokasenna's Radial Menu?

Is your iMac 64 or 32 bit?
juliansader is offline   Reply With Quote
Old 09-05-2019, 06:43 AM   #694
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by juliansader View Post
I haven't had any success doing this on Windows (with Aero theme) or on Linux -- which is why I haven't yet added a JS_Window_SetStyle function.

AFAIK, the usual steps are to set the style using the C++ function SetWindowLongPtr and then update the window using SetWindowPos with FRAMECHANGED flag. But as soon as I try to remove the frame of a window that expects a frame, I see all kinds of artefacts, such as white borders, blank windows, mouse events that pass through to lower windows, etc. Perhaps one of the C++ experts here knows of a better way?

But deeb is in luck!

To my surprise, when I tried to do this on macOS, everything seems to work fine (though I haven't tested it extensively). Simply do this:
Code:
reaper.JS_Window_SetLong(w, "STYLE", 0x80000000) -- Sets "POPUP" style. 0xC40000 to return the title bar and border.
reaper.JS_WindowMessage_Send(w, "WM_NCCALCSIZE", 0, 0, 0, 0) -- Recalculates border size
See my previous message - I think you must pass the complete style value - not just the bits you want to set/unset to the SetLong function.

This avoids those unwanted artifacts - at least for me on Win10. I was also having trouble with mouse events being passed through to lower windows etc until I changed the way I used the function.
__________________
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 09-05-2019, 09:19 AM   #695
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
So to remove say the entire window border and title - I found this code works:
Thanks, Been a long time (that hide/show hack was for something else ), but ya thats basically how I did it in VB6/WinXP_x86 days, went something like, style = style And Not (WS_CAPTION OR WS_THICKFRAME). Never even tried AHK.
So how would you add a style back that you removed?


@Julian, What about Extended Styles, is that possible also? I may never use any of this but always good to know.
Edgemeal is offline   Reply With Quote
Old 09-05-2019, 11:32 AM   #696
lb0
Human being with feelings
 
Join Date: Apr 2014
Posts: 4,171
Default

Quote:
Originally Posted by Edgemeal View Post
Thanks, Been a long time (that hide/show hack was for something else ), but ya thats basically how I did it in VB6/WinXP_x86 days, went something like, style = style And Not (WS_CAPTION OR WS_THICKFRAME). Never even tried AHK.
So how would you add a style back that you removed?


@Julian, What about Extended Styles, is that possible also? I may never use any of this but always good to know.
Yeah - I've never really messed around with windows styles beyond copying and adapting other peoples AHK scripts

I guess to add the flags back you could check if the flags are not already set - something like:

Code:
if not style & 0xc40000 == 0xc40000 then
  style = style + 0xc40000
end
but there may be a neater way of doing this?

In fact you could check whether the flag value is set whether you want to add them or remove them - and then adjust accordingly - subtracting the flag value to remove them.

With AHK - you simply set the new flag settings to positive if you want to add them - and negative if you want to remove them - I guess it does the rest under the hood.
__________________
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 09-06-2019, 07:06 PM   #697
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Thanks for the advice!

I have uploaded v0.991 with JS_Window_SetStyle that seems to work well on Windows 7, Linux Xfce and macOS Mojave. Please let me know if there are any problems on other OS's.

Also in v0.991:
* Improved: JS_Window_SetPosition: Full functionality of SetWindowPos.
* Improved: Xen_StartSourcePreview: Add support for setting hardware output channels for PCM_source previews.


(Full Unicode support is still a work in progress.)
juliansader is offline   Reply With Quote
Old 09-07-2019, 11:46 AM   #698
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Another Linux bug report for you - JS_Dialog_BrowseForFolder won't let me actually pick the folder. Clicking the button just navigates into the folder instead, as with Reaper's native file dialog.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 09-07-2019, 11:52 AM   #699
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Lokasenna View Post
Another Linux bug report for you - JS_Dialog_BrowseForFolder won't let me actually pick the folder. Clicking the button just navigates into the folder instead, as with Reaper's native file dialog.
Unlike the file browser dialogs, which return the files that are selected, the folder dialog returns the folder that you are *in* at that moment, not the one that is selected. So to return a folder, first open it, make sure that you *don't* have any subfolder selected, and then click Choose.
juliansader is offline   Reply With Quote
Old 09-07-2019, 11:57 AM   #700
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by juliansader View Post
Unlike the file browser dialogs, which return the files that are selected, the folder dialog returns the folder that you are *in* at that moment, not the one that is selected. So to return a folder, first open it, make sure that you *don't* have any subfolder selected, and then click Choose.
Ah, fair enough.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 09-10-2019, 10:56 AM   #701
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Quote:
Originally Posted by juliansader View Post
I was actually wondering how the Inspector looks when docked inside the piano roll, since it uses LICE/Compositing when docked, but this screenshot is even more interesting: Why is the GUI blank? The GUI uses plain native gfx graphics.

Could you perhaps check other script GUIs, such as my LFO Tool or Lokasenna's Radial Menu?

Is your iMac 64 or 32 bit?
Even more strange is, that sometimes, the GUI is visible and sometimes it isn't. I can't make any sense out of it...

The LFO tool has the same behavior. But not Radial Menu. I somehow have the feeling it has to do with the detection of the MIDI Editor.

I'm running Reaper 64bit.
__________________
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 09-13-2019, 11:07 AM   #702
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Do you think we can change YES / NO label button of ShowMessageBox window with js_extension ?



Quote:
reaper.ShowMessageBox( msg, title, type )

I would like a user popup with two button but the "yes" "no" label lacks customization.


Thanks !
X-Raym is offline   Reply With Quote
Old 09-13-2019, 12:45 PM   #703
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by X-Raym View Post
Do you think we can change YES / NO label button of ShowMessageBox window with js_extension ?
Only way I know is to use two scripts, main one saves text to temp extstate, then launch a watcher script that reads the extstate info, does something with it..., here I change the Yes No buttons to something else,...

Code:
function Main()
  -- save title and button texts to extstate
  local params = msgbox_title .. ',Ya Man!' .. ',No Way!' 
  reaper.SetExtState("Edgemeal", "MessageBox", params, false)
  -- start watcher script,
  reaper.Main_OnCommand(reaper.NamedCommandLookup('_R****'), 0) -- Script: Watcher.lua
  -- show yes-no msgbox
  local result = reaper.MB("OK to overwrite file?", msgbox_title, 4)
  -- if result == bla bla bla
end

msgbox_title = "OK or No Way" -- No commas!
Main()
Code:
-- change button text on yes no msgbox
function watcher()
  local hwnd = reaper.JS_Window_FindTop(params[1], true)
  if hwnd then -- change Yes - No button texts
    yes = reaper.JS_Window_FindChildByID(hwnd, 6) -- yes button
    if yes then reaper.JS_Window_SetTitle(yes, params[2]) end
    no = reaper.JS_Window_FindChildByID(hwnd, 7) --  no button
    if no then reaper.JS_Window_SetTitle(no, params[3]) end 
    reaper.DeleteExtState("Edgemeal", "MessageBox", false)
  else
    reaper.defer(watcher)
  end
end

param = reaper.GetExtState("Edgemeal", "MessageBox")
params = {} 
for item in param:gmatch("[^,]+") do
  params[#params+1] = item
end

watcher()

Last edited by Edgemeal; 09-13-2019 at 01:13 PM. Reason: fix typo in code
Edgemeal is offline   Reply With Quote
Old 09-13-2019, 04:35 PM   #704
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

@edgemeal
Interesting wolrkarround ! Hmmm so it need two scripts.

A bit overkill in my case but I keep that in mind. Many thx for your support.!!
X-Raym is offline   Reply With Quote
Old 09-14-2019, 07:24 AM   #705
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

If anyone knows how to manipulate REAPER's dialog window templates using C++, I can try to add it to the extension.
juliansader is offline   Reply With Quote
Old 09-14-2019, 12:59 PM   #706
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Quote:
Originally Posted by X-Raym View Post
Do you think we can change YES / NO label button of ShowMessageBox window with js_extension ?






I would like a user popup with two button but the "yes" "no" label lacks customization.


Thanks !
Yes, using Ultraschall-API
https://mespotin.uber.space/Ultrasch...ctions.html#MB

However, it has a known bug on Mac, which I'm on with solving.

But I would prefer having something properly done native or as proper C++-function.

@Julian
I would like to attempt it using the new WindowCreate-functions. Do you have an example, which I can take as basis for doing new dialogs?
__________________
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 09-20-2019, 07:02 AM   #707
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by mespotine View Post
@Julian
I would like to attempt it using the new WindowCreate-functions. Do you have an example, which I can take as basis for doing new dialogs?
Unfortunately, I don't have any helpful examples.
juliansader is offline   Reply With Quote
Old 09-27-2019, 11:36 AM   #708
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by X-Raym View Post
is reaper.JS_Window_SetTitle supposed to support UTF-8 characters ?
I have uploaded v0.992 with better support for Unicode characters. The file dialogs, Window_SetTitle, GetClassName and GDI_DrawText seem to work well. Window_GetTitle does not yet work with the entire Unicode set.

The VKeys functions have also be updated to ignore auto-repeated keys, so that it is easier for scripts to detect new key presses.
juliansader is offline   Reply With Quote
Old 09-29-2019, 05:01 AM   #709
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

Nice!
__________________
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 09-29-2019, 05:53 AM   #710
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Thx !
X-Raym is offline   Reply With Quote
Old 09-29-2019, 06:47 AM   #711
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

@Julian, I’m not sure what the current state is but when creating a defer script, is it possible to intercept the ALT, CTRL and SHIFT keys and assign new functions, while the defer script is running?

Like: if ALT is pressed, execute GlueNotes()
__________________
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 09-29-2019, 06:57 AM   #712
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

This should be possible. I once made something like that working for a prototype-script some time ago, but don't know, if I still have that script.

Edit:

This returns the mouse-modifiers, like gfx.mouse_cap does.

Code:
function main()
  A=reaper.JS_Mouse_GetState(-1)
  reaper.defer(main)
end

main()
Try this and watch variable A change, as you hit Alt/Cmd/Shift-keys.
__________________
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 09-29-2019, 06:59 AM   #713
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Quote:
Originally Posted by mespotine View Post
This should be possible. I once made something like that working for a prototype-script some time ago, but don't know, if I still have that script.

Edit:

This returns the mouse-modifiers, like gfx.mouse_cap does.

Code:
function main()
  A=reaper.JS_Mouse_GetState(-1)
  reaper.defer(main)
end

main()
Try this and watch variable A change, as you hit Alt/Cmd/Shift-keys.
Awesome, danke, will try that!
__________________
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 09-29-2019, 07:15 AM   #714
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

This can, however, have issues on Mac, when these keys are hit too often after each other(more than 30times a second, usually only a problem with mousebuttons).
They may not be noticed by your script in these cases.
This was a problem at least, when I used it the last time.
__________________
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 09-29-2019, 07:17 AM   #715
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

Ah good to know, but that won’t happen for my usecase.

EDIT: weeee, 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

Last edited by _Stevie_; 09-29-2019 at 08:40 AM.
_Stevie_ is offline   Reply With Quote
Old 09-29-2019, 08:55 AM   #716
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
Default

I did this for a quick test:

Code:
function main()
  A=reaper.JS_Mouse_GetState(-1)
  reaper.defer(main)

  if A == 5 then
    reaper.ShowConsoleMsg("CMD+Click")
  end
end

main()
But this will repeatedly give me "CMD+Click", when the mouse button is being pressed.
Is there a way to only execute it once (on click) and not during button press?
__________________
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 09-29-2019, 09:21 AM   #717
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
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   #718
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
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
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 09-30-2019, 03:25 PM   #719
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
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 offline   Reply With Quote
Old 10-01-2019, 01:32 PM   #720
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
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
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
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:39 AM.


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