Old 10-24-2021, 03:25 PM   #1641
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by Edgemeal View Post
So what about the OK button? You still can't click it? Sending left mouse down/up messages on Mac should work...

Code:
function ClickWindow(hwnd)
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONDOWN", 1, 0, 0, 0)
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONUP", 0, 0, 0, 0)
end

function Main()  
  main_hwnd = reaper.JS_Window_FindTop("Project Settings", true) 
  if main_hwnd then   
    --  Do stuff once the window is found ---
    reaper.ShowConsoleMsg('Window found!\n')
    -- find & click the OK button
    OK_button = reaper.JS_Window_FindChildByID(main_hwnd, 1)
    if OK_button then
      reaper.ShowConsoleMsg('OK button found, Clicking OK button\n')
      ClickWindow(OK_button) 
    end 
  else
    reaper.ShowConsoleMsg('Window not yet found, trying again\n')    
    reaper.defer(Main)
  end 
end

-- Run action "File: Project settings..." without blocking this script,
reaper.JS_WindowMessage_Post(reaper.GetMainHwnd(), "WM_COMMAND", 40021,0,0,0)
Main()
Nope, as I said clicking the OK button does not work by ANY method, including:

WM_LBUTTONDOWN/WM_LBUTTONUP
WM_KEYDOWN/WM_KEYUP (using either space or return/enter)
BM_CLICK
etc...

It also does not work no matter how the message is sent

JS_WindowMessage_Send
JS_WindowMessage_Post
BR_WIN32_SendMessage

Clearly, this is another bug.
cohler is offline   Reply With Quote
Old 10-25-2021, 04:42 PM   #1642
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I tried this myself on Linux and on MacOS, both of which use WDL/swell. On Linux, emulating clicks with WindowMessage_Send works fine on any button in any (modeless) window. On MacOS, no luck in any windows outside the script IDE.

However, even in Linux, I couldn't get it to work on modal windows such as Project Settings.
juliansader is offline   Reply With Quote
Old 10-27-2021, 07:03 PM   #1643
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
I tried this myself on Linux and on MacOS, both of which use WDL/swell. On Linux, emulating clicks with WindowMessage_Send works fine on any button in any (modeless) window. On MacOS, no luck in any windows outside the script IDE.

However, even in Linux, I couldn't get it to work on modal windows such as Project Settings.
Yes, that's my experience as well. Can this bug be fixed?
cohler is offline   Reply With Quote
Old 10-29-2021, 04:29 AM   #1644
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by cohler View Post
Yes, that's my experience as well. Can this bug be fixed?
I reported it here: WDL/swell on macOS: emulating mouseclicks with WM_LBUTTONDOWN doesn't work.
juliansader is offline   Reply With Quote
Old 10-29-2021, 08:59 AM   #1645
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
Thanks. I posted there that sending SPACE using WM_KEYDOWN/WM_KEYUP to "click" the selected OK button also doesn't work on Mac.
cohler is offline   Reply With Quote
Old 10-29-2021, 07:11 PM   #1646
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

I rem reading on MSDN, to click a button on a dialog window you may need to activate the button first, anyone try that?
Code:
function ClickWindow(hwnd)
  reaper.JS_WindowMessage_Send(hwnd, "WM_ACTIVATE", 1, 0, 0, 0) -- 1=WA_ACTIVE 
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONDOWN", 1, 0, 0, 0)
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONUP", 0, 0, 0, 0)
end
FWIW, I tried WA_CLICKACTIVE like I used to change REAPER topmost pins on that OK button but that didn't work here on Win10.


Also, SWS has action to send left mouse click to whatever visible window is under the mouse pointer, '_S&M_MOUSE_L_CLICK', IOW what code that using?
Edgemeal is offline   Reply With Quote
Old 10-29-2021, 09:29 PM   #1647
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,964
Default

