|
|
|
01-07-2020, 09:44 AM
|
#881
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
Julian again I need a little assistance this time for OSX...
Unlike before V6 core reaper changes (track UI changes), now the script detects tracks out of the box, which was not the case before (did not detect them since tracks Y position was calculated via JS_API.
So this is only a matter of inverting the coordinates then?
This is the main and only function that stores all tracks coordinates and the rest of the script just reads it, so I assume it only needs modification here in order to work with OSX:
Code:
local TBH
function GetTracksXYH()
TBH = {}
local _, x_view_start, y_view_start, x_view_end, y_view_end = reaper.JS_Window_GetRect(track_window)
-- ONLY ADD MASTER TRACK IF VISIBLE IN TCP
if reaper.GetMasterTrackVisibility() == 1 then
local master_tr = reaper.GetMasterTrack(0)
local m_tr_h = reaper.GetMediaTrackInfo_Value(master_tr, "I_TCPH")
local m_tr_t = reaper.GetMediaTrackInfo_Value(master_tr, "I_TCPY") + y_view_start
local m_tr_b = m_tr_t + m_tr_h
TBH[master_tr] = {t = m_tr_t, b = m_tr_b, h = m_tr_h}
end
for i = 1, reaper.CountTracks(0) do
local tr = reaper.GetTrack(0, i - 1)
local tr_h = reaper.GetMediaTrackInfo_Value(tr, "I_TCPH")
local tr_t = reaper.GetMediaTrackInfo_Value(tr, "I_TCPY") + y_view_start
local tr_b = tr_t + tr_h
TBH[tr] = {t = tr_t, b = tr_b, h = tr_h}
for j = 1, reaper.CountTrackEnvelopes(tr) do
local env = reaper.GetTrackEnvelope(tr, j - 1)
local env_h = reaper.GetEnvelopeInfo_Value(env, "I_TCPH")
local env_t = reaper.GetEnvelopeInfo_Value(env, "I_TCPY") + tr_t
local env_b = env_t + env_h
TBH[env] = {t = env_t, b = env_b, h = env_h}
end
end
end
My brain is little stuck ATM what am I supposed to do? Subtract track top and bot with the height of the window?
and btw this is the drawing code in case I need to add something here also:
Code:
function Element:draw()
local _, x_view_start, y_view_start = reaper.JS_Window_GetRect(track_window)
reaper.JS_Composite(track_window, self.x - x_view_start, self.y - y_view_start, self.w, self.h, self.bm, 0, 0, 1, 1)
refresh_reaper()
end
where self.y is just tr_t
EDIT:
Figured I need to reverse the track bottom
right now everything is "fine" tracks are exactly on same pixels as the mouse is, coordinates now match. But where is the problem? What API expects "normal" in this case "inverted" coordinates? I guess mouse also needs to be inverted?
EDIT:
I really hope there is some simple solution to this, because I've modified a lot of calculating code and inverted lots of things to many functions to get right coordinates but still got nowhere
Last edited by Sexan; 01-07-2020 at 12:54 PM.
|
|
|
01-08-2020, 10:53 AM
|
#883
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
The main problem is that all of my functions and important variables are all inverted. My top variables are bottom, bottom is top, then I have other calculations to inverse that in case you start drawing from bottom up instead of top to bottom.
I need some starting point because I'm a little bit scared of modifying 50% of the script to not brake things.
I hope we can modify only the main function that gets all the coordinates and stores them if we can modify only it
|
|
|
01-08-2020, 01:01 PM
|
#884
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
Well some progress,its not drawing but its getting all the information under it, and now keys do not work??
I'm not getting ANY respond from keys I press (from script)
Code:
-- FOR WINDOWS
for i = 1, 255 do
local func
local name = string.char(i)
if type(tonumber(name)) == "number" then
func = select_as
end
if i == 16 then
name = "Shift"
elseif i == 17 then
name = "Ctrl"
elseif i == 18 then
name = "Alt"
elseif i == 13 then
name = "Return"
elseif i == 8 then
name = "Backspace"
elseif i == 32 then
name = "Space"
elseif i == 20 then
name = "Caps-Lock"
elseif i == 27 then
name = "ESC"
func = remove
elseif i == 9 then
name = "TAB"
elseif i == 192 then
name = "~"
elseif i == 91 then
name = "Win"
elseif i == 45 then
name = "Insert"
elseif i == 46 then
name = "Del"
func = del
elseif i == 36 then
name = "Home"
elseif i == 35 then
name = "End"
elseif i == 33 then
name = "PG-Up"
elseif i == 34 then
name = "PG-Down"
end
Key_TB[#Key_TB + 1] = Key:new({i}, name, func)
end
This is how I fill the table with all the keys, it should at least return letters and numbers but keyboard is not responding at all (script)
https://github.com/GoranKovac/ReaScr...a_51_input.lua
UPDATE 2:
It seems something is wrong with drawing also, cannot seem to get anything on the screen even manually entering coordinates:
Code:
track_window = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8) -- all platforms
function Element:draw()
reaper.JS_Composite(track_window, 400, 400, 400, 400, self.bm, 0, 0, 1, 1)
refresh_reaper()
end
This should draw fixed rectangle when I make first area but its not drawing anything.
The current status is that that script gets all the data, it draws "invisible" areas and all the info is there, all the tables are filled but:
1. Cannot draw anything on screen
2. Keys do not work
Last edited by Sexan; 01-08-2020 at 11:28 PM.
|
|
|
01-09-2020, 02:35 PM
|
#885
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Sexan
My brain is little stuck ATM what am I supposed to do? Subtract track top and bot with the height of the window?
EDIT:
Figured I need to reverse the track bottom
right now everything is "fine" tracks are exactly on same pixels as the mouse is, coordinates now match. But where is the problem? What API expects "normal" in this case "inverted" coordinates? I guess mouse also needs to be inverted?
EDIT:
I really hope there is some simple solution to this, because I've modified a lot of calculating code and inverted lots of things to many functions to get right coordinates but still got nowhere
|
The method in the link that nofish posted is usually the best solution, and requires no arithmetic or different code for macOS:
* Some functions use or return *screen* coordinates, such as GetMousePosition, JS_Window_FromPoint, GetTrackFromPoint and GetItemFromPoint. These coordinates differ between Windows/Linux and macOS.
* Others use *client* coordinates, such as the LICE drawing functions, or GetMediaTrackInfo_Value(track, "I_TCPY"). These are the same between Windows /Linux and macOS.
I suggest that you only use screen coordinates when getting the mouse position and the track under the mouse. Then convert to client coordinates to do all the rest.
|
|
|
01-09-2020, 04:54 PM
|
#886
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
@sexan
When you have a lot of elseif statemebt like that,
consider just using a simple associative table
where names is a table containing all your indexes and value.
This way it doesnt have to test everything :P
|
|
|
01-10-2020, 01:37 AM
|
#887
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
I have them like this because string.char returns empty string for those keys
|
|
|
01-10-2020, 02:18 AM
|
#888
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
@sexan
Code:
if string.char(i) == "" then
name = blabla
else
name = names[i]
end
still way more efficient :]
But this is micro optimization, not very important at least not in this thread.
|
|
|
01-10-2020, 06:09 AM
|
#889
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
I cannot draw anything, even with manually entering coordinates...
Code:
track_window = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8) -- all platforms
function Element:draw()
reaper.JS_Composite(track_window, 400, 400, 400, 400, self.bm, 0, 0, 1, 1)
refresh_reaper()
end
This modification works on windows so I assume it will also work with other platforms but I still cannot draw anything on OSX
Code:
track_window = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8) -- all platforms
function Element:draw()
local cx,cy = reaper.JS_Window_ScreenToClient(track_window,self.x,self.y)
reaper.JS_Composite(track_window, cx, cy, self.w, self.h, self.bm, 0, 0, 1, 1)
refresh_reaper()
end
Its drawing INVISIBLE areas and it collects all the data from it correctly. So everything works except drawing (ATM at least) regarding data.
Still not sure why I do not get any response from Keyboard. Does OSX need any addition in order for JS_VKeys_GetState to work?
Last edited by Sexan; 01-10-2020 at 06:15 AM.
|
|
|
01-10-2020, 09:09 AM
|
#890
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Warning re OSX: Users of my MIDI scripts have discovered a bug in REAPER's functions for blitting transparent images on OSX. If the Metal graphics API is enabled (mostly Mojave and later, but also some older systems), alpha blending is not performed, so the blitted images are fully opaque.
Unfortunately, Justin warned that it may be difficult to implement, so I'm not sure when it will be fixed. Anyone interested may track the progress in the bug report thread: WDL/swell on OSX: BitBlt and StretchBlt: SRCCOPY_USEALPHACHAN not working.
|
|
|
01-11-2020, 12:17 PM
|
#891
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Sexan
Still not sure why I do not get any response from Keyboard. Does OSX need any addition in order for JS_VKeys_GetState to work?
|
Which keys are you trying to detect? As mentioned in the API documentation, mouse buttons and modifier keys are not reliably detected by the VKeys functions, and Mouse_GetState should be used instead.
In the case of WindowsOS, VKeys should detect modifier keys, but in the case of Linux and macOS, I haven't figured out a way to detect them.
We can submit a feature request for REAPER to send modifier keys to the keyboard hook.
|
|
|
01-11-2020, 12:58 PM
|
#892
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
The general problem is as I've mentioned above I cannot draw anything even manually entering coordinates. Nothing is drawing on screen. Regarding keys you can check my Area_51_input class script and its not returning ANY key not modifiers,nothing.
I'm really sorry for bothering you but I just don't understand the osx.I got one to try to fix the problem but I cant get anything to work. I have all the data so coordinates are correct because the script is working but its not drawing and keys are not working.
|
|
|
01-12-2020, 07:13 AM
|
#893
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
Is there a way to know if a window is floating or not ? and pinned ?
Also simple question, what is the funciton to get a windowHWND from simple ID (and not a reaper object) ?
|
|
|
01-12-2020, 08:54 AM
|
#894
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by X-Raym
Is there a way to know if a window is floating or not ?
|
If you mean, Is window a floating plugin window or a FX Chain window? then since the window styles seem to be identical then Id' check if window has one or more specific controls on it, for example the fx chain window has a ListView control but floating plugin windows don't.
|
|
|
01-12-2020, 10:33 AM
|
#895
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Quote:
Originally Posted by X-Raym
Also simple question, what is the funciton to get a windowHWND from simple ID (and not a reaper object) ?
|
What do you mean by 'simple ID', how did you retrieve this ID?
|
|
|
01-12-2020, 11:24 AM
|
#896
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Sexan
The general problem is as I've mentioned above I cannot draw anything even manually entering coordinates. Nothing is drawing on screen.
|
Is it only the Area51 script that doesn't draw composites, or does the function not work at all? For example, does this barebones script draw anything?
Code:
bm = reaper.JS_LICE_CreateBitmap(true, 1, 1)
reaper.JS_LICE_Clear(bm, 0xFFFF0000)
tv = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
cOK = reaper.JS_LICE_Composite(tv, 100, 100, 100, 100, bm, 0, 0, 1, 1)
reaper.JS_Window_InvalidateRect(tv, 100, 100, 200, 200, false)
Quote:
Originally Posted by Sexan
Regarding keys you can check my Area_51_input class script and its not returning ANY key not modifiers,nothing.
|
I tested VKeys_GetState and Mouse_GetState and both seemed to work fine on my OSX High Sierra x64. To my pleasant surprise, VKeys_GetState even returned modifier keys, so perhaps the bug that I mentioned before has been fixed without me noticing (or remembering?) it.
I took a look at the Area51 script, and I can confirm that it doesn't draw anything on my OSX system (when I hold Cmd+Shift+leftdrag), but unfortunately the script is far too long and complex for me to make head or tails of it. Do you perhaps have a minimal example of a script that doesn't get keyboard inputs and doesn't draw anything?
The script did crash a few times while I tested it, and I had to use the "Panic" script to remove the keyboard intercepts before I could type again. I would recommend that you use pcall throughout the script, so that if the script encounters an error, it can gracefully remove all intercepts and terminate, instead of just crashing.
|
|
|
01-12-2020, 12:20 PM
|
#897
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
Quote:
What do you mean by 'simple ID', how did you retrieve this ID?
|
With Edgemeal Get COntrol ID under mouse windows software :P
@Edgemeal
Now, just floating window, any type, everything not docked.
|
|
|
01-12-2020, 12:21 PM
|
#898
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
That barebone script draws nothing (you entered some API wrong btw). I done this exact thing in my script the code is above (but it would draw it when area is made) and nothing
Code:
bm = reaper.JS_LICE_CreateBitmap(true, 1, 1)
reaper.JS_LICE_Clear(bm, 0xFFFF0000)
tv = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8)
cOK = reaper.JS_Composite(tv, 100, 100, 100, 100, bm, 0, 0, 1, 1)
reaper.JS_Window_InvalidateRect(tv, 100, 100, 200, 200, false)
Atleast JS_LICE_COMPOSE does not exist on my end or anywhere in API
OSX High Siera
In the Main() loop there is check_keys() function that calls the Input script, if you press any key it should appear in de IDE as a table.
For drawing the function is in the class script() - Element:draw()
Thats the only call for compositing, anywhing you put there it will draw (if you actually draw first area). but there I set coordinates manually so it should draw things no matter what are Area coordinates. But since this above does not work do not know whats the issue.
Regarding keys - when you call track_keys() which is in the check_keys() function it should return a key you pressed as a table (which you can see in IDE since its global)
I will make a minimal script that does keys and drawing
Last edited by Sexan; 01-12-2020 at 12:34 PM.
|
|
|
01-12-2020, 01:00 PM
|
#899
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
@EdgemealNow, just floating window, any type, everything not docked.
|
If you want to exclude docked windows try JS_Window_FindTop and JS_Window_ArrayAllTop.
Last edited by Edgemeal; 01-12-2020 at 01:05 PM.
|
|
|
01-12-2020, 01:03 PM
|
#900
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
Code:
local Key_TB = {}
local startTime = reaper.time_precise()
local thisCycleTime
local Element = {}
function Element:new(ID, name, func)
local elm = {}
elm.ID = ID
elm.name = name
elm.press = function() local start = true
for i = 1, #elm.ID do
if reaper.JS_VKeys_GetState(startTime-2):byte(elm.ID[i]) == 0 then start = false break -- BREAK IF NOT BOTH KEYS ARE PRESSED
end
end
return start
end
elm.down_time = 0
elm.last_key_down = false
elm.last_key_hold = false
elm.last_key_up = true
elm.func = func
----------------------
setmetatable(elm, self)
self.__index = self
return elm
end
function extended(Child, Parent)
setmetatable(Child,{__index = Parent})
end
Key = {}
extended(Key, Element)
function Element:intercept(int)
for i = 1, #self.ID do
reaper.JS_VKeys_Intercept(self.ID[i], int)
end
end
function Element:onKeyDown(kd)
if kd and self.last_key_down == false then
self.down_time = os.clock()
self.last_key_down = true
self.last_key_up = false
key["DOWN"] = self
return self
end
end
function Element:OnKeyUp(kd)
if not kd and self.last_key_down == true and self.last_key_up == false then
self.last_key_up = true
self.last_key_down = false
self.last_key_hold = false
key["UP"] = self
end
end
function Element:onKeyHold()
self.last_key_hold = true
key["HOLD"] = self
return self
end
function Element:GetKey()
local KEY_DOWN = self.press()
if KEY_DOWN then
if self.last_key_up == true and self.last_key_down == false then
self:onKeyDown(KEY_DOWN)
elseif self.last_key_up == false and self.last_key_down == true then
if os.clock() - self.down_time > 0.15 then
self:onKeyHold()
end
end
elseif not KEY_DOWN and self.last_key_up == false and self.last_key_down == true then
self:OnKeyUp(KEY_DOWN)
end
end
function Track_keys(tbl)
local prevCycleTime = thisCycleTime or startTime
thisCycleTime = reaper.time_precise()
key = {}
for k,v in pairs(tbl) do v:GetKey() end
if key.DOWN or key.UP or key.HOLD then return key end
end
function main()
key = Track_keys(Key_TB)
reaper.defer(main)
end
for i = 1, 255 do
local func
local name = string.char(i)
if type(tonumber(name)) == "number" then
func = select_as
end
if name == "S" then
func = as_split
end
if i == 16 then
name = "Shift"
elseif i == 17 then
name = "Ctrl"
elseif i == 18 then
name = "Alt"
elseif i == 13 then
name = "Return"
elseif i == 8 then
name = "Backspace"
elseif i == 32 then
name = "Space"
elseif i == 20 then
name = "Caps-Lock"
elseif i == 27 then
name = "ESC"
func = remove
elseif i == 9 then
name = "TAB"
elseif i == 192 then
name = "~"
elseif i == 91 then
name = "Win"
elseif i == 45 then
name = "Insert"
elseif i == 46 then
name = "Del"
func = del
elseif i == 36 then
name = "Home"
elseif i == 35 then
name = "End"
elseif i == 33 then
name = "PG-Up"
elseif i == 34 then
name = "PG-Down"
end
Key_TB[#Key_TB + 1] = Key:new({i}, name, func)
end
main()
Code:
elm.press = function() local start = true
for i = 1, #elm.ID do
if reaper.JS_VKeys_GetState(startTime-2):byte(elm.ID[i]) == 0 then start = false break -- BREAK IF NOT BOTH KEYS ARE PRESSED
end
end
return start
end
This function is made so you can set combination of keys to act as one key/action. For example :
Code:
Key_TB[#Key_TB + 1] = Key:new({17, 67}, "COPY", copy_mode, true) -- COPY (TOGGLE)
I you make a key like this you are putting two keys together in this case its : 17 - CTRL and 67 - C
The function above waits for both keys to be true in order to return the value:
This is just whole input class together with key call from main script.
The exact same thing you need to see in AreaScript, keys show like this in IDE.
Again this works on windows but its not working on OSX
Regarding drawing its in Area_51_Class script and its only this function.
Code:
function Element:draw()
local cx,cy = reaper.JS_Window_ScreenToClient(track_window,self.x,self.y)
reaper.JS_Composite(track_window, cx, cy, self.w, self.h, self.bm, 0, 0, 1, 1)
refresh_reaper()
end
It reads the area tables and draws
Last edited by Sexan; 01-12-2020 at 01:16 PM.
|
|
|
01-12-2020, 01:04 PM
|
#901
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,875
|
@edgemeal
Thanks I'll experiment with that !
|
|
|
01-12-2020, 01:09 PM
|
#902
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
what is the funciton to get a windowHWND from simple ID
|
Control window handle? Shouldn't be any different then done in reaper, you got handle of window the control is on and pass the control ID to get the controls handle...
Code:
control_hwnd = reaper.JS_Window_FindChildByID(hwnd, ID)
Quote:
Originally Posted by X-Raym
With Edgemeal Get COntrol ID under mouse windows software :P
|
This basically does same thing,..
Code:
function Main()
-- Get Control ID under mouse (top-level window)
x,y = reaper.GetMousePosition()
hwnd = reaper.JS_Window_FromPoint(x,y)
hid = reaper.JS_Window_GetLongPtr(hwnd, "ID")
id = reaper.JS_Window_AddressFromHandle(hid)
reaper.ShowConsoleMsg(tostring(id) .. "\n")
reaper.defer(Main)
end
Main()
Last edited by Edgemeal; 01-12-2020 at 01:36 PM.
|
|
|
01-12-2020, 02:36 PM
|
#903
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Sexan
(you entered some API wrong btw). I done this exact thing in my script the code is above (but it would draw it when area is made) and nothing
|
Sorry about the typo. With the corrected "JS_Composite" function name, does it *not* draw a colored square on the trackview?
If you go to Preferences -> Advanced UI/system tweaks -> Display Updates, and set it to "Force Classic", does it make any difference?
|
|
|
01-12-2020, 02:49 PM
|
#904
|
Human being with feelings
Join Date: Jun 2009
Location: Croatia
Posts: 4,595
|
No its not drawing anything
Code:
bm = reaper.JS_LICE_CreateBitmap(true, 1, 1)
reaper.JS_LICE_Clear(bm, 0xFFFF0000)
tv = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 0x3E8) -- EVEN CHANGED THIS FROM 1000 SINCE ITS NOT CROSS-PLATFORM
cOK = reaper.JS_Composite(tv, 100, 100, 100, 100, bm, 0, 0, 1, 1)
reaper.JS_Window_InvalidateRect(tv, 100, 100, 200, 200, false) -- EVEN IF THIS IS COMMENTED OUT
|
|
|
01-12-2020, 03:10 PM
|
#905
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,054
|
Yep same here. Nothing is being drawn. OSX High Sierra here.
EDIT, sorry, was wrong. The gfx was hidden behind the action window:
|
|
|
01-14-2020, 01:38 PM
|
#906
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Sexan
No its not drawing anything
|
This is very strange, and I have no idea it isn't working on your system. The other macOS users that encountered problems with compositing see opaque graphics, while you see nothing. I wonder if your system truly fails to composite, or whether it makes the bitmap fully transparent -- analogous to how the bitmap becomes fully opaque on other users' Macs
Given that even the barebones script doesn't draw anything on your system, I suspect that the reason why the Area51 script isn't drawing anything either, is not a bug in the Area51 script.
Moreover, the fact that you can't get keyboard input, makes me wonder if something has gone awry with your installation or with the dylib.
Could you test keyboard input by running this script, and checking the value of "key" in the IDE while you pre?
Code:
function loop()
key = reaper.JS_VKeys_GetState(t or -1):find("\1") or key
t = reaper.time_precise()
reaper.defer(loop)
end
loop()
You can try checking the return value of JS_Composite for errors, and well as the list of linked bitmaps, using JS_Composite_ListBitmaps, to see if the bitmap was truly linked.
|
|
|
01-23-2020, 07:10 AM
|
#907
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
How could I get the list of items in a combox?
Code:
wnd = reaper.JS_Window_Find( "Theme element finder", false )
combo = reaper.JS_Window_FindChildByID( wnd, 1001 )
count = reaper.JS_WindowMessage_Send( combo, "CB_GETCOUNT", 0, 0, 0, 0 )
I guess by using reaper.JS_WindowMessage_Send "CB_GETLBTEXT" but how exactly?
Last edited by amagalma; 01-23-2020 at 07:29 AM.
|
|
|
01-23-2020, 12:31 PM
|
#908
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by amagalma
How could I get the list of items in a combox?
|
Not sure if the API has been updated since I tried that ( post 249), but I ended up doing it like,..
Code:
itemCount = reaper.JS_WindowMessage_Send(combo, "CB_GETCOUNT", 0,0,0,0 )
cur_index = reaper.JS_WindowMessage_Send(combo, "CB_GETCURSEL", 0,0,0,0) -- save current index
for i = 0, itemCount-1 do
reaper.JS_WindowMessage_Send(combo, "CB_SETCURSEL", i, 0,0,0)
t[#t+1] = reaper.JS_Window_GetTitle(combo,"") -- save item text to table
end
reaper.JS_WindowMessage_Send(combo, "CB_SETCURSEL", cur_index, 0,0,0) -- restore index
Odd thing is, I can't get the handle to that ComboBox or any of the children on that window, I got combobox handle from SPY++ to test that code.
Last edited by Edgemeal; 01-23-2020 at 12:37 PM.
|
|
|
01-23-2020, 12:52 PM
|
#909
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
This works great! Thank you very much Edgemeal!
|
|
|
01-24-2020, 11:59 AM
|
#910
|
Human being with feelings
Join Date: Aug 2012
Location: Finland
Posts: 2,668
|
Is there any way to set the minimum size of a window?
It can get quite tiny (window style is "WS_BORDER"):
|
|
|
01-24-2020, 01:08 PM
|
#911
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by Edgemeal
Not sure if the API has been updated since I tried that ( post 249), but I ended up doing it like,..
Code:
itemCount = reaper.JS_WindowMessage_Send(combo, "CB_GETCOUNT", 0,0,0,0 )
cur_index = reaper.JS_WindowMessage_Send(combo, "CB_GETCURSEL", 0,0,0,0) -- save current index
for i = 0, itemCount-1 do
reaper.JS_WindowMessage_Send(combo, "CB_SETCURSEL", i, 0,0,0)
t[#t+1] = reaper.JS_Window_GetTitle(combo,"") -- save item text to table
end
reaper.JS_WindowMessage_Send(combo, "CB_SETCURSEL", cur_index, 0,0,0) -- restore index
Odd thing is, I can't get the handle to that ComboBox or any of the children on that window, I got combobox handle from SPY++ to test that code.
|
I tried to do the same with a ListBox but it didn't work. Any idea why? Is there any other way?
Code:
t = {}
wnd = reaper.JS_Window_Find( "Theme development/tweaker", true )
listbox = reaper.JS_Window_FindChildByID( wnd, 1209 )
itemCount = reaper.JS_WindowMessage_Send(listbox, "LB_GETCOUNT", 0,0,0,0 )
cur_index = reaper.JS_WindowMessage_Send(listbox, "LB_GETCURSEL", 0,0,0,0) -- save current index
for i = 0, itemCount-1 do
reaper.JS_WindowMessage_Send(listbox, "LB_SETCURSEL", i, 0,0,0)
t[#t+1] = reaper.JS_Window_GetTitle(listbox,"") -- save item text to table
end
reaper.JS_WindowMessage_Send(listbox, "LB_SETCURSEL", cur_index, 0,0,0) -- restore index
|
|
|
01-24-2020, 09:09 PM
|
#912
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by amagalma
I tried to do the same with a ListBox but it didn't work. Any idea why? Is there any other way?
|
I'm pretty sure only way to read listbox item text is to use the LB_ messages and I don't think this extension has them defined so you'll have to add them , most of the LB_ msg I tried seem to work except LB_GETTEXTLEN, it returns a much higher value then the actual text lengths, so I guess as long as its not smaller it should be OK. , this seems to be working, but I'm just VB coder and normally don't use pointers, so assume I'm using JS_Mem_Alloc correctly?
Tested on listbox in Actions un-docked window,..
Code:
LB_GETTEXT = '0x189' -- API (as of v0.998) doesn't have LB_* messages defined.
LB_GETCOUNT = '0x18B'
LB_GETTEXTLEN = '0x18A'
actions = reaper.JS_Window_FindTop('Actions', true)
listbox = reaper.JS_Window_FindChildByID(actions, 0x531) -- assigned shortcuts listbox in Actions window.
itemCount = reaper.JS_WindowMessage_Send(listbox, LB_GETCOUNT, 0,0,0,0)
for i = 0, itemCount-1 do
bufSize = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXTLEN, i,0,0,0)
m = reaper.JS_Mem_Alloc(bufSize)
txt_len = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXT, i, 0, reaper.JS_Window_AddressFromHandle(m),0)
retval, item_txt = reaper.JS_String(m, 0, txt_len)
reaper.JS_Mem_Free(m)
reaper.ShowConsoleMsg(item_txt..'\n')
end
From MSDN, LB_GETTEXTLEN message
Quote:
Under certain conditions, the return value is larger than the actual length of the text. This occurs with certain mixtures of ANSI and Unicode, and is due to the operating system allowing for the possible existence of double-byte character set (DBCS) characters within the text. The return value, however, will always be at least as large as the actual length of the text; you can thus always use it to guide buffer allocation. This behavior can occur when an application uses both ANSI functions and common dialogs, which use Unicode.
To obtain the exact length of the text, use the WM_GETTEXT, LB_GETTEXT, or CB_GETLBTEXT messages, or the GetWindowText function.
|
So looks like were OK!
Last edited by Edgemeal; 01-25-2020 at 01:49 AM.
Reason: Tweaked for 100th time! :-)
|
|
|
01-25-2020, 01:15 AM
|
#913
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by amagalma
This works great! Thank you very much Edgemeal!
|
Another possible way, this doesn't change the combo index like the other code. Tested on 'presets' combobox of a floating ReaEQ FX window...
Code:
floatVST = reaper.JS_Window_FindTop('VST: ReaEQ (Cockos)', false) -- floatng FX window
if not floatVST then return end
container = reaper.JS_Window_FindChildByID(floatVST, 0) -- combobox is inside child window
combobox = reaper.JS_Window_FindChildByID(container, 0x3E8) -- FX 'Presets' combobox
itemCount = reaper.JS_WindowMessage_Send(combobox, "CB_GETCOUNT", 0,0,0,0)
for i = 0, itemCount-1 do
bufSize = reaper.JS_WindowMessage_Send(combobox, "CB_GETLBTEXTLEN", i ,0,0,0)
m = reaper.JS_Mem_Alloc(bufSize)
txt_len = reaper.JS_WindowMessage_Send(combobox, "CB_GETLBTEXT", i, 0, reaper.JS_Window_AddressFromHandle(m) ,0)
retval, item_txt = reaper.JS_String(m, 0, txt_len)
reaper.JS_Mem_Free(m)
reaper.ShowConsoleMsg(item_txt..'\n')
end
|
|
|
01-25-2020, 02:50 AM
|
#914
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 864
|
Quick question regarding my usage of the following code:
Code:
if reaper.JS_VKeys_GetState( 0 ):byte(hotkey[a].key) ~= 0 then
It works just fine to intercept key-presses from almost every window in REAPER, except the mixer.
Is there a way to combat this?
|
|
|
01-25-2020, 03:16 AM
|
#915
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by Edgemeal
I'm pretty sure only way to read listbox item text is to use the LB_ messages and I don't think this extension has them defined so you'll have to add them , most of the LB_ msg I tried seem to work except LB_GETTEXTLEN, it returns a much higher value then the actual text lengths, so I guess as long as its not smaller it should be OK. , this seems to be working, but I'm just VB coder and normally don't use pointers, so assume I'm using JS_Mem_Alloc correctly?
Tested on listbox in Actions un-docked window,..
Code:
LB_GETTEXT = '0x189' -- API (as of v0.998) doesn't have LB_* messages defined.
LB_GETCOUNT = '0x18B'
LB_GETTEXTLEN = '0x18A'
actions = reaper.JS_Window_FindTop('Actions', true)
listbox = reaper.JS_Window_FindChildByID(actions, 0x531) -- assigned shortcuts listbox in Actions window.
itemCount = reaper.JS_WindowMessage_Send(listbox, LB_GETCOUNT, 0,0,0,0)
for i = 0, itemCount-1 do
bufSize = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXTLEN, i,0,0,0)
m = reaper.JS_Mem_Alloc(bufSize)
txt_len = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXT, i, 0, reaper.JS_Window_AddressFromHandle(m),0)
retval, item_txt = reaper.JS_String(m, 0, txt_len)
reaper.JS_Mem_Free(m)
reaper.ShowConsoleMsg(item_txt..'\n')
end
From MSDN, LB_GETTEXTLEN message
So looks like were OK!
|
Hmm.. Doesn't seem to work with the ListBox of the Theme development/tweaker.. :/
Code:
local LB_GETTEXT, LB_GETCOUNT,LB_GETTEXTLEN = '0x189', '0x18B', '0x18A'
t = {}
local wnd = reaper.JS_Window_Find( "Theme development/tweaker", true )
local listbox = reaper.JS_Window_FindChildByID( wnd, 1209 )
itemCount = reaper.JS_WindowMessage_Send(listbox, LB_GETCOUNT, 0,0,0,0)
for i = 0, itemCount-1 do
local bufSize = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXTLEN, i,0,0,0)
local m = reaper.JS_Mem_Alloc(bufSize)
txt_len = reaper.JS_WindowMessage_Send(listbox, LB_GETTEXT, i, 0, reaper.JS_Window_AddressFromHandle(m),0)
retval, item_txt = reaper.JS_String(m, 0, txt_len)
reaper.JS_Mem_Free(m)
t[#t+1] = item_txt
reaper.ShowConsoleMsg(item_txt..'\n')
end
It returns 'chinese'..
|
|
|
01-25-2020, 03:33 AM
|
#916
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,913
|
Quote:
Originally Posted by amagalma
Hmm.. Doesn't seem to work with the ListBox of the Theme development/tweaker.. :/
It returns 'chinese'..
|
Sorry no clue, don't have 'Theme development/tweaker' window either but take your word for it. Maybe one of the guru's could clue us in on whats going on.
Was testing on Win10(US English), REAPER v6.03/x64.
|
|
|
01-25-2020, 04:00 AM
|
#917
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Thanks for the help Edgemeal!
That is the window that tweaks the colors of a theme.
Theme development: Show theme tweak/configuration window, action 41930
Win10(US English), REAPER v6.03/x64 here too.
|
|
|
01-25-2020, 04:31 AM
|
#918
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Quote:
Originally Posted by amagalma
Thanks for the help Edgemeal!
That is the window that tweaks the colors of a theme.
Theme development: Show theme tweak/configuration window, action 41930
Win10(US English), REAPER v6.03/x64 here too.
|
Edit.. Actually what is returned is not 'chinese'.. it's all the the characters of the keyboard..
Code:
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™
|
|
|
01-25-2020, 05:05 AM
|
#919
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Dafarkias
Quick question regarding my usage of the following code:
Code:
if reaper.JS_VKeys_GetState( 0 ):byte(hotkey[a].key) ~= 0 then
It works just fine to intercept key-presses from almost every window in REAPER, except the mixer.
Is there a way to combat this?
|
Could you elaborate? (Do you mean that when the mixer is in the foreground, GetState does not detect any key strokes?)
|
|
|
01-25-2020, 05:07 AM
|
#920
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by spk77
Is there any way to set the minimum size of a window?
It can get quite tiny (window style is "WS_BORDER"):
|
You can perhaps check the window size in every defer cycle, and then resize whenever the size is too small.
Alternatively, use a window style that does not allow resizing.
|
|
|
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:17 AM.
|