Old 06-21-2019, 01:24 AM   #601
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by _Stevie_ View Post
Nope, the Reaper Mixer window does, though.
Quote:
Originally Posted by tack View Post
I'm in the same boat as Stephan, no pin on that window either.
Ah, so SWS is in the same boat. This is good news in a way, since it means the problem doesn't lie with ReaScriptAPI.


Quote:
Originally Posted by tack View Post
Do you reckon it's an SWS issue?
No, ReaScriptAPI adds the pin directly, without requiring SWS, so it seems to be a REAPER or Windows issue. Both extensions use the same trick to add the pin, namely an undocumented, unofficial feature of REAPER.

I will submit a bug report thread, but since the feature is not officially supported, it may not be high on the devs' priority list.

Are either of you perhaps using an unusual Windows 10 theme, or anything else that might affect window frames, such as WindowBlinds?
juliansader is offline   Reply With Quote
Old 06-21-2019, 02:58 AM   #602
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

Using the default Windows 10 theme. No changes or theme hacks.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 06-29-2019, 09:44 AM   #603
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 120
Default

Hi JS!

Your extension is a thing of beauty, a great contribution to the Reaper community.

Wanna throw an idea past you for plausibility and whether or not you think it would be of value:

I know you have functions that get the mouse cursor's time-position from the arrange, would it be possible to have a function where you could get an item's x/y-coordinates at its upper-left point?

Similarly, I could also see potential value in a function that could get the x coordinate of the project edit cursor.

High regards,

Dafark
Dafarkias is online now   Reply With Quote
Old 06-30-2019, 04:24 PM   #604
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by Dafarkias View Post
I know you have functions that get the mouse cursor's time-position from the arrange, would it be possible to have a function where you could get an item's x/y-coordinates at its upper-left point?

Similarly, I could also see potential value in a function that could get the x coordinate of the project edit cursor.
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.
juliansader is offline   Reply With Quote
Old 07-01-2019, 04:11 AM   #605
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 120
Default

Quote:
Originally Posted by juliansader View Post
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.
Dafarkias is online now   Reply With Quote
Old 07-01-2019, 09:12 AM   #606
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

Quote:
Originally Posted by juliansader View Post
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
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-01-2019, 12:42 PM   #607
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by Dafarkias View Post
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)
juliansader is offline   Reply With Quote
Old 07-01-2019, 02:40 PM   #608
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 120
Default

Quote:
Originally Posted by mespotine View Post
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 View Post
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.
Dafarkias is online now   Reply With Quote
Old 07-07-2019, 09:52 AM   #609
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

How can I access dropdown/context-menüs programmatically?

I would love to access the following menupoint:

__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-07-2019, 10:13 AM   #610
deeb
Human being with feelings
 
deeb's Avatar
 
Join Date: Feb 2017
Posts: 2,253
Default

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).
deeb is offline   Reply With Quote
Old 07-07-2019, 10:30 AM   #611
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,260
Default

Quote:
Originally Posted by mespotine View Post
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.
Edgemeal is offline   Reply With Quote
Old 07-07-2019, 10:36 AM   #612
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

Ok. Maybe I can add that stuff somehow into my API. Thanks
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-07-2019, 11:26 AM   #613
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

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.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-07-2019, 12:39 PM   #614
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,260
Default RE-POST

Quote:
Originally Posted by mespotine View Post
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 :-)
Edgemeal is offline   Reply With Quote
Old 07-07-2019, 02:52 PM   #615
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 381
Default

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?
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 07-07-2019, 03:16 PM   #616
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

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...
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-12-2019, 09:14 AM   #617
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

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.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-13-2019, 03:46 PM   #618
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by lexaproductions View Post
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.)
juliansader is offline   Reply With Quote
Old 07-25-2019, 02:18 AM   #619
nikolalkc
Human being with feelings
 