Quote:
Originally Posted by Edgemeal View Post
Also, SWS has action to send left mouse click to whatever visible window is under the mouse pointer, '_S&M_MOUSE_L_CLICK', IOW what code that using?
Code:
void SimulateMouseClick(COMMAND_T* _ct)
{
	POINT p;
	GetCursorPos(&p);
	mouse_event(MOUSEEVENTF_LEFTDOWN, p.x, p.y, 0, 0);
	mouse_event(MOUSEEVENTF_LEFTUP, p.x, p.y, 0, 0);
	WinWaitForEvent(WM_LBUTTONUP);
}
(That SWS action is only available on Windows)
cfillion is offline   Reply With Quote
Old 10-30-2021, 05:04 AM   #1648
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by Edgemeal View Post
I rem reading on MSDN, to click a button on a dialog window you may need to activate the button first, anyone try that?
Code:
function ClickWindow(hwnd)
  reaper.JS_WindowMessage_Send(hwnd, "WM_ACTIVATE", 1, 0, 0, 0) -- 1=WA_ACTIVE 
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONDOWN", 1, 0, 0, 0)
  reaper.JS_WindowMessage_Send(hwnd, "WM_LBUTTONUP", 0, 0, 0, 0)
end
FWIW, I tried WA_CLICKACTIVE like I used to change REAPER topmost pins on that OK button but that didn't work here on Win10.


Also, SWS has action to send left mouse click to whatever visible window is under the mouse pointer, '_S&M_MOUSE_L_CLICK', IOW what code that using?
Still doesn't work on Mac with WM_ACTIVATE using wParam WA_ACTIVE or WA_CLICKACTIVE.

The SWS action mentioned is a solution to a different problem, because it requires the user to move the mouse over the button. The whole point here is to click the button without user action.
cohler is offline   Reply With Quote
Old 10-30-2021, 08:31 AM   #1649
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by cohler View Post
Still doesn't work on Mac with WM_ACTIVATE using wParam WA_ACTIVE or WA_CLICKACTIVE.

The SWS action mentioned is a solution to a different problem, because it requires the user to move the mouse over the button. The whole point here is to click the button without user action.
Ya I wouldn't use mouse_event in a publicly released app, but I did use it as a last resort in one of my personal apps years ago... Save mouse position, move mouse to target window, make sure the target window is topmost/foreground, call api to click mouse, move mouse back to where it was. Sorry I couldn't help, best of luck!
Edgemeal is offline   Reply With Quote
Old 12-07-2021, 04:30 AM   #1650
Rodilab
Human being with feelings
 
Rodilab's Avatar
 
Join Date: Jan 2021
Location: Paris
Posts: 255
Default

Hi guys

When using JS_Mouse_GetCursor() and JS_Mouse_LoadCursor(), are the cursors id the same on all OS and themes ?
For example, left edge is 417 and right edge is 418 at home.
This will work for everybody ? :

Code:
local reaper_cursors =
{
  {417,'EDGE L'},
  {418,'EDGE R'}
}

function MouseCursor()
  local cur_cursor = reaper.JS_Mouse_GetCursor()
  for i = 1, #reaper_cursors do
    local cursor = reaper.JS_Mouse_LoadCursor(reaper_cursors[i][1])
    if cur_cursor == cursor then
      return reaper_cursors[i][2]
    end
  end
  return nil
end
Rodilab is offline   Reply With Quote
Old 12-07-2021, 01:47 PM   #1651
Infrabass
Human being with feelings
 
Join Date: Apr 2014
Posts: 398
Default

Hi everyone,
I'm still not sure if we can send keystrokes via reascript on Mac.
I think it's something around "reaper.JS_WindowMessage_Post" but I can't make it work.
Is it possible in the first place?
Thanks!

Last edited by Infrabass; 12-08-2021 at 12:04 AM.
Infrabass is offline   Reply With Quote
Old 12-07-2021, 04:33 PM   #1652
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Rodilab View Post
Hi guys

When using JS_Mouse_GetCursor() and JS_Mouse_LoadCursor(), are the cursors id the same on all OS and themes ?
For example, left edge is 417 and right edge is 418 at home.
This will work for everybody ? :
To the best of my knowledge, the IDs should work the same for everyone, but themes may change the appearance of the cursors.
juliansader is offline   Reply With Quote
Old 12-07-2021, 04:49 PM   #1653
tack
Human being with feelings
 
