|
|
|
07-01-2019, 04:11 AM
|
#601
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 869
|
Quote:
Originally Posted by juliansader
This is actually already possible, using the existing API. For example, to get item position, get the track y position as in this code above, and then get the item position inside the track using GetMediaItemInfo_Value with I_LASTY, I_LASTH, F_FREEMODE_Y and F_FREEMODE_H.
|
That is very cool, wow, thank you.
I assume in order to get the edit-cursor's 'x' position one would simply get the x/y position of the arrange view window, and then use arrange view start/end time positions to calculate the edit-cursor's 'x' position?
Sorry to bother you with such a simplistic question, I've just wanted to add features to several scripts that use screen coordinate capabilities, and I think that being able to screen-coordinate the edit-cursor and item positions would really help me in this.
[ADD., 7/1/19]
This seems to work okay:
Code:
function get_EC_x(EC_time_pos)
local x, y = reaper.JS_Window_ClientToScreen( reaper.JS_Window_Find( "trackview", 1 ), 0, 0 )
local retval, w, h = reaper.JS_Window_GetClientSize( reaper.JS_Window_Find( "trackview", 1 ) )
local AV_a, AV_z = reaper.GetSet_ArrangeView2( 0, 0, 0, 0 )
local AV_w = AV_z - AV_a
local AV_w_EC_pos = EC_time_pos - AV_a
return (math.floor(w/(AV_w/AV_w_EC_pos)) + x)
end
Last edited by Dafarkias; 07-01-2019 at 04:56 AM.
|
|
|
07-01-2019, 09:12 AM
|
#602
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
Quote:
Originally Posted by juliansader
This is actually already possible, using the existing API. For example, to get item position, get the track y position as in this code above, and then get the item position inside the track using GetMediaItemInfo_Value with I_LASTY, I_LASTH, F_FREEMODE_Y and F_FREEMODE_H.
|
Oooh...that's nice! Will add that to my Ultraschall-API!
@Dafarkias
Could this help you as well?
https://mespotin.uber.space/Ultrasch...tItemFromPoint
|
|
|
07-01-2019, 12:42 PM
|
#603
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by Dafarkias
I assume in order to get the edit-cursor's 'x' position one would simply get the x/y position of the arrange view window, and then use arrange view start/end time positions to calculate the edit-cursor's 'x' position?
|
Yep, the code that you posted above should work. Just look out for divide-by-zero errors, and Window_FindChildByID(mainHWND, 1000) is more cross-platform reliable than Window_Find("trackview").
For interest's sake, here is some code that we used in another thread to do the same calculations as you do above:
Code:
trackview = reaper.JS_Window_FindChildByID(reaper.GetMainHwnd(), 1000)
rectOK, leftmostArrangeY = reaper.JS_Window_GetRect(trackview)
infoOK, scrollPos, pageSize, min, max, trackPos = reaper.JS_Window_GetScrollInfo(trackview, "HORZ")
cursorTimeFromStart = reaper.GetCursorPositionEx(0) -- Always counted from start of project, ignores "Project start time"
zoom = reaper.GetHZoomLevel() -- returns pixels/second
cursorPixelsFromStart = cursorTimeFromStart*zoom
cursorY = leftmostArrangeY + (cursorPixelsFromStart - scrollPos)
|
|
|
07-01-2019, 02:40 PM
|
#604
|
Human being with feelings
Join Date: Feb 2019
Location: Southern Vermont
Posts: 869
|
Quote:
Originally Posted by mespotine
|
Always been a fan of your API... I think that's kinda the opposite of what I'm looking for in this regard though.
I'd like a function that gets a specific item's x/y coordinates, whereas it seems the function you referenced gets the item of a specific x/y coordinate.
Quote:
Originally Posted by juliansader
Yep, the code that you posted above should work. Just look out for divide-by-zero errors, and Window_FindChildByID(mainHWND, 1000) is more cross-platform reliable than Window_Find("trackview").
|
Thanks for the information. I'm interested about what you say regarding divide-by-zero errors... Even when I input EC_time_pos and AV_a both as the value '0' and effectively divide AV_w by '0' I receive no error. Is that commonplace?
Last edited by Dafarkias; 07-01-2019 at 02:46 PM.
|
|
|
07-07-2019, 09:52 AM
|
#605
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
How can I access dropdown/context-menüs programmatically?
I would love to access the following menupoint:
|
|
|
07-07-2019, 10:13 AM
|
#606
|
Human being with feelings
Join Date: Feb 2017
Posts: 4,952
|
Anyone? i am trying to use this:
reaper.JS_Window_SetOpacity(w, "ALPHA", 0.5 )
but nothing happens! does this work on OSX (10.9.5) or am i doing something wrong?
docs says:
Code:
boolean reaper.JS_Window_SetOpacity(identifier windowHWND, string mode, number value)
mode: either "ALPHA" or "COLOR".
value: If ALPHA, the specified value may range from zero to one, and will apply to the entire window.
If COLOR, value specifies a 0xRRGGBB color, and all pixels in this color will be made transparent. (All mouse clicks over transparent pixels will pass through, too).
|
|
|
07-07-2019, 10:30 AM
|
#607
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,030
|
Quote:
Originally Posted by mespotine
How can I access dropdown/context-menüs programmatically?
|
I hope I'm wrong but doesn't seem possible, as soon as a context menu is shown all lua scripts are paused until the menu is closed, I'm guessing we need a defer option that runs on it own thread?
EDIT, not a context menu, maybe a regular menu?
Last edited by Edgemeal; 07-07-2019 at 11:24 AM.
|
|
|
07-07-2019, 10:36 AM
|
#608
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
Ok. Maybe I can add that stuff somehow into my API. Thanks
|
|
|
07-07-2019, 11:26 AM
|
#609
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
I don't know. But I think, it's a context menu. But I'm not deep enough in such things to know, what kind of menus exist.
|
|
|
07-07-2019, 12:39 PM
|
#610
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,030
|
RE-POST
Quote:
Originally Posted by mespotine
I don't know. But I think, it's a context menu. But I'm not deep enough in such things to know, what kind of menus exist.
|
Your right, it is a menu, it has a classname #32768, and to my surprise a defer-loop script didn't stop when it was shown, so maybe there is hope, you need to figure out where to send it a click message thouguh, not sdure how you do that without help of the GetMenuItemRect Win32 API.
Testing, how to get handle of a Menu (Windows classname #32768) and click top menu item.
Code:
function msg(str)
reaper.ShowConsoleMsg(tostring(str) .. '\n')
end
function Post_LMouseDownUp(hwnd, x, y)
reaper.JS_WindowMessage_Post(hwnd, "WM_LBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Post(hwnd, "WM_LBUTTONUP", 0, 0, x, y)
end
function FindMenu()
local arr = reaper.new_array({}, 255)
local ret = reaper.JS_Window_ArrayAllTop(arr)
if ret < 1 then return end
local childs = arr.table()
for j = 1, #childs do
local hwnd = reaper.JS_Window_HandleFromAddress(childs[j])
if reaper.JS_Window_GetClassName(hwnd) == "#32768" then
return hwnd
end
end
end
local function main()
menuWindow = FindMenu()
if menuWindow ~= nil then -- Menu window found.
--< Add code to click inside window @ specific point to select a menu item :) >--
retval, left, top, right, bottom = reaper.JS_Window_GetRect(menuWindow)
-- Post_LMouseDownUp(menuWindow, left+4, top+4) -- <<<< Clicks top menu item ???
msg(menuWindow)
return -- exit
end
reaper.defer(main)
end
reaper.defer(main)
Last edited by Edgemeal; 07-07-2019 at 01:11 PM.
Reason: comment out click code, could be dangerous :-)
|
|
|
07-07-2019, 02:52 PM
|
#611
|
Human being with feelings
Join Date: Jan 2013
Posts: 1,177
|
Hi JulianSader.
I'm trying to use reascript to change Project Tabs' order. See in this LICECap:
There's no way for me to change the order of Song 14, Song 15, Song 16, etc...
Mespotine told me there might be a way using your extension's childID?
I'm not too experienced yet in all of this but maybe you could enlight me if it is feasible to reorder tabs with reascript using your stuff?
|
|
|
07-07-2019, 03:16 PM
|
#612
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
To add to lexaproductions, I think Click+Mousedragging-stuff could work for that, but I don't know, if such windows-messages exist in swell to do that...
And I don't know, if there's a way to find out, where which tab is...
|
|
|
07-12-2019, 09:14 AM
|
#613
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
Maybe useful for finding the right localized-texts:
I made a LangPack-file, which shows to the left of the text the section, in which you can find it.
This is probably useful, when wanting to get the right hwnd-text, as some texts in the LangPacks are duplicated.
It looks like this:
You can get it here: https://raw.githubusercontent.com/Ul...ReaperLangPack
Just use it, as any other language-pack-file.
|
|
|
07-13-2019, 03:46 PM
|
#614
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by lexaproductions
Mespotine told me there might be a way using your extension's childID?
I'm not too experienced yet in all of this but maybe you could enlight me if it is feasible to reorder tabs with reascript using your stuff?
|
Unfortunately, I am not aware of any way to do this. (Someone else might know, though -- we can even ask the devs directly.)
|
|
|
07-25-2019, 02:18 AM
|
#615
|
Human being with feelings
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 339
|
First of all I want to thank Julian for creating this amazing extension.
Second, is there a way to use JS_GDI_Line function to draw lines around selected items, like in a picture below?
Can I detect position of item edges at all?
|
|
|
07-25-2019, 06:36 AM
|
#617
|
Human being with feelings
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 339
|
Quote:
Originally Posted by nofish
|
I was actually thinking of position of items in terms of x and y coordinates in REAPER window.
|
|
|
07-25-2019, 01:13 PM
|
#618
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by nikolalkc
I was actually thinking of position of items in terms of x and y coordinates in REAPER window.
|
Sure, it's easy to do: check out post #604 and the next few posts on this page above.
|
|
|
07-26-2019, 08:37 AM
|
#619
|
Human being with feelings
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 339
|
Quote:
Originally Posted by juliansader
Sure, it's easy to do: check out post #604 and the next few posts on this page above.
|
Thanks Julian, but how do I change the color of the lines?
I'm completely new to GDI, i still don't understand the concept completely.
|
|
|
07-27-2019, 03:55 AM
|
#620
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by nikolalkc
Thanks Julian, but how do I change the color of the lines?
I'm completely new to GDI, i still don't understand the concept completely.
|
The color of the line is determined by the "pen" that is active in the window's "device context (dc)". Use JS_GDI_CreatePen to create a pen and then JS_GDI_SelectObject to activate it.
The online documentation for the corresponding C++ functions is probably the best place to learn how to use the API functions. For example, Window messages and Drawing with GDI.
Cockos's own LICE and swell C++ functions are not so extensively documented, and you will unfortunately have to browse through the "ReaScript, JSFX, REAPER Plug-in Extensions, Developer" subforum as well as the "WDL users" subforum. We are all figuring out together how REAPER works "under the hood" as we go along.
As alternative to GDI, use can use the JS_Composite functions, together with LICE. For the compositing functions, the best (and only) source of information is this and other discussion threads.
You can also get a better idea of what's going on under the hood by checking the source code on github.
|
|
|
07-27-2019, 05:30 AM
|
#621
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
Quote:
Cockos's own LICE and swell C++ functions are not so extensively documented, and you will unfortunately have to browse through the "ReaScript, JSFX, REAPER Plug-in Extensions, Developer" subforum as well as the "WDL users" subforum. We are all figuring out together how REAPER works "under the hood" as we go along.
|
If you guys find some threads with information about that, please drop a link into my Reaper-Internals-thread so I can use that as a base, when I document WDL, LICE and Swell at some point.
https://forum.cockos.com/showthread.php?t=207635
|
|
|
07-27-2019, 10:05 AM
|
#622
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
Is there a way to clear a text / search field without the SetTitle method?
reaper.JS_Window_SetTitle(searchbox, "") does not work here, because the text is stored as caption and not as title.
|
|
|
07-27-2019, 11:26 AM
|
#623
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,707
|
You can try, if the hwnd, whose title you can't change, has a childhwnd.
If yes, this probably holds the text as title...
|
|
|
07-27-2019, 11:30 AM
|
#624
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
Nope, unfortunately not. I solved it by using a double mouse click and a press of the delete key. Not very elegant, but works.
|
|
|
07-28-2019, 02:23 PM
|
#625
|
Human being with feelings
Join Date: Dec 2017
Posts: 321
|
Friends! Is there any way to get drag and drop Fx message from FX Browser to specific window (gfx window) with JS_API?)
|
|
|
07-29-2019, 01:51 PM
|
#626
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
Quote:
Originally Posted by _Stevie_
Is there a way to clear a text / search field without the SetTitle method?
reaper.JS_Window_SetTitle(searchbox, "") does not work here, because the text is stored as caption and not as title.
|
Which searchbox are you trying to edit? I tested a few, such as the ones in FX browser and Media Explorer, and SetTitle seems to work fine.
However, I read in Microsoft's documentation:
Quote:
Changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.
...
To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText.
|
WM_SETTEXT is unfortunately not implemented in swell for macOS and Linux. On Windows, you can use WM_SETTEXT's code, 0x000C. I quickly tested this approach, and it also seems to work for the above-mentioned searchboxes. Sending a string via WindowMessage_Send is a bit complicated, though, since you need to convert the Lua string into a 0-terminated string in memory first:
Code:
m = reaper.JS_Mem_Alloc(10)
reaper.JS_Mem_FromString(m, 0, "testing\0", 8)
reaper.JS_WindowMessage_Send(searchbox, "0x000C", 0, 0, reaper.JS_Window_AddressFromHandle(m), 0)
reaper.JS_Mem_Free(m)
Last edited by juliansader; 07-29-2019 at 01:58 PM.
|
|
|
07-29-2019, 02:15 PM
|
#627
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
Hey Julian!
I'm trying to change the search box from foobar2000:
https://i.imgur.com/WM3ctNS.gif
Ahh, I did not try WM_SETTEXT as hex code. Let me check if that works...
|
|
|
07-29-2019, 02:21 PM
|
#628
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
Wohoo, that worked, thanks Julian!
But it worked without the Mem_Free function:
Code:
reaper.JS_WindowMessage_Send(searchbox, "0x000C", 0, 0, 0, 0)
Is there a downside not using it?
|
|
|
07-29-2019, 03:03 PM
|
#629
|
Human being with feelings
Join Date: Jul 2009
Posts: 3,714
|
I don't know? I don't see anything in the WM_SETTEXT documentation about null pointers, so I'm only guessing: Perhaps some programs may interpret a null pointer as "don't change the text", rather than "clear the text"?
|
|
|
07-29-2019, 03:05 PM
|
#630
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
Okay that could be. In any case: it works! Thanks man
|
|
|
07-30-2019, 08:44 AM
|
#631
|
Human being with feelings
Join Date: Aug 2011
Posts: 529
|
Wait..so you can actually jump into other windows and inject text or mouse clicks OUTSIDE Reaper by using some of the commands on the extension? :O
Would you guys have any code example?
|
|
|
07-30-2019, 08:55 AM
|
#632
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by reapero
Wait..so you can actually jump into other windows and inject text or mouse clicks OUTSIDE Reaper
|
That's a standard feature of the Windows messaging system. You just need to get the correct target window handle (HWND) to send the message to. I don't think it's going to work on OS-X and Linux.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
07-30-2019, 09:03 AM
|
#633
|
Human being with feelings
Join Date: Aug 2011
Posts: 529
|
Yeah, windows only would be enough.
I´ve searched in the API for something like GetAllHwnd, to get all the handles from all the different opened applications (hoping to be able to filter afterwards and target the one i need) but i couldnt see nothing like this.
Any hint? Thx!
EDIT: Btw Xenakios, found out the other day that you did Hourglass. Congrats man! Thanks a lot for that. Cant wait to test the VST plugin
|
|
|
07-30-2019, 09:14 AM
|
#634
|
Human being with feelings
Join Date: Oct 2017
Location: Black Forest
Posts: 5,130
|
reapero asked me, if I could post some examples in regard to my foobar2000 scripts I'm using. I guess this can also be of help for others in this thread.
Basically, I use foobar2000 as a database for my written cues and Lemur to
trigger buttons with search commands that will be written into foobar's quick search.
In the past, I used AHK for that (some pretty convoluted method: Lemur sending MIDI -> Loopmidi port on Windows -> and AHK would listen on that Loopmidi port).
To make a long story short. I moved over to LBX Stripper and assigned LUA scripts to buttons. That way I can do a search from within Reaper without all the MIDI connecting.
This would be a "type text in the quick search box"- script (I used a function that Edgemeal posted in this thread "JS_Send_Char"):
Code:
function foobarDB(keyword)
-- insert keyword in foobar
function JS_Send_Char(hwnd, str)
for n = 1, string.len(str) do
char = string.sub(str,n,n)
ret = reaper.JS_WindowMessage_Send(hwnd, "WM_CHAR", string.byte(char), 0, 0, 0)
if ret ~= 1 then break end
end
end
-- find fooabr200 window
function GetFoobarSearchfield()
foobar2000 = reaper.JS_Window_Find("foobar2000", false) -- find foobar2000 window
quicksearch_toolbar = reaper.JS_Window_FindChild(foobar2000, "Quick Search Toolbar", true) -- look for Quick Search Toolbar child window
search = reaper.JS_Window_FindChild(quicksearch_toolbar, "", true) -- find child window without title
search_field = reaper.JS_Window_FindChildByID(search, 1001)
reaper.BR_Win32_SetWindowPos(foobar2000,"HWND_TOPMOST" , 0, 0, 0, 0, 19) -- 19 = SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE.
reaper.JS_Window_SetForeground(search_field) -- focus search field
return search_field, foobar2000
end
local hwnd, foobar2000 = GetFoobarSearchfield()
JS_Send_Char(hwnd, keyword)
end
Last edited by _Stevie_; 07-30-2019 at 09:23 AM.
|
|
|
07-30-2019, 09:21 AM
|
#635
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,030
|
Quote:
Originally Posted by reapero
Would you guys have any code example?
|
If I'm using JS_Mem correctly this should replace the selected text in Windows Notepad (that has titlebar text of "Untitled - Notepad") with "Hello World!",...
Code:
EM_REPLACESEL = '0x00C2'
text = "Hello World!"
text_len = string.len(text) + 1
hwnd = reaper.JS_Window_FindTop('Untitled - Notepad', true) -- get notepad
if hwnd then
edit = reaper.JS_Window_FindChildByID(hwnd, 15) -- get 'edit'
if edit then
m = reaper.JS_Mem_Alloc(text_len)
reaper.JS_Mem_FromString(m, 0, text..'\0', text_len)
reaper.JS_WindowMessage_Send(edit, EM_REPLACESEL, 0, 0, reaper.JS_Window_AddressFromHandle(m), 0)
reaper.JS_Mem_Free(m)
end
end
|
|
|
07-30-2019, 09:45 AM
|
#636
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,030
|
Quote:
Originally Posted by reapero
I´ve searched in the API for something like GetAllHwnd, to get all the handles from all the different opened applications (hoping to be able to filter afterwards and target the one i need) but i couldnt see nothing like this.
|
reaper.JS_Window_ArrayFind
reaper.JS_Window_ArrayAllTop
|
|
|
07-30-2019, 09:46 AM
|
#637
|
Human being with feelings
Join Date: Aug 2011
Posts: 529
|
Thanks guys! You are the best!
I see that its easier than i thought though. Hwnds can be found simply by the title bar´s name, which is something i wasnt counting on.
Thx again
EDIT: Ahh shit. The window i wanna target has appended the version of the program, and i update this every couple weeks. So i probably need to use the global commands Edgemeal was refering to.
|
|
|
07-30-2019, 11:37 AM
|
#638
|
Human being with feelings
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 4,030
|
Quote:
Originally Posted by reapero
The window i wanna target has appended the version of the program, and i update this every couple weeks. So i probably need to use the global commands Edgemeal was refering to.
|
If the app title text is unique enough you can just enter partial title, and set the exact param to false, e.g.,
Code:
hwnd = reaper.JS_Window_FindTop('REAPER v5.', false)
|
|
|
07-31-2019, 01:32 AM
|
#639
|
Human being with feelings
Join Date: Aug 2011
Posts: 529
|
Thanks Edgemeal!
I could get the hwnd i wanted but then, unlike in Stevie´s gif with Foobar2000, i cant dive inside to look for the search field.
I think this is related with the app being done in Qt: Spyxx only detects one window (class Qt5QWindowIcon) and nothing else inside it. In fact in the windows tab of this window´s properties Spyxx displays "First Child Window Handle(None)"
Seems like an impossible task for the win32 api then?
|
|
|
07-31-2019, 05:10 AM
|
#640
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by reapero
I think this is related with the app being done in Qt
...
Seems like an impossible task for the win32 api then?
|
Yes, unfortunately not possible if the application is written with something like Qt or JUCE.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
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:39 PM.
|