nikolalkc's Avatar
 
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 153
Default

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?
Attached Images
File Type: jpg lines.jpg (37.6 KB, 165 views)
nikolalkc is offline   Reply With Quote
Old 07-25-2019, 06:10 AM   #620
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,917
Default

Quote:
Originally Posted by nikolalkc View Post
Can I detect position of item edges at all?
Sure.
https://www.extremraym.com/cloud/rea...ItemInfo_Value
nofish is offline   Reply With Quote
Old 07-25-2019, 06:36 AM   #621
nikolalkc
Human being with feelings
 
nikolalkc's Avatar
 
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 153
Default

Quote:
Originally Posted by nofish View Post
I was actually thinking of position of items in terms of x and y coordinates in REAPER window.
nikolalkc is offline   Reply With Quote
Old 07-25-2019, 01:13 PM   #622
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by nikolalkc View Post
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.
juliansader is offline   Reply With Quote
Old 07-26-2019, 08:37 AM   #623
nikolalkc
Human being with feelings
 
nikolalkc's Avatar
 
Join Date: Feb 2017
Location: Belgrade, Serbia
Posts: 153
Default

Quote:
Originally Posted by juliansader View Post
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.
nikolalkc is offline   Reply With Quote
Old 07-27-2019, 03:55 AM   #624
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by nikolalkc View Post
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.
juliansader is offline   Reply With Quote
Old 07-27-2019, 05:30 AM   #625
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

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
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-27-2019, 10:05 AM   #626
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

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.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-27-2019, 11:26 AM   #627
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,401
Default

You can try, if the hwnd, whose title you can't change, has a childhwnd.
If yes, this probably holds the text as title...
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-27-2019, 11:30 AM   #628
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

Nope, unfortunately not. I solved it by using a double mouse click and a press of the delete key. Not very elegant, but works.
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-28-2019, 02:23 PM   #629
nappies
Human being with feelings
 
nappies's Avatar
 
Join Date: Dec 2017
Posts: 123
Default

Friends! Is there any way to get drag and drop Fx message from FX Browser to specific window (gfx window) with JS_API?)
nappies is offline   Reply With Quote
Old 07-29-2019, 01:51 PM   #630
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

Quote:
Originally Posted by _Stevie_ View Post
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.
juliansader is offline   Reply With Quote
Old 07-29-2019, 02:15 PM   #631
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

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...
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-29-2019, 02:21 PM   #632
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

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?
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-29-2019, 03:03 PM   #633
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 2,659
Default

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"?
juliansader is offline   Reply With Quote
Old 07-29-2019, 03:05 PM   #634
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

Okay that could be. In any case: it works! Thanks man
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...
_Stevie_ is offline   Reply With Quote
Old 07-30-2019, 08:44 AM   #635
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 196
Default

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?
reapero is offline   Reply With Quote
Old 07-30-2019, 08:55 AM   #636
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,792
Default

Quote:
Originally Posted by reapero View Post
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.
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is offline   Reply With Quote
Old 07-30-2019, 09:03 AM   #637
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 196
Default

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
reapero is offline   Reply With Quote
Old 07-30-2019, 09:14 AM   #638
_Stevie_
Human being with feelings
 
_Stevie_'s Avatar
 
Join Date: Oct 2017
Posts: 2,608
Default

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
__________________
My Reascripts forum thread | My Reascripts on GitHub | Stephan Römer - film composer
If you wish to donate for my scripts: please consider an organization like: animal shelter, doctors without borders, UNICEF, etc...

Last edited by _Stevie_; 07-30-2019 at 09:23 AM.
_Stevie_ is offline   Reply With Quote
Old 07-30-2019, 09:21 AM   #639
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,260
Default

Quote:
Originally Posted by reapero View Post
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
Edgemeal is offline   Reply With Quote
Old 07-30-2019, 09:45 AM   #640
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,260
Default

Quote:
Originally Posted by reapero View Post
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
Edgemeal 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 12:35 AM.


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