tack's Avatar
 
Join Date: Jan 2014
Location: Ontario, Canada
Posts: 1,619
Default

Quote:
Originally Posted by Rodilab View Post
are the cursors id the same on all OS and themes ?
There are some differences -- some cursors only work on Windows -- but otherwise they are consistent (except for width+height resize cursors which are swapped on Linux). Cursor ids below 2000 should be safe.

This is documented here for rtk:

https://reapertoolkit.dev/module/rtk....mouse.cursors

You can see what those rtk-specific constants translate to for your own non-rtk scripts here:

https://github.com/jtackaberry/rtk/b.../core.lua#L309

Last edited by tack; 12-07-2021 at 04:59 PM.
tack is offline   Reply With Quote
Old 12-11-2021, 06:44 AM   #1654
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

How to get the trackview window HWND in linux?
In windows, I can get it from this:
Code:
hwnd=reaper.JS_Window_Find('trackview', true)
But it doesn't work in linux. I try to print all child windows' name of main window:
Code:
local main=reaper.GetMainHwnd()
retval, list = reaper.JS_Window_ListAllChild(main)
for address in list:gmatch('[^,]+') do
  local hwnd= reaper.JS_Window_HandleFromAddress(address)
  reaper.ShowConsoleMsg(reaper.JS_Window_GetTitle(hwnd)..'\n')
end
But no "trackview" in them.
dsyrock is offline   Reply With Quote
Old 12-11-2021, 03:43 PM   #1655
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Window and class names are not cross-platform reliable. Instead, use window IDs, with JS_Window_FindChildByID. You can get the ID with JS_Window_GetLong(win, "ID"). IIRC, the trackview's ID is 1000.
juliansader is offline   Reply With Quote
Old 12-11-2021, 06:14 PM   #1656
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Quote:
Originally Posted by juliansader View Post
Window and class names are not cross-platform reliable. Instead, use window IDs, with JS_Window_FindChildByID. You can get the ID with JS_Window_GetLong(win, "ID"). IIRC, the trackview's ID is 1000.
Thanks. By the way, is there any way to print all the child ID of a parent window?
dsyrock is offline   Reply With Quote
Old 12-14-2021, 03:36 PM   #1657
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default Do the JS_Actions functions still exist somewhere?

What happened to the JS_Actions functions?
cohler is offline   Reply With Quote
Old 12-14-2021, 06:11 PM   #1658
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by dsyrock View Post
Thanks. By the way, is there any way to print all the child ID of a parent window?
Sure. Use the same code as in your previous post, but replace reaper.JS_Window_GetTitle(hwnd) with reaper.JS_Window_GetLong(hwnd, "ID")
juliansader is offline   Reply With Quote
Old 12-14-2021, 06:12 PM   #1659
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by cohler View Post
What happened to the JS_Actions functions?
Please jog my memory -- what were the JS_Actions functions?
juliansader is offline   Reply With Quote
Old 12-14-2021, 07:30 PM   #1660
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
Please jog my memory -- what were the JS_Actions functions?
  • JS_Actions_CountShortcuts
  • JS_Actions_DeleteShortcuts
  • JS_Actions_DoShortcutDialog
  • JS_Actions_GetShortcutDesc
cohler is offline   Reply With Quote
Old 12-14-2021, 07:44 PM   #1661
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Sorry, I still don't quite understand what you are referring to. Did anything happen to these functions on your system?
juliansader is offline   Reply With Quote
Old 12-15-2021, 09:31 AM   #1662
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by juliansader View Post
Sorry, I still don't quite understand what you are referring to. Did anything happen to these functions on your system?
Sorry, my bad. The problem was that I was using v0.999 of js_ReaScriptAPI64.dylib. I've updated now to 1.220 and all is good.
cohler is offline   Reply With Quote
Old 12-24-2021, 02:11 AM   #1663
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I am working on v1.300 of the extension, with the following updates:
* New: Zip/Unzip functions.
* LoadPNG/JPGFromMemory, which work nicely after Zip_Entry_ExtractToMemory.
* New: JS_LICE_SetFontFXColor, so that font shadows can be properly black.
* New: TabCtrl functions.
* Fixed: JS_ListView_SetItemState documentation.

