|
|
|
10-10-2022, 02:16 AM
|
#1841
|
Human being with feelings
Join Date: Jan 2013
Posts: 1,126
|
Hello Julian,
This function:
Code:
reaper.JS_Window_GetClientRect()
does not seem to yield similar result on windows and on osx. The "Top" and "Bottom" seems inverted.
I'm trying to figure out wether the lower dock is showing or not, comparing the Main Bottom window vs the arrange window Bottom. On windows it seems to be working but on mac, the LOWER dock showing will change the TOP and not the Bottom value? That seems to be unexpected isn't it?
|
|
|
10-12-2022, 09:38 AM
|
#1842
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Could it be the Mac-behavior that the y-coordinates start at the bottom?
|
|
|
11-01-2022, 09:52 AM
|
#1843
|
Human being with feelings
Join Date: Oct 2021
Location: France
Posts: 363
|
Hi,
I'm looking for a function that would scroll the arrangeview / TCP in order to position a given track at the top of the view.
Or maybe a bunch of functions that would help making the trick ;-)
I search into the various APIs, but no clue...
Any idea ?
|
|
|
11-01-2022, 01:10 PM
|
#1844
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
Quote:
Originally Posted by binbinhfr
Hi,
I'm looking for a function that would scroll the arrangeview / TCP in order to position a given track at the top of the view.
Or maybe a bunch of functions that would help making the trick ;-)
I search into the various APIs, but no clue...
Any idea ?
|
Maybe something like this (see post #4 and #5): https://forum.cockos.com/showthread.php?t=240962
|
|
|
11-01-2022, 01:15 PM
|
#1845
|
Human being with feelings
Join Date: Oct 2021
Location: France
Posts: 363
|
Quote:
Originally Posted by solger
|
Thanks man !
|
|
|
11-10-2022, 02:54 AM
|
#1846
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
I wrote a script to highlight the track under mouse in tcp. It looks like:
But when I copy it to another machine and run, nothing happen. Both of them using reaper v6.69 and js api v1.310. So is there anyrhing wrong in my codes?
|
|
|
11-10-2022, 03:23 AM
|
#1847
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
Quote:
Originally Posted by dsyrock
I wrote a script to highlight the track under mouse in tcp. It looks like:
But when I copy it to another machine and run, nothing happen. Both of them using reaper v6.69 and js api v1.310. So is there anyrhing wrong in my codes?
|
Path problems maybe?
|
|
|
11-10-2022, 03:34 AM
|
#1848
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by TonE
Path problems maybe?
|
You mean the path of jsapi? I think I've already installed it correctly, there is nothing warning message, the script is running but nothing show up in tcp.
|
|
|
11-10-2022, 04:33 AM
|
#1849
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
The logic seems to work, means, it recognizes track changes.
So I think, you either mess up the bitmap-creation or you draw into the wrong hwnd.
Edit: Looks more like the former. I tried with Reaper's main hwnd and nothing gets drawn into the area...
Edit2:
On what os did you try the script first and what os does the other computer have, where it doesn't work?
|
|
|
11-10-2022, 05:21 AM
|
#1850
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Meo-Ada Mespotine
The logic seems to work, means, it recognizes track changes.
So I think, you either mess up the bitmap-creation or you draw into the wrong hwnd.
Edit: Looks more like the former. I tried with Reaper's main hwnd and nothing gets drawn into the area...
Edit2:
On what os did you try the script first and what os does the other computer have, where it doesn't work?
|
Tested on 3 machines, A:win 10, succeed. B:win8, fail, nothing happen. C: win10, fail, but can see the red frame shows in wrong place. I think maybe I draw into the wrong hwnd? If so, what's the correct way to get the hwnd of TCP? Now I'm using:
Code:
local main=reaper.GetMainHwnd()
local hwnd=reaper.JS_Window_FindChildByID(main, 0)
|
|
|
11-10-2022, 09:55 AM
|
#1851
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
what's the correct way to get the hwnd of TCP?
|
On Windows I get tcp window by classname,...
Code:
local tcp_hwnd = reaper.JS_Window_FindEx(reaper.GetMainHwnd(), nil, "REAPERTCPDisplay", "")
|
|
|
11-10-2022, 11:06 AM
|
#1852
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Edgemeal
On Windows I get tcp window by classname,...
Code:
local tcp_hwnd = reaper.JS_Window_FindEx(reaper.GetMainHwnd(), nil, "REAPERTCPDisplay", "")
|
Thanks. And I tested your code and my, on my machine they are the same hwnd, I will test it on other machines later.
|
|
|
11-10-2022, 11:45 AM
|
#1853
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
Thanks. And I tested your code and my, on my machine they are the same hwnd, I will test it on other machines later.
|
Maybe depends on theme/layout or other things?, FWIW, the first child of Main with ID of zero here (Win10) is the Transport window, the second with ID zero is TCP.
|
|
|
11-10-2022, 07:32 PM
|
#1854
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Edgemeal
Maybe depends on theme/layout or other things?, FWIW, the first child of Main with ID of zero here (Win10) is the Transport window, the second with ID zero is TCP.
|
I'm confusing. I thought one ID represent one specific window, then I turn on the transport window(I hide it before), after that,
Code:
reaper.JS_Window_FindEx(reaper.GetMainHwnd(), nil, "REAPERTCPDisplay", "")
reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0)
they are not equal anymore. So apparently I was wrong, one ID represent different window in different layout.
|
|
|
11-10-2022, 09:38 PM
|
#1855
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
I thought one ID represent one specific window
|
Yes, except for ID 0 (zero).
When I hide transport its removed and TCP becomes first child with ID 0.
|
|
|
11-11-2022, 02:21 AM
|
#1856
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
From what I see, the TCP has no ID. You could get it by class-name "REAPERTCPDisplay" but I'm not sure, if that works on Mac, as getting the class of a HWND used to not work on Mac.
You can use my function to get the various HWNDs of the arrangeview:
Code:
function GetHWND_ArrangeViewAndTimeLine()
--[[
Functioncall:
HWND arrange_view, HWND timeline, HWND TrackControlPanel, HWND TrackListWindow = ultraschall.GetHWND_ArrangeViewAndTimeLine()</functioncall>
Description:
Returns the HWND-Reaper-Windowhandler for the tracklist- and timeline-area in the arrange-view
Note: in later versions of Reaper, TracklistWindow and arrange_view became the same.
returns nil in case of an error. Please report such an error, which means, that you should use ultraschall.ShowLastErrorMessage() to show that error and report the information requested(fruitful bugreports lead to a handwritten postcard as reward :) )
Retvals:
HWND arrange_view - the HWND-window-handler for the tracklist-area of the arrangeview
HWND timeline - the HWND-window-handler for the timeline/markerarea of the arrangeview
HWND TrackControlPanel - the HWND-window-handler for the track-control-panel(TCP)(may not work anymore in an upcoming Reaper-release! Send me a note in that case!)
HWND TrackListWindow - the HWND-window-handler for the tracklist-window
--]]
local function CSV2IndividualLinesAsArray(csv_line,separator)
-- check parameters
if type(csv_line)~="string" then ultraschall.AddErrorMessage("CSV2IndividualLinesAsArray","csv_line", "only string is allowed", -1) return -1 end
if separator==nil then separator="," end
-- set variables
local count=1
local line_array={}
-- small workaround
csv_line=csv_line..separator
-- do the patternmatching-magic
for line in csv_line:gmatch("(.-)"..separator) do
line_array[count]=line
count=count+1
end
return count-1, line_array
end
-- preparation of variables
local ARHWND, TLHWND, temphwnd, TCPHWND, TCPHWND2
-- if we haven't stored the adress of the arrangeviewhwnd yet, let's go find them.
if reaper.GetExtState("ultraschall", "arrangehwnd")=="" then
-- prepare some values we need
local Start, Stop = reaper.GetSet_ArrangeView2(0, false, 0, 0, 0, 0)
local Projectlength=reaper.GetProjectLength()
-- get mainhwnd of Reaper and all of it's childhwnds
local HWND=reaper.GetMainHwnd()
local retval, list = reaper.JS_Window_ListAllChild(HWND)
--Now, the magic happens
-- [ Getting Arrangeview HWND] --
-- split the hwnd-adresses into individual adresses
local Count, Individual_values = CSV2IndividualLinesAsArray(list)
-- get current scroll-state of all hwnds
local ScrollState={}
for i=1, Count do
ScrollState[i]={}
local temphwnd=reaper.JS_Window_HandleFromAddress(Individual_values[i])
ScrollState[i]["retval"], ScrollState[i]["position"], ScrollState[i]["pageSize"], ScrollState[i]["min"], ScrollState[i]["max"], ScrollState[i]["trackPos"] = reaper.JS_Window_GetScrollInfo(temphwnd,"h")
retval, ScrollState[i]["left"], ScrollState[i]["top"], ScrollState[i]["right"], ScrollState[i]["bottom"] = reaper.JS_Window_GetRect(temphwnd)
end
-- alter scrollstate
reaper.GetSet_ArrangeView2(0, true, 0, 0, Start+100000,Stop+100000)
-- check scrollstate of all hwnds for the one, whose scrollstate changed, as this is the arrange-view-hwnd
for i=1, Count do
temphwnd=reaper.JS_Window_HandleFromAddress(Individual_values[i])
local retval, position, pageSize, min, max, trackPos = reaper.JS_Window_GetScrollInfo(temphwnd,"h")
if position~=ScrollState[i]["position"] or
pageSize~=ScrollState[i]["pageSize"] or
min~=ScrollState[i]["min"] or
max~=ScrollState[i]["max"] or
trackPos~=ScrollState[i]["trackPos"] then
ARHWND=temphwnd
break
end
end
-- reset arrangeview-scrolling to it's original state
reaper.GetSet_ArrangeView2(0, true, 0, 0, Start,Stop)
-- [ Getting Timeline HWND] --
-- let's get the dimensions of the arrangeview-hwnd, as top, left and right-positions can be used
-- to determine bottom, left, right of the timeline-hwnd
local retval, left, top, right, bottom = reaper.JS_Window_GetRect(ARHWND)
-- TimeLine: check all hwnds to find the one, that has right=right, left=left, bottom_timeline=top_arrangeview
for i=1, Count do
local temphwnd=reaper.JS_Window_HandleFromAddress(Individual_values[i])
if ScrollState[i]["left"]==left and ScrollState[i]["right"]==right and ScrollState[i]["bottom"]==top then
TLHWND=temphwnd
break
end
end
-- TCP: check all hwnds to find the one, that has right<left, top=top, bottom_timeline=top_arrangeview
for i=1, Count do
local temphwnd=reaper.JS_Window_HandleFromAddress(Individual_values[i])
if (reaper.GetToggleCommandState(42373)==0 and ScrollState[i]["right"]<=left
and ScrollState[i]["top"]==top
and ScrollState[i]["bottom"]==bottom-18)
or
(reaper.GetToggleCommandState(42373)==1 and ScrollState[i]["left"]>=right
and ScrollState[i]["top"]==top
and ScrollState[i]["bottom"]==bottom-18)
then
if TCPHWND==nil then
TCPHWND=temphwnd
else
TCPHWND2=temphwnd
if reaper.JS_Window_GetParent(TCPHWND2)==TCPHWND then TCPHWND=TCPHWND2 end
end
end
end
-- store the adresses of the found HWNDs of Arrangeview and Timeline into an extstate for further use, to prevent useless
-- scroll-state-altering of the Arrangeview(which could cause stuck Arrangeviews, when done permanently)
reaper.SetExtState("ultraschall", "arrangehwnd", reaper.JS_Window_AddressFromHandle(ARHWND), false)
reaper.SetExtState("ultraschall", "timelinehwnd", reaper.JS_Window_AddressFromHandle(TLHWND), false)
if TCPHWND~=nil then
reaper.SetExtState("ultraschall", "tcphwnd", reaper.JS_Window_AddressFromHandle(TCPHWND), false)
end
else
-- if the extstate already has stored the arrangeview-hwnd-address, just convert the one for arrangeview and timeline
-- it into their handles and return them
ARHWND=reaper.JS_Window_HandleFromAddress(reaper.GetExtState("ultraschall", "arrangehwnd"))
TLHWND=reaper.JS_Window_HandleFromAddress(reaper.GetExtState("ultraschall", "timelinehwnd"))
TCPHWND=reaper.JS_Window_HandleFromAddress(reaper.GetExtState("ultraschall", "tcphwnd"))
if TCPHWND=="" then TCPHWND=nil end
end
return ARHWND, TLHWND, TCPHWND, reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
end
HWND_Arr, HWND_TimeLine, HWND_TCP = GetHWND_ArrangeViewAndTimeLine()
It returns Arrangeview, Timeline and TCP(the one you need). Needs SWS and JS-extension to work
Maybe this helps you.
|
|
|
11-11-2022, 03:53 AM
|
#1857
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Meo-Ada Mespotine
From what I see, the TCP has no ID. You could get it by class-name "REAPERTCPDisplay" but I'm not sure, if that works on Mac, as getting the class of a HWND used to not work on Mac.
You can use my function to get the various HWNDs of the arrangeview:
It returns Arrangeview, Timeline and TCP(the one you need). Needs SWS and JS-extension to work
Maybe this helps you.
|
Ah thanks! I will check these amazing codes later. For now I use class name to get the tcp hwnd, and still only work on win10, but not win8.
Last edited by dsyrock; 11-11-2022 at 04:11 AM.
|
|
|
11-11-2022, 10:05 AM
|
#1858
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
Ah thanks! I will check these amazing codes later. For now I use class name to get the tcp hwnd, and still only work on win10, but not win8.
|
Don't you have an app like MS SPY++ so you can view the window layout of REAPER? Otherwise how can you even do stuff like this?
|
|
|
11-11-2022, 10:39 AM
|
#1859
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Edgemeal
Don't you have an app like MS SPY++ so you can view the window layout of REAPER? Otherwise how can you even do stuff like this?
|
Yes, I use a tool called windows spy in AHK, and using it I'm pretty sure that I've got the correct tcp class name, and then hwnd, but still cannot draw anything on it. I even succeed in Win10 and Win7, but not Win8.
|
|
|
11-11-2022, 11:02 AM
|
#1860
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
Yes, I use a tool called windows spy in AHK, and using it I'm pretty sure that I've got the correct tcp class name, and then hwnd, but still cannot draw anything on it. I even succeed in Win10 and Win7, but not Win8.
|
Oh OK, I don't have Win8 to test, good luck!
|
|
|
11-11-2022, 11:28 AM
|
#1861
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Can anyone help me to test this script and tell me what happen on your machine? I borrow some codes from Meo-Ada Mespotine, thanks!
|
|
|
11-11-2022, 11:50 AM
|
#1862
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by dsyrock
Can anyone help me to test this script and tell me what happen on your machine? I borrow some codes from Meo-Ada Mespotine, thanks!
|
With TCP on left side, it draws OK, unless track heights are resized, or TCP width is changed.
With TCP on right side I get error when staring script,
29: attempt to perform arithmetic on a nil value (local 'viewRight')
Win10/REAPER v6.69_x64
|
|
|
11-11-2022, 12:28 PM
|
#1863
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by Edgemeal
With TCP on left side, it draws OK, unless track heights are resized, or TCP width is changed.
With TCP on right side I get error when staring script,
29: attempt to perform arithmetic on a nil value (local 'viewRight')
Win10/REAPER v6.69_x64
|
Really helpful, thanks
|
|
|
11-12-2022, 05:12 AM
|
#1864
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
When you are compositing the bitmap:
Code:
reaper.JS_Composite(hwnd, tcpX, tcpY, tcpW, tcpH, bitmap, 0, 0, tcpW, tcpH, true)
the second argument should be 0 instead of tcpX. JS_Composite requires client coordinates, but tcpX is a screen coordinate returned by GetRect.
I was surprised to note that the TCP doesn't have any ID. It may be a good idea to ask Justin/Schwa to give this window an ID, since IDs are (AFAIK) the only reliable way to find child windows that work cross-platform. Class names are not the same on all platforms.
Last edited by juliansader; 11-12-2022 at 05:20 AM.
|
|
|
11-12-2022, 08:16 AM
|
#1865
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by juliansader
When you are compositing the bitmap:
Code:
reaper.JS_Composite(hwnd, tcpX, tcpY, tcpW, tcpH, bitmap, 0, 0, tcpW, tcpH, true)
the second argument should be 0 instead of tcpX. JS_Composite requires client coordinates, but tcpX is a screen coordinate returned by GetRect.
I was surprised to note that the TCP doesn't have any ID. It may be a good idea to ask Justin/Schwa to give this window an ID, since IDs are (AFAIK) the only reliable way to find child windows that work cross-platform. Class names are not the same on all platforms.
|
Hi julian, about this api
Code:
reaper.JS_Composite(hwnd, tcpX, tcpY, tcpW, tcpH, bitmap, 0, 0, tcpW, tcpH, true)
I used it on two machines, win7 and win10, and they warned: this api expected 10 arguments maximum. Both of them are running the latest js api extension.
|
|
|
11-12-2022, 12:34 PM
|
#1866
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by dsyrock
I used it on two machines, win7 and win10, and they warned: this api expected 10 arguments maximum. Both of them are running the latest js api extension.
|
That is strange.
* If you open the API Help webpage, or if you check the realtime help in the IDE, which parameters are listed for the function?
* Could you please double-check the API version with JS_Version?
BTW, the "unsupported autoUpdate" that you'll see as the last parameter is an old bug that deserves a bump: Extension API: Optional boolean parameter "unsupported" in IDE and API help.
Last edited by juliansader; 11-12-2022 at 01:02 PM.
|
|
|
11-13-2022, 11:32 AM
|
#1867
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
I finally find out what makes the same script running differently in differrent machines, it is the color parameter!
At first, I wrote like this:
Code:
reaper.JS_LICE_Clear(bitmap, 0)
and
Code:
reaper.JS_LICE_RoundRect(bitmap, 0, 0, tcpW-3, tcpH-1, 5, 0xFF0000, 1, '', 1)
It works in Win10 but fails in Win8, then I change them to
Code:
reaper.JS_LICE_Clear(bitmap, 0x00000000)
and
Code:
reaper.JS_LICE_RoundRect(bitmap, 0, 0, tcpW-3, tcpH-1, 5, 0xFFFF0000, 1, '', 1)
or
reaper.JS_LICE_RoundRect(bitmap, 0, 0, tcpW-3, tcpH-1, 5, 0x00FF0000, 1, '', 1)
then both of the machines work! Maybe I have to declare the AA value in Win8, but in Win10 can be omitted? No clue, but fixxing it is more important.
By the way, I'm still confused about JS_LICE_Clear, I think it is to clear everything drawed in the bitmap, but what's the meaning of the color parameter?
|
|
|
11-14-2022, 12:43 AM
|
#1868
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Quote:
Originally Posted by juliansader
That is strange.
* If you open the API Help webpage, or if you check the realtime help in the IDE, which parameters are listed for the function?
* Could you please double-check the API version with JS_Version?
BTW, the "unsupported autoUpdate" that you'll see as the last parameter is an old bug that deserves a bump: Extension API: Optional boolean parameter "unsupported" in IDE and API help.
|
My bad, I gave the latest file to my friends, but they mess up with the file and still running the old version of it.
|
|
|
12-01-2022, 09:58 AM
|
#1869
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Just in case, someone is looking for code-examples on how to use JS_VKeys_GetState:
Here's a simple example-code, that shows in the watchlist, if A or B or C has been pressed:
Code:
function main()
Astate = reaper.JS_VKeys_GetState(0)
A_key_has_been_pressed=string.byte(Astate:sub(65,65))
B_key_has_been_pressed=string.byte(Astate:sub(66,66))
C_key_has_been_pressed=string.byte(Astate:sub(67,67))
reaper.defer(main)
end
main()
This example-code shows, which key is pressed:
Code:
function main()
Astate = reaper.JS_VKeys_GetState(0)
reaper.ClearConsole()
for i=1, 255 do
if string.byte(Astate:sub(i,i))==1 then
reaper.ShowConsoleMsg(i.." is pressed\n")
end
end
reaper.defer(main)
end
main()
|
|
|
12-02-2022, 04:13 AM
|
#1870
|
Human being with feelings
Join Date: Jul 2022
Posts: 82
|
Opening main REAPER menus via js_ReaScriptAPI or other ReaScript commands
Does anybody know a programmatic way using js_ReaScriptAPI or otherwise to open the main REAPER menu to a certain point?
For example, as in the picture below to Track=>MIDI track controls=>Link track volume/pan to MIDI channel=>8
|
|
|
12-02-2022, 04:20 AM
|
#1871
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Nope, not possible. You need to find another way to link them via script.
Is this parameter-linking or what is it exactly?
|
|
|
12-02-2022, 10:23 AM
|
#1872
|
Human being with feelings
Join Date: Feb 2009
Location: Reaper HAS send control via midi !!!
Posts: 4,031
|
"Just in case, someone is looking for code-examples on how to use ..."
I am always looking for code examples regarding midi mapping export / import, as you know my old project, in CSV format. Anything what can be useful there. Not sure how stable the functions are now regarding that. Too many new function s were added lately I guess. So was waiting a bit more, until it stabilizes. Including Ultraschall api, with its changes.
|
|
|
12-07-2022, 07:54 AM
|
#1873
|
Human being with feelings
Join Date: Jan 2019
Location: Taiwan
Posts: 432
|
Any way to hide mouse on MacOS?
passing nil to r.JS_Mouse_SetCursor(identifier cursorHandle) can't seem to hide the mouse cursor on Mac, just wondering if anyone knows how to do this? Thank you!!
Edit: loading a fully transparent mouse cursor file achieves this, but if there's a way to do this without the extra cursor file please let me know, thank you!!
Last edited by BryanChi; 12-07-2022 at 10:29 PM.
|
|
|
12-17-2022, 05:43 AM
|
#1874
|
Human being with feelings
Join Date: Jan 2020
Location: Amoy
Posts: 179
|
Hi, The script below does not work in Media Explorer.
I'm not sure if the problem comes from [reaper.JS_ListView_GetItemCount] and [reaper.JS_ListView_ListAllSelItems], it seems like they fail.
OS: Windows 11 Pro 22H2 (x64)
REAPER version: 6.71 (x64)
Code:
MediaDB = "Desktop"
function Send_KeyDownUp(hwnd, vk_key)
reaper.JS_WindowMessage_Send(hwnd, "WM_KEYDOWN", vk_key, 0,0,0)
reaper.JS_WindowMessage_Send(hwnd, "WM_KEYUP", vk_key, 0,0,0)
end
function SelectShortcut(find)
if not find or find == '' then return end
local title = reaper.JS_Localize("Media Explorer", "common")
local explorer = reaper.JS_Window_Find(title, true)
-- get handle to 'Shortcut' Listview in media explorer.
local lv = reaper.JS_Window_FindChildByID(explorer, 1000)
if not lv then return end
-- loop thru LV list, find matching text in find.
local new_index = -1
local count = reaper.JS_ListView_GetItemCount(lv)
if count == 0 then return end
for index = 0, count-1 do
item_text = reaper.JS_ListView_GetItemText(lv, index, 0) -- get lv item text in column 0.
if item_text == find then
new_index = index
break
end
end
reaper.JS_Window_SetFocus(lv)
local VK_HOME = 0x24 -- https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes
local VK_DOWN = 0x28
-- Send "Home" key to LV, (selects first item in LV).
Send_KeyDownUp(lv, VK_HOME)
-- send Down-arrow keys to LV (to select matching LV item).
for index = 0, new_index-1 do
Send_KeyDownUp(lv, VK_DOWN)
end
end -- end function
SelectShortcut(MediaDB)
and this script:
https://forum.cockos.com/showpost.ph...&postcount=140
Code:
-- Testing: x64, Windows 7, REAPER v5.963+dev1213, js_ReaScriptAPI v0.961.
function print(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n") -- console
end
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end
local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)
sel_count, sel_indexes = reaper.JS_ListView_ListAllSelItems(file_LV)
if sel_count == 0 then return end
for ndx in string.gmatch(sel_indexes, '[^,]+') do
index = tonumber(ndx)
local fname = reaper.JS_ListView_GetItemText(file_LV, index, 0)
local size = reaper.JS_ListView_GetItemText(file_LV, index, 1)
local date = reaper.JS_ListView_GetItemText(file_LV, index, 2)
local ftype = reaper.JS_ListView_GetItemText(file_LV, index, 3)
print(fname .. ', ' .. size .. ', ' .. date .. ', ' .. ftype)
end
-- get selected path from edit control inside combobox
local combo = reaper.JS_Window_FindChildByID(hWnd, 1002)
local edit = reaper.JS_Window_FindChildByID(combo, 1001)
local path = reaper.JS_Window_GetTitle(edit, "", 255)
print(path)
Last edited by zaibuyidao; 12-17-2022 at 06:22 AM.
|
|
|
12-17-2022, 07:32 AM
|
#1875
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
Quote:
Originally Posted by zaibuyidao
Hi, The script below does not work in Media Explorer.
I'm not sure if the problem comes from [reaper.JS_ListView_GetItemCount] and [reaper.JS_ListView_ListAllSelItems], it seems like they fail.
OS: Windows 11 Pro 22H2 (x64)
REAPER version: 6.71 (x64)
Code:
MediaDB = "Desktop"
function Send_KeyDownUp(hwnd, vk_key)
reaper.JS_WindowMessage_Send(hwnd, "WM_KEYDOWN", vk_key, 0,0,0)
reaper.JS_WindowMessage_Send(hwnd, "WM_KEYUP", vk_key, 0,0,0)
end
function SelectShortcut(find)
if not find or find == '' then return end
local title = reaper.JS_Localize("Media Explorer", "common")
local explorer = reaper.JS_Window_Find(title, true)
-- get handle to 'Shortcut' Listview in media explorer.
local lv = reaper.JS_Window_FindChildByID(explorer, 1000)
if not lv then return end
-- loop thru LV list, find matching text in find.
local new_index = -1
local count = reaper.JS_ListView_GetItemCount(lv)
if count == 0 then return end
for index = 0, count-1 do
item_text = reaper.JS_ListView_GetItemText(lv, index, 0) -- get lv item text in column 0.
if item_text == find then
new_index = index
break
end
end
reaper.JS_Window_SetFocus(lv)
local VK_HOME = 0x24 -- https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes
local VK_DOWN = 0x28
-- Send "Home" key to LV, (selects first item in LV).
Send_KeyDownUp(lv, VK_HOME)
-- send Down-arrow keys to LV (to select matching LV item).
for index = 0, new_index-1 do
Send_KeyDownUp(lv, VK_DOWN)
end
end -- end function
SelectShortcut(MediaDB)
and this script:
https://forum.cockos.com/showpost.ph...&postcount=140
Code:
-- Testing: x64, Windows 7, REAPER v5.963+dev1213, js_ReaScriptAPI v0.961.
function print(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n") -- console
end
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end
local container = reaper.JS_Window_FindChildByID(hWnd, 0)
local file_LV = reaper.JS_Window_FindChildByID(container, 1000)
sel_count, sel_indexes = reaper.JS_ListView_ListAllSelItems(file_LV)
if sel_count == 0 then return end
for ndx in string.gmatch(sel_indexes, '[^,]+') do
index = tonumber(ndx)
local fname = reaper.JS_ListView_GetItemText(file_LV, index, 0)
local size = reaper.JS_ListView_GetItemText(file_LV, index, 1)
local date = reaper.JS_ListView_GetItemText(file_LV, index, 2)
local ftype = reaper.JS_ListView_GetItemText(file_LV, index, 3)
print(fname .. ', ' .. size .. ', ' .. date .. ', ' .. ftype)
end
-- get selected path from edit control inside combobox
local combo = reaper.JS_Window_FindChildByID(hWnd, 1002)
local edit = reaper.JS_Window_FindChildByID(combo, 1001)
local path = reaper.JS_Window_GetTitle(edit, "", 255)
print(path)
|
What are the scripts supposed to do and what does fail exactly mean?
|
|
|
12-17-2022, 08:49 AM
|
#1876
|
Human being with feelings
Join Date: Jan 2020
Location: Amoy
Posts: 179
|
Quote:
Originally Posted by Meo-Ada Mespotine
What are the scripts supposed to do and what does fail exactly mean?
|
The first script, if there are no problems will focus and select the Media Explorer "Desktop" shortcut.
The second script, which also works in the media browser, is used to get a handle to the file Listview, as well as other information.
I have tested the above scripts and they have problems:
reaper.JS_ListView_GetItemCount and reaper.JS_ListView_ListAllSelItems get parameters that are always 0 and the script does not work properly.
Last edited by zaibuyidao; 12-17-2022 at 09:06 AM.
|
|
|
12-17-2022, 09:14 AM
|
#1877
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by zaibuyidao
Hi, The script below does not work in Media Explorer.
|
That code is outdated, REAPER changed some of the controls and the layout of the Media Explorer around v6.12 ~ 6.15. The shortcut list is now a TreeView control so that old code wont work anymore, for reading the file list and path, this should work,..
Code:
-- Testing: Win10, REAPER v6.71_x64, js_ReaScriptAPI v1.31
function print(str)
reaper.ShowConsoleMsg(tostring(str) .. "\n") -- console
end
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
if hWnd == nil then return end
local file_LV = reaper.JS_Window_FindChildByID(hWnd, 1001)
sel_count, sel_indexes = reaper.JS_ListView_ListAllSelItems(file_LV)
for ndx in string.gmatch(sel_indexes, '[^,]+') do
index = tonumber(ndx)
local fname = reaper.JS_ListView_GetItemText(file_LV, index, 0)
local size = reaper.JS_ListView_GetItemText(file_LV, index, 1)
local date = reaper.JS_ListView_GetItemText(file_LV, index, 2)
local ftype = reaper.JS_ListView_GetItemText(file_LV, index, 3)
print(fname .. ', ' .. size .. ', ' .. date .. ', ' .. ftype)
end
-- get path
local path_hwnd = reaper.JS_Window_FindChildByID(hWnd, 1002)
local path = reaper.JS_Window_GetTitle(path_hwnd, "", 255)
print(path)
Last edited by Edgemeal; 12-17-2022 at 09:26 AM.
Reason: Add test version info
|
|
|
12-17-2022, 10:00 AM
|
#1878
|
Human being with feelings
Join Date: Jan 2020
Location: Amoy
Posts: 179
|
Quote:
Originally Posted by Edgemeal
That code is outdated, REAPER changed some of the controls and the layout of the Media Explorer around v6.12 ~ 6.15. The shortcut list is now a TreeView control so that old code wont work anymore, for reading the file list and path, this should work,..
|
Thank you, Edgemeal.
I found that ID: 1000 is not working. The shortcut list is now a TreeView control, so if I want to focus and select the "Desktop" shortcut in Media Explorer via script, is there a way to do it?
|
|
|
12-17-2022, 10:24 AM
|
#1879
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by zaibuyidao
Thank you, Edgemeal.
I found that ID: 1000 is not working. The shortcut list is now a TreeView control, so if I want to focus and select the "Desktop" shortcut in Media Explorer via script, is there a way to do it?
|
AFAIK we can't read TreeView control text. To set the path you can try this, but it doesn't update the treeview control (shortcut list) to the path.
Code:
-- Testing: Win10, REAPER v6.71_x64, js_ReaScriptAPI v1.31
function PostKey(hwnd, vk_code) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
reaper.JS_WindowMessage_Post(hwnd, "WM_KEYDOWN", vk_code, 0,0,0)
reaper.JS_WindowMessage_Post(hwnd, "WM_KEYUP", vk_code, 0,0,0)
end
function PostText(hwnd, str) -- https://docs.microsoft.com/en-us/windows/win32/inputdev/wm-char
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
function SetExplorerPath(hwnd, folder)
local cbo = reaper.JS_Window_FindChildByID(hwnd, 0x3EA)
local edit = reaper.JS_Window_FindChildByID(cbo, 0x3E9)
if edit then
reaper.JS_Window_SetTitle(edit, "")
PostText(edit, folder)
PostKey(edit, 0xD) -- post Return key
end
end
local hWnd = reaper.JS_Window_Find("Media Explorer", true)
SetExplorerPath(hWnd, "Desktop") -- name of path/DB, e.g., "DB: My Reaper Songs 2022"
Last edited by Edgemeal; 12-17-2022 at 10:31 AM.
Reason: Add test version info
|
|
|
12-19-2022, 11:53 PM
|
#1880
|
Human being with feelings
Join Date: Jan 2020
Location: Amoy
Posts: 179
|
Quote:
Originally Posted by Edgemeal
AFAIK we can't read TreeView control text. To set the path you can try this, but it doesn't update the treeview control (shortcut list) to the path.
|
Thank you very much, I will try it as soon as possible.
--
There is no problem except that the [Shortcut List] item cannot be selected. I think this is the best solution for now.
Thank you, Edgemeal.
Last edited by zaibuyidao; 12-26-2022 at 06:51 PM.
Reason: Adding content
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 11:35 AM.
|