Old 04-14-2021, 09:45 AM   #1561
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
Default

Any idea why

Code:
reaper.JS_Window_SetStyle(window, "CAPTION,SYSMENU")
causes this?



Notice how there is no border, initially upon the window starting, but when I move the window with my cursor a white border appears.
__________________

Support my feature request!
Dafarkias is offline   Reply With Quote
Old 04-22-2021, 12:55 PM   #1562
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Interesting. I don't know. Perhaps your Windows theme is overriding the style?

WindowBlinds (which I use on my computer) seems to override certain window styles and applies it own border and titlebar.
juliansader is offline   Reply With Quote
Old 04-23-2021, 10:37 AM   #1563
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Hi Julian,

Reaper doesn't receive pressed keys infos if the focus is on another window (like a GUI script for example).

Is it possible to send keys with "JS_WindowMessage_Send()" to Reaper ?
The idea would be to get the keys in the script with "JS_VKeys_GetState()", and to send them back to Reaper.

I can get them, but I can't manage to send them back to Reaper
Is this even possible?

Thank you
Rodilab is offline   Reply With Quote
Old 04-27-2021, 06:08 AM   #1564
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Rodilab View Post
Is it possible to send keys with "JS_WindowMessage_Send()" to Reaper ?
The idea would be to get the keys in the script with "JS_VKeys_GetState()", and to send them back to Reaper.
This question has come up before, but unfortunately I still have no better answer:

Quote:
Originally Posted by juliansader View Post
Some time ago, another user had the same issue, and my suggested solution is in this this thread: Script Requests for a reasonable $$$.

I am not sure how REAPER's keyboard input is handled "under the hood". Unlike mouse inputs, which are directed to specific windows, can be simulated with WindowMessage_Post/Send, and can be intercepted by WindowMessage_Intercept, REAPER's keyboard inputs seem to enter a global queue, and some key presses (particularly shortcuts, IIRC), do not seem to be handled via window messages.
If you are sending shortcuts for actions, you can send the action command directly with Window_OnCommand.

Amagalma did suggest a novel approach to sending keyboard input, but I haven't looked into this yet:

Quote:
Originally Posted by amagalma View Post
It seems that actions triggered by key shortcuts are in the same thread as MIDI. Jeffos had done a VST that could send MIDI in that control path ( MIDItoReaControlPath ) . Do you think it could be possible to make an API that could peek and intercept messages in that control path?
juliansader is offline   Reply With Quote
Old 05-06-2021, 08:16 AM   #1565
Malfunction
Human being with feelings
 
Malfunction's Avatar
 
Join Date: Sep 2020
Posts: 149
Default

Quote:
Originally Posted by Malfunction View Post
If I have 100s of bitmaps in a script. Is it faster to keep them and use them later, than to delete them and create new?
Found out. Drawing many things into one big bitmap is less flickery.
Malfunction is offline   Reply With Quote
Old 05-07-2021, 02:37 AM   #1566
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Hello !

I need help with a defer() LUA script.
I would like to draw a small png image with alpha that follows the mouse cursor, everywhere in Reaper.
Like a tooltip that comes in addition to the cursor displayed by Reaper (without replacing it).

I tried to follow the example of the first post in this thread. But I have difficulties to understand how it works.

Does anyone have some time to tell me what the right method is ? How to do it?

Thank you very much !
Rodilab is offline   Reply With Quote
Old 05-07-2021, 01:57 PM   #1567
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Rodilab View Post
I would like to draw a small png image with alpha that follows the mouse cursor, everywhere in Reaper.
This code will hopefully give you some pointers:
Code:
size = 30

function loop()
    x, y = reaper.GetMousePosition()
    x, y = x+10, y+(macOS and -10 or 10) -- macOS y axis has 0 at bottom
    win = reaper.JS_Window_FromPoint(x, y)
    if win ~= prevwin then
        if prevwin then reaper.JS_Composite_Unlink(prevwin, bm, true) end
        prevwin = win
        if win then win = reaper.ValidatePtr(win, "HWND") and win or nil end
    end
    if win then
        x, y = reaper.JS_Window_ScreenToClient(win, x, y)
        reaper.JS_Composite(win, x, y, size, size, bm, 0, 0, size, size, true)
    end
    reaper.defer(loop)
end
reaper.atexit(function() reaper.JS_LICE_DestroyBitmap(bm) end)

macOS = reaper.GetOS():match("OS")