I would appreciate it very much if some of you could check whether the new version loads and works properly -- particularly on Apple ARM, since I can't test that platform myself.

macOS
macOS ARM
Linux
Windows


EDIT: Added the LoadPNG/JPGFromMemory functions.

Last edited by juliansader; 12-24-2021 at 11:00 AM.
juliansader is offline   Reply With Quote
Old 12-24-2021, 10:37 AM   #1664
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

Quote:
Originally Posted by juliansader View Post
I am working on v1.300 of the extension, with the following updates:
* New: Zip/Unzip functions.
* New: JS_LICE_SetFontFXColor, so that font shadows can be properly black.
* New: TabCtrl functions.
* Fixed: JS_ListView_SetItemState documentation.

I would appreciate it very much if some of you could check whether the new version loads and works properly -- particularly on Apple ARM, since I can't test that platform myself.

macOS
macOS ARM
Linux
Windows

Thank you so much for these additions!


I am testing the zip actions:

Code:
local function Error( ok, msg )
  if not msg then msg = "" 
  else msg = msg .. " : "
  end
  if ok < 0 then
    reaper.JS_Zip_Close( nil, zipHandle )
    error(msg .. reaper.JS_Zip_ErrorString( ok ))
  else
    reaper.ShowConsoleMsg( msg .. ok .. "\n")
  end
end

theme = reaper.GetResourcePath() .. "\\ColorThemes\\Default_5.0.ReaperThemeZip"
zipHandle, ok = reaper.JS_Zip_Open(theme, "READ",  6)
Error(ok,"openzip")
entries_cnt = reaper.JS_Zip_CountEntries( zipHandle )
entry_id = reaper.JS_Zip_Entry_OpenByName( zipHandle, "Default_5.0_unpacked\\rtconfig.txt")
ok, contents = reaper.JS_Zip_Entry_ExtractToMemory(zipHandle)
Error(ok,"extract2mem")
--reaper.ShowConsoleMsg( contents )
ok = reaper.JS_Zip_Entry_Close(zipHandle)
Error(ok,"entryclose")
ok = reaper.JS_Zip_Close( theme )
Error(ok,"zipclose")

JS_Zip_Entry_ExtractToMemory seems to return positive numbers on success while the documentation states that it would return 0.
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)

Last edited by amagalma; 12-24-2021 at 10:44 AM.
amagalma is offline   Reply With Quote
Old 12-24-2021, 10:40 AM   #1665
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,628
Default

Quote:
Originally Posted by juliansader View Post
I am working on v1.300 of the extension, with the following updates:
* New: Zip/Unzip functions.
* New: JS_LICE_SetFontFXColor, so that font shadows can be properly black.
* New: TabCtrl functions.
* Fixed: JS_ListView_SetItemState documentation.

I would appreciate it very much if some of you could check whether the new version loads and works properly -- particularly on Apple ARM, since I can't test that platform myself.

macOS
macOS ARM
Linux
Windows


Oooh...this sounds very nice
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 12-24-2021, 10:50 AM   #1666
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,458
Default

TabCtrl actions do not work with WDLTabCtrl class, right?
Code:
bay = reaper.JS_Window_Find("Project Bay", true)
tab = reaper.JS_Window_FindChildByID( bay, 1064 )
count = reaper.JS_TabCtrl_GetItemCount( tab )
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 12-24-2021, 10:59 AM   #1667
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

I forgot to mention that there are also new LoadPNG/JPGFromMemory functions, which work very nicely after Zip_Entry_ExtractToMemory.
juliansader is offline   Reply With Quote
Old 12-24-2021, 11:21 PM   #1668
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 565
Default