n, f = reaper.JS_Dialog_BrowseForOpenFiles("", "", "", "", false)
if f then bm = reaper.JS_LICE_LoadPNG(f) end
if bm then 
    w0, h0 = reaper.JS_LICE_GetWidth(bm), reaper.JS_LICE_GetHeight(bm)
    reaper.JS_LICE_ScaledBlit(bm, 0, 0, size, size, bm, 0, 0, w0, h0, 1, "COPY")
    reaper.JS_LICE_Resize(bm, size, size)
    loop() 
end



You can also try setting a custom mouse cursor that includes your image, or perhaps create a tiny frameless window that follows the mouse cursor around. (I've not yet checked out ReaImGUI myself, but perhaps ReaImGUI offers nifty new window creation functions.)

Last edited by juliansader; 05-07-2021 at 04:07 PM.
juliansader is offline   Reply With Quote
Old 05-08-2021, 05:52 PM   #1568
dangguidan
Human being with feelings
 
Join Date: Jan 2019
Location: China
Posts: 654
Default

JS_VKeys_GetState ,When the key is not released, the mouse clicks other windows, and the return value is wrong.
The test code is as follows:
Code:
function test() 
state = reaper.JS_VKeys_GetState(0) 
ret = state:byte(65) --Key'A' 
reaper.ShowConsoleMsg(ret) 
reaper.defer(test) end 
test()
When I press the "a" button, RET is 1. If I don't release the button and click the mouse to other places in windows, RET will always be 1, even if I go back to reaper. Until you click "a" again.
In addition, recently found that if the key is not released, click the right mouse button will also appear the same problem, in software operation this situation will be more frequent.

Last edited by dangguidan; 05-08-2021 at 11:57 PM.
dangguidan is offline   Reply With Quote
Old 05-15-2021, 05:02 PM   #1569
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by dangguidan View Post
JS_VKeys_GetState ,When the key is not released, the mouse clicks other windows, and the return value is wrong.
Thanks for the report!

The fact that key-ups are not reliable is a known problem, and it is actually the reason why the function has the cutoff parameter. It is usually advisable to use a cutoff time that is as close as possible to the current time.
juliansader is offline   Reply With Quote
Old 05-30-2021, 07:44 AM   #1570
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Is there any way to choose a particular tab (window name: "Custom 1", window class: "WDLTabCtrl") of the Project Bay window?
__________________
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 05-31-2021, 05:44 AM   #1571
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

The extension does not currently provide any TabCtrl functions, but I can include them in an update.

In the meantime, if you are on WindowsOS, you can probably manually send a TCM_SETCURSEL message (using the raw value of the command).
juliansader is offline   Reply With Quote
Old 05-31-2021, 07:57 AM   #1572
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by juliansader View Post
The extension does not currently provide any TabCtrl functions, but I can include them in an update.
If it is not a lot of work, it would be nice to have

Quote:
In the meantime, if you are on WindowsOS, you can probably manually send a TCM_SETCURSEL message (using the raw value of the command).
Thanks! I've tried it but it didn't work:
Code:
proj_bay = reaper.JS_Window_Find( "Project Bay", true )
tab = reaper.JS_Window_FindChild( proj_bay, "Custom1", true )
reaper.JS_WindowMessage_Send( tab, 0x130C, 0, 0, 0, 0 )
I don't see any TCM_SETCURSEL registering in Spy++ when changing tab manually either. Maybe it is because it is a WDLTabCtrl and not a WC_TABCONTROL class?
__________________
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; 05-31-2021 at 08:02 AM.
amagalma is offline   Reply With Quote
Old 05-31-2021, 03:55 PM   #1573
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Hmmm... If these aren't standard Win32 tabs, I'm not sure how to switch them. Does Spy++ detect any other kind of window message when switching?
juliansader is offline   Reply With Quote
Old 06-01-2021, 04:55 AM   #1574
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by juliansader View Post
Hmmm... If these aren't standard Win32 tabs, I'm not sure how to switch them. Does Spy++ detect any other kind of window message when switching?

Logging all messages except mouse messages and hit-tests, spy++ logs these on mouse button down:
Code:
<000001> 00000000002409B8 S message:0x040A [User-defined:WM_USER+10] wParam:00000001 lParam:0006022E
<000002> 00000000002409B8 R message:0x040A [User-defined:WM_USER+10] lResult:80000006
<000003> 00000000002409B8 S WM_WINDOWPOSCHANGING lpwp:00144470 [wParam:0000000000000000 lParam:0000000000144470]
<000004> 00000000002409B8 R WM_WINDOWPOSCHANGING lResult:0000000000000000
<000005> 00000000002409B8 S WM_WINDOWPOSCHANGING lpwp:00144470 [wParam:0000000000000000 lParam:0000000000144470]
<000006> 00000000002409B8 R WM_WINDOWPOSCHANGING lResult:0000000000000000
<000007> 00000000002409B8 P WM_PAINT hdc:00000000 [wParam:0000000000000000 lParam:0000000000000000]
and these on mouse button up:
Code:
<000008> 00000000002409B8 S message:0x040A [User-defined:WM_USER+10] wParam:00000001 lParam:0006022E
<000009> 00000000002409B8 R message:0x040A [User-defined:WM_USER+10] lResult:00000006
<000010> 00000000002409B8 S WM_CAPTURECHANGED hwndNewCapture:00000000 [wParam:0000000000000000 lParam:0000000000000000]
<000011> 00000000002409B8 R WM_CAPTURECHANGED lResult:0000000000000000
<000012> 00000000002409B8 P WM_PAINT hdc:00000000 [wParam:0000000000000000 lParam:0000000000000000]
when changing a tab.


Any ideas?
__________________
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 06-03-2021, 01:09 AM   #1575
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by amagalma
Quote:
Originally Posted by juliansader View Post
The extension does not currently provide any TabCtrl functions, but I can include them in an update.
If it is not a lot of work, it would be nice to have

And another FR if I may.. Since we have all these very useful ListView APIs to get info from rows, could we have some to get info from columns too? Basically these 2 or 3:
Code:
- JS_ListView_GetHeader( listviewHWND ) (this can be done otherwise, so it is not essential)
- JS_Header_GetItemCount( headerHWND )
- JS_Header_GetItemText( headerHWND, index )
__________________
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 06-08-2021, 03:28 AM   #1576
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by amagalma View Post
Logging all messages except mouse messages and hit-tests, spy++ logs these on mouse button down:when changing a tab.


Any ideas?
I've tested the TabCtrl functions, but they don't work either. Unless I'm doing something wrong, it appears that REAPER isn't using Win32-style tabs in the Project Bay window.
juliansader is offline   Reply With Quote
Old 06-08-2021, 08:23 AM   #1577
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Is it possible to get access to the shortcut list of the Media Explorer and get any list item of it? I can only get the hwnd of the list

Code:
local title = reaper.JS_Localize("Media Explorer","common")
local hwnd = reaper.JS_Window_Find(title, true)
local shortcut=reaper.JS_Window_FindChildByID(hwnd, 1000)
But that's it. I can't get any chid window of it:
Code:
    for i=0, 50000 do
        local check=reaper.JS_Window_FindChildByID(shortcut, i)
        if check and check~='' then
          reaper.ShowConsoleMsg(i..' : '..reaper.JS_Window_GetTitle(check)..'\n')
        end
    end
Or any list item:
Code:
local num=reaper.JS_ListView_GetItemCount(shortcut)  --num=0
So any way can get access to it?
dsyrock is offline   Reply With Quote
Old 06-08-2021, 09:03 AM   #1578
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by dsyrock View Post
Code:
local num=reaper.JS_ListView_GetItemCount(shortcut)  --num=0
Thats because its TreeView control.

AFAIK, JS_API doesn't support TreeView controls.
Edgemeal is offline   Reply With Quote
Old 06-08-2021, 10:06 AM   #1579
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Quote:
Originally Posted by Edgemeal View Post
Thats because its TreeView control.

AFAIK, JS_API doesn't support TreeView controls.
OK, thanks!
dsyrock is offline   Reply With Quote
Old 06-08-2021, 02:05 PM   #1580
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default function SetComboBoxIndex

Works in Win10!
https://docs.microsoft.com/en-us/win.../cbn-selchange

Does it work on other OS? Could you guys test please? THANKS!

Code:
function SetComboBoxIndex(hwnd, index)
  local id = reaper.JS_Window_AddressFromHandle(reaper.JS_Window_GetLongPtr(hwnd, "ID")) 
  reaper.JS_WindowMessage_Send(hwnd, "CB_SETCURSEL", index,0,0,0)
  reaper.JS_WindowMessage_Send(reaper.JS_Window_GetParent(hwnd), "WM_COMMAND", id, 1, reaper.JS_Window_AddressFromHandle(hwnd), 0) -- 1 = CBN_SELCHANGE
end

-- Change section in Actions window
action = reaper.JS_Window_Find("Actions", true)
if action then
  section = reaper.JS_Window_FindChildByID(action, 1317) -- Section ComboBox 
  SetComboBoxIndex(section, 2) -- 2 = MIDI Editor section
end

Last edited by Edgemeal; 06-08-2021 at 02:43 PM. Reason: TYPOS
Edgemeal is offline   Reply With Quote
Old 06-08-2021, 03:41 PM   #1581
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

I know, that I can send mouse-events to hwnds, but can I send mouseevents to specific coordinates in an hwnd?

For instance, can I click at a specific coordinate in the arrangeview somehow to select/drag stuff around?
__________________
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 06-09-2021, 03:25 PM   #1582
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Yes, it should work. The WM_LBUTTONDOWN and other mouse events take the coordinates as arguments.
juliansader is offline   Reply With Quote
Old 06-18-2021, 09:08 AM   #1583
lemerchand
Human being with feelings
 
lemerchand's Avatar
 
Join Date: May 2018
Location: Sacramento, CA
Posts: 43
Default

I tried looking but I couldn't find a post that answered my question. I'm
trying to detect which key is being pressed using JS_VKeys_GetState(). I am
not testing for a particular key, though.

So far I've tried
Code:
local char = reaper.JS_VKeys_GetState(-1)
but char never seems to have any value. If I test for a particular key things work fine, for eg,
Code:
local char = reaper.JS_VKeys_GetState(-1):byte(13)
I'm really hoping to get this working with JS API so I don't have a gfx window
popping up every key press, haha!
__________________
MIDI Selector Tool

Last edited by lemerchand; 06-18-2021 at 09:24 AM.
lemerchand is offline   Reply With Quote
Old 06-19-2021, 12:07 PM   #1584
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by lemerchand View Post
So far I've tried
Code:
local char = reaper.JS_VKeys_GetState(-1)
but char never seems to have any value.
JS_VKeys_GetState returns a 255-char string -- not just a single char -- so you can use Lua's string function "find" (instead of "byte") to find the chars that aren't 0 inside the string.
juliansader is offline   Reply With Quote
Old 06-28-2021, 09:44 AM   #1585
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Can Js api access to an item in right click menu? For example, I wanna run "Browser to folder" or "Edit metadata tag" in Media Explorer's right click menu in a script, is there any api can make it?
dsyrock is offline   Reply With Quote
Old 06-28-2021, 10:17 AM   #1586
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 dsyrock View Post
Can Js api access to an item in right click menu? For example, I wanna run "Browser to folder" or "Edit metadata tag" in Media Explorer's right click menu in a script, is there any api can make it?
Nope, unfortunately not.
__________________
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 07-19-2021, 02:21 AM   #1587
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

I want to type something into the search field of Media Explorer

Code:
local title = reaper.JS_Localize("Media Explorer","common")
local hwnd = reaper.JS_Window_Find(title, true)
local search = reaper.JS_Window_FindChildByID(hwnd, 1015)
reaper.JS_Window_SetTitle(search, 'metal box')
I can see 'metal box' showed in the text field, but Media Explorer didn't start searching, even I clicked on the search field and pressed enter. Seems that it didn't "TYPE" the words in the field.

I found a workaround here:
Code:
local word='metal drop light'
for i=1, #word do
  reaper.JS_WindowMessage_Send(search, "WM_CHAR", string.byte(word:sub(i, i)), 0, 0, 0)
end
It works, but only in English words.

Last edited by dsyrock; 07-19-2021 at 03:49 AM.
dsyrock is offline   Reply With Quote
Old 07-19-2021, 08:08 AM   #1588
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

In these cases, it often helps to send additional window messages to the field that "clicks" into it. This usually activates them to accept the entered text as having being typed.
__________________
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 07-19-2021, 08:24 AM   #1589
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
In these cases, it often helps to send additional window messages to the field that "clicks" into it. This usually activates them to accept the entered text as having being typed.
I also tried:
Code:
reaper.JS_Window_SetTitle(search, word)
reaper.JS_WindowMessage_Send(search, 'WM_LBUTTONDOWN', 1, 0, 10, 10)
reaper.JS_WindowMessage_Send(search, 'WM_LBUTTONUP', 0, 0, 10, 10)
and:
Code:
reaper.JS_Window_SetTitle(search, word)
reaper.JS_Window_SetFocus(search)
But neither of them worked.
dsyrock is offline   Reply With Quote
Old 07-20-2021, 12:30 AM   #1590
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

I eventually found a work around of this issue:
Code:
local title = reaper.JS_Localize("Media Explorer","common")
local hwnd = reaper.JS_Window_Find(title, true)
local search = reaper.JS_Window_FindChildByID(hwnd, 1015)

local word='metal impact heavy'

reaper.JS_Window_SetTitle(search, word)
reaper.JS_WindowMessage_Send(search, "WM_CHAR", string.byte(' '), 5, 0, 0) --input a space
reaper.JS_WindowMessage_Post(search, "WM_KEYDOWN", 0x08, 0, 0, 0) --press backspace
reaper.JS_WindowMessage_Send(search, "WM_KEYUP", 0x08, 0, 0, 0)
dsyrock is offline   Reply With Quote
Old 07-20-2021, 06:42 AM   #1591
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by dsyrock View Post
I eventually found a work around of this issue:
Code:
local title = reaper.JS_Localize("Media Explorer","common")
local hwnd = reaper.JS_Window_Find(title, true)
local search = reaper.JS_Window_FindChildByID(hwnd, 1015)

local word='metal impact heavy'

reaper.JS_Window_SetTitle(search, word)
reaper.JS_WindowMessage_Send(search, "WM_CHAR", string.byte(' '), 5, 0, 0) --input a space
reaper.JS_WindowMessage_Post(search, "WM_KEYDOWN", 0x08, 0, 0, 0) --press backspace
reaper.JS_WindowMessage_Send(search, "WM_KEYUP", 0x08, 0, 0, 0)
FWIW, on Win10 US English that prefixes the word with a unknown char, I simply changed 'JS_WindowMessage_Post' to 'JS_WindowMessage_Send' and it works as expected.
EDIT, working but now it prefixes the word with what appears to be a space char, not sure that matters tho?

FWIW, this is what I use,..
Code:
local function PostText(hwnd, str)
  for char in string.gmatch(str, ".") do
    ret = reaper.JS_WindowMessage_Post(hwnd, "WM_CHAR", string.byte(char),0,0,0)
    if not ret then break end
  end
end

reaper.JS_Window_SetTitle(search, "") -- Erase current text in search field
PostText(search, search_word) -- type text

Last edited by Edgemeal; 07-20-2021 at 08:17 AM.
Edgemeal is offline   Reply With Quote
Old 08-06-2021, 02:04 PM   #1592
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Which would be the best/most efficient way to recreate the marquee selection? (rectangle with white 1px line border filled with alpha black)



The size would follow the mouse cursor, so what size should the bitmap have? Is it possible to do it with one bitmap only? Or more are required?

I find JS_LICE_FillRect. Isn't there a DrawRect one?
__________________
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; 08-09-2021 at 12:49 PM.
amagalma is offline   Reply With Quote
Old 08-08-2021, 07:30 AM   #1593
lemerchand
Human being with feelings
 
lemerchand's Avatar
 
Join Date: May 2018
Location: Sacramento, CA
Posts: 43
Default

Hokay, so I made a script that allows me bind actions to a string of characters, sort of vim-style. For example, there is a
Code:
g-Bindings.conf
file that has things like the following:

Goto the begining of the project
Code:
GG
Goto end of the project
Code:
GE
Goto next marker
Code:
GN
Goto prev marker
Code:
GP
And so on--you get the picture.

I've gotten it all to run surprisingly well, with the following two (related) exceptions:

First, I have a separate file of bindings for each key and that is already a lot--it's even more if I have to reload and bind them to the Actions List for MIDI Editor and Media Explorer. My soloution to this was to try and make each keybinding Global.

The problem with this is (and the second exception), is that the interception doesn't seem to act correctly here. If I make the binding Global and the second keypress is the same as the first eg,
Code:
GG
the script tries to run itself again--the whole 'There is already and instance running...would you like to terminate or create a new instance?'

If I have to I can continue on non-globally, but I'd prefer if I didn't because in addition to having to reload for each Actions List, there sometimes are issues if the window focus is on something other than the window that called it (like the mixer for example).*

*This suddenly gives me the idea that I might force the window focus to main if it detects the keypress. Not ideal, in my opinion, but if no one has an idea of what else I can do I will try this.:wq
__________________
MIDI Selector Tool
lemerchand is offline   Reply With Quote
Old 08-08-2021, 09:51 AM   #1594
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
Default

Quote:
Originally Posted by lemerchand View Post
Hokay, so I made a script that allows me bind actions to a string of characters, sort of vim-style.
No clue what that is and never tried anything like this in ReaScript, but for a dev tool I used the TAB key as a detector. I had a keylogger that held the last 4 chars typed, when a TAB key was detected it searched a database for matching key sequence and if found did whatever. Same concept of how I use code-snippets in Visual Studio now.
Edgemeal is offline   Reply With Quote
Old 08-09-2021, 12:50 PM   #1595
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by amagalma
Which would be the best/most efficient way to recreate the marquee selection? (rectangle with white 1px line border filled with alpha black)

The size would follow the mouse cursor, so what size should the bitmap have? Is it possible to do it with one bitmap only? Or more are required?

I find JS_LICE_FillRect. Isn't there a DrawRect one?
For the time being, I did it with 5 bitmaps..

Another question:
Is it possible to not have the mouse cursor blink between shapes when moving the mouse?



I used:
Code:
local cursor = reaper.JS_Mouse_LoadCursor( 32515 )
And this inside the deferred loop function:
Code:
if reaper.JS_Window_FromPoint( x, y ) == arrange then
  reaper.JS_Mouse_SetCursor( cursor )
end
__________________
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; 08-09-2021 at 01:51 PM.
amagalma is offline   Reply With Quote
Old 08-09-2021, 03:26 PM   #1596
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by lemerchand View Post
Hokay, so I made a script that allows me bind actions to a string of characters, sort of vim-style. For example, there is a
I am not quite sure what you are asking or how we can help.


Quote:
Originally Posted by lemerchand View Post
First, I have a separate file of bindings for each key and that is already a lot--it's even more if I have to reload and bind them to the Actions List for MIDI Editor and Media Explorer. My soloution to this was to try and make each keybinding Global.
I use "hotstrings" everywhere, and my script is available in ReaPack, named "js_Hotstrings". Perhaps you can use this script, or check how I approached the problem.

(It uses a single file for all linked shortcuts.)
juliansader is offline   Reply With Quote
Old 08-09-2021, 03:29 PM   #1597
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by amagalma View Post
Another question:
Is it possible to not have the mouse cursor blink between shapes when moving the mouse?
Try blocking WM_SETCURSOR messages after you set it yourself.
juliansader is offline   Reply With Quote
Old 08-09-2021, 10:59 PM   #1598
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,451
Default

Quote:
Originally Posted by juliansader View Post
Try blocking WM_SETCURSOR messages after you set it yourself.
Ah, of course! Thank you!
__________________
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 08-18-2021, 04:44 AM   #1599
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Location: Berlin
Posts: 2,163
Default

Hi guys,

I wrote a function to get the time selection of the Media Explorer. To read out the values it's necessary for the mouse to be on top of the waveform preview (the time selection values are only displayed on hover). That's why I temporarily move it using JS_Mouse_SetPosition.

This works fine for Windows & Linux, but apparently it does not work on MacOS, seems like the window never registers that it's being hovered upon. (Even if I leave the mouse on top of it for multiple defer runs).

Any clues as to why this is? Or maybe some other way to get the time selection?

Here's the code:

Edit: I updated the code as it wasn't working as expected. After moving the mouse with JS_Mouse_SetPosition, the time selection can be read out in the following 2-3 defer cycles (but not immediately).
Edit2: Removed code as I found a solution and posted it in the next post
__________________
Featured scripts: REAPER Update UtilityLil ChordboxGridbox/Adaptive gridMX TunerRS5K LinkMIDI Editor Magic Donate💝: PayPal|ko-fi

Last edited by FeedTheCat; 08-19-2021 at 04:53 AM.
FeedTheCat is offline   Reply With Quote
Old 08-18-2021, 05:40 AM   #1600
euxebio
Human being with feelings
 
euxebio's Avatar
 
Join Date: Apr 2020
Location: Italy
Posts: 22
Default

Quote:
Originally Posted by juliansader View Post
It may be possible to construct the C++ struct in a Lua string, store it using JS_Mem_Alloc and JS_Mem_FromString, and then pass the malloc address as an argument of JS_WindowMessage_Send.

Given padding inside C++ structs, 32bit and 64bit systems may have different byte-for-byte structures for HDLAYOUT.

Also, this message isn't available in WDL/swell, so it would only work on WindowsOS systems.
Very interesting..it's possible a exemple to understand how to construct the C++ struct in a Lua string, store it using JS_Mem_Alloc and JS_Mem_FromString, and then pass the malloc address as an argument of JS_WindowMessage_Send?

I don't understand how do that.
Thanks
euxebio 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 10:41 AM.


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