Quote:
Originally Posted by juliansader View Post
I forgot to mention that there are also new LoadPNG/JPGFromMemory functions, which work very nicely after Zip_Entry_ExtractToMemory.
Hi, is there any plan about getting access in tree list? Like the tree list in Media Explorer?
dsyrock is offline   Reply With Quote
Old 01-02-2022, 01:56 PM   #1669
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Wondering if there are solutions to any of these questions using js_ReaScriptAPI? I have posted them each independently in the Developer forum and received lots of views but no responses:
cohler is offline   Reply With Quote
Old 01-10-2022, 07:17 AM   #1670
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 522
Default

Hey!

I am trying to send a right click to a plugin window and using the following code, it doesnt work:

Code:
x, y = reaper.GetMousePosition()
w = reaper.JS_Window_FromPoint(x, y)
x, y = reaper.JS_Window_ScreenToClient(w, x, y)
reaper.JS_WindowMessage_Send(w, "WM_RBUTTONDOWN", 1, 0, x, y)
reaper.JS_WindowMessage_Send(w, "WM_RBUTTONUP", 0, 0, x, y)
This works when being in the main reaper window (soit sends the right click on the TCP, timeline, items, empty areas, etc) but it fails once the mouse is inside the VSTi UI. I am wondering if reaper.JS_Window_ScreenToClient is not the right thing to use here?

Thx!

EDIT: Sending a keystroke works so looks like its something related to mouse clicks?

Last edited by reapero; 01-10-2022 at 12:14 PM.
reapero is offline   Reply With Quote
Old 01-15-2022, 02:28 PM   #1671
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,628
Default

Is there a way to hijack mouse-messages from a hwnd?
I would like to rewire left-doubleclick and right-click on markers to use my code instead of opening the edit marker-dialog and the marker-context-menu.
But for that, I need to prevent them from being recognized by the marker-lane and be able to get, that the user tried to send left-doubleclick or right-click, so I can react to it.

Where should I look?

@JulianSader
Clipboards can also hold image-information at least on Windows. Would it be possible to make a function JS_Image_GetFromClipboard, that returns a handler, that I could blit or pass to the png/jpg-save-functions and JS_Image_PutToClipboard to put the contents of an image back into the clipboard of the os?

I would like to be able to get a coverimage from clipboard and write a script, that automatically saves it as png in my projectfolder.

That way, I can create the cover in an Photoshop, etc, and can put it in my projectfolder, without needing to choose the projectfolder in Photoshop to save it, I just put it into the clipboard and run my script.
And if I need to alter it again, I simply put it into the clipboard using Reaper and paste it back into Photoshop.

This would make some things like that go much faster, but I don't know, if that is possible in the first place...

What do you think?
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
Old 01-15-2022, 03:54 PM   #1672
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by Meo-Ada Mespotine View Post
Is there a way to hijack mouse-messages from a hwnd?
Yes -- the WindowMessage_Intercept functions should hopefully do the job.


Quote:
Originally Posted by Meo-Ada Mespotine View Post
Would it be possible to make a function JS_Image_GetFromClipboard
I'm not sure, but I will look into it.
juliansader is offline   Reply With Quote
Old 01-15-2022, 03:55 PM   #1673
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Has anyone checked whether the Apple ARM version of the extension's v1.300 update loads correctly?
juliansader is offline   Reply With Quote
Old 01-15-2022, 04:09 PM   #1674
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by dsyrock View Post
Hi, is there any plan about getting access in tree list? Like the tree list in Media Explorer?
I haven't looked into tree lists yet.
juliansader is offline   Reply With Quote
Old 01-15-2022, 04:21 PM   #1675
juliansader
Human being with feelings
 
Join Date: Jul 2009
Posts: 3,714
Default

Quote:
Originally Posted by reapero View Post
I am trying to send a right click to a plugin window and using the following code, it doesnt work:
Which VSTi and operating system are you using? I tested a few VSTs on Windows and Linux, and they all seem to work fine.

However, I suspect that if you're on Linux or macOS, and if the VST bypasses REAPER/swell to draw the windows by itself, the VST might not respond to REAPER's swell messages.
juliansader is offline   Reply With Quote
Old 01-16-2022, 10:20 AM   #1676
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 522
Default

Quote:
Originally Posted by juliansader View Post
Which VSTi and operating system are you using?
Its Omnisphere2 with windows10. I just had a look at the problem again and turns out that i am receiving a left click instead of a right one. I tried with Massive and this does receive the right click correctly, so looks like its something specific from Omnisphere.

Can you think of why such a thing would happen? Could there be a workaround or shall i just let it go?

Thanks, you are awesome, as always!
reapero is offline   Reply With Quote
Old 01-16-2022, 03:38 PM   #1677
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by reapero View Post
Its Omnisphere2 with windows10. I just had a look at the problem again and turns out that i am receiving a left click instead of a right one.
Maybe try setting wParam to 0x2 (MK_RBUTTON), for down..
Code:
reaper.JS_WindowMessage_Send(w, "WM_RBUTTONDOWN", 2, 0, x, y)
Edgemeal is offline   Reply With Quote
Old 01-17-2022, 04:51 AM   #1678
reapero
Human being with feelings
 
Join Date: Aug 2011
Posts: 522
Default

Quote:
Originally Posted by Edgemeal View Post
Maybe try setting wParam to 0x2 (MK_RBUTTON), for down..
Code:
reaper.JS_WindowMessage_Send(w, "WM_RBUTTONDOWN", 2, 0, x, y)
Yes! That made it work, for TCP and inside Omnisphere! Thanks a ton Edgemeal!

Now i am facing another problem. I want the script to send the right click and then select one of this options from the dropdown menu:



I thought about sending cursor key down strokes once this dropdown menu shows up, since that works when using my keyboard, but it doesnt work since i guess (might be wrong here) the dropdown is a new window with different handle. So whats happening now is that once i get rid of the dropdown manually, the cursor down is sent to Omnisphere, which changes the patch

Using spyxx i cant seem to find the handle for that window cause i soon as i switch the app the dropdown menu disappears. Any suggestions are welcome
reapero is offline   Reply With Quote
Old 01-17-2022, 09:31 AM   #1679
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Quote:
Originally Posted by reapero View Post
Yes! That made it work, for TCP and inside Omnisphere! Thanks a ton Edgemeal!
Cool!
Quote:
Using spyxx i cant seem to find the handle for that window cause i soon as i switch the app the dropdown menu disappears. Any suggestions are welcome
You can detect menu by its classname ("#32768").
https://docs.microsoft.com/en-us/win...window-classes

AFAIK JS_API doesn't have the needed functions to interact with Menus, but maybe you can hack it by sending keys to the window to select the menu item?
Quick test worked here on the (TCP) Track context menu,..

Code:
-- Select context menu item example/hack

-- virtual keys -- https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
local VK_DOWN = 0x28   -- DOWN ARROW key
local VK_RETURN = 0x0D -- ENTER key

function PostKey(hwnd, vk_code)
  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 FindMenu()
  local arr = reaper.new_array({}, 1024)
  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 
      -- context menu found, call another function or whatever...
      --> TEST: Send 3 Down Arrow keys, followed by an Enter key to select 3rd menu item.
      for i = 1, 3 do PostKey(hwnd, VK_DOWN) end
      PostKey(hwnd, VK_RETURN)
      return -- exit func.
    end
  end
  -- limit how long to wait for menu to be found
  if (reaper.time_precise() - init_time) >= 2.0 then -- 2 sec max wait.
    reaper.ShowConsoleMsg('Context menu not found!\n')
    return
  end
  reaper.defer(FindMenu)
end

init_time = reaper.time_precise()
FindMenu()

Last edited by Edgemeal; 01-17-2022 at 10:07 AM.
Edgemeal is offline   Reply With Quote
Old 01-18-2022, 08:02 AM   #1680
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,628
Default

Quote:
Originally Posted by juliansader View Post
Yes -- the WindowMessage_Intercept functions should hopefully do the job.




I'm not sure, but I will look into it.
Thnx
__________________
Use you/she/her.Ultraschall-Api Lua Api4Reaper - Donate, if you wish

On vacation for the time being...
Meo-Ada Mespotine is offline   Reply With Quote
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 01:46 AM.


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