|
|
|
12-02-2014, 11:31 AM
|
#1
|
Human being with feelings
Join Date: Mar 2007
Posts: 21,551
|
Javascript
I ask here because you guys are talented. Here's what I need to do...
1. Javascript files A, B, and C are external to my Win application.
2. I need to fire a function in file B from my external application.
Possible? To make an entry point into an external JS file and fire a JS function as if it was called from the script collection?
Thanks for any advice.
|
|
|
12-02-2014, 12:32 PM
|
#2
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
It's "probably" possible but it would depend on how your main application has been written. With what language, what frameworks you have at your disposal etc...(By the way, can there really be some so awesome function you are prepared to involve Javascript to execute it...? Or is the function going to be something user written or so...?)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
12-02-2014, 12:45 PM
|
#3
|
Human being with feelings
Join Date: Mar 2007
Posts: 21,551
|
The commands I'm trying to get to already fire directly from a JS function so if I could inject into that, call that function directly, externally, it would remove a large layer of coding to do the same thing, that would then be unnecessary. I'm using this code below to send formatted keyboard messages to an app, and it works fine, as long as the keycode is properly formatted...
Code:
' Convert qwerty letters to their keycodes
Dim o As Object = kc.ConvertFromString(Key) 'last arry item
keyCode = CType(o, Keys)
' If modifier is required, use these. May have 3 modifiers total
If KeyMods(0) = True Then keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYDOWN, 0)
If KeyMods(1) = True Then keybd_event(VK_ALT, MapVirtualKey(VK_ALT, 0), KEYEVENTF_KEYDOWN, 0)
If KeyMods(2) = True Then keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYDOWN, 0)
'Main Key Char To press ===============================
SendMessage(CurHwnd, WM_KEYDOWN, keyCode, 0)
SendMessage(CurHwnd, WM_KEYUP, keyCode, 0)
'======================================================
'if modifiers are used, release
If KeyMods(0) = True Then keybd_event(VK_CONTROL, MapVirtualKey(VK_CONTROL, 0), KEYEVENTF_KEYUP, 0)
If KeyMods(1) = True Then keybd_event(VK_ALT, MapVirtualKey(VK_ALT, 0), KEYEVENTF_KEYUP, 0)
If KeyMods(2) = True Then keybd_event(VK_SHIFT, MapVirtualKey(VK_SHIFT, 0), KEYEVENTF_KEYUP, 0)
.. but if I could hit the JS function directly, which is already attached to the main class, I could send the actual commands directly to the app without being concerned with parsing and formatting key combos. The JS function takes a codeline something like this below...
Code:
Host.GUI.Commands.interpretCommand (element.category, element.name, false, args);
... so if I could call that function I could get rid of all the API code doing keyboard and sendmessage and send the command directly to the app UI. It works fine as is, just wondering if there's a better way. Instead of taking a key combo from a command and formatting it and then passing it to the API, I could send the literal category | element (action) | args directly to the JS function.
I wonder if it might be better to not do this in VS altogether and just add a new include file to the JS collection and use an XML UI so I could have a direct connection to the JS files, the mini API already there in JS.
Last edited by Lawrence; 12-02-2014 at 01:03 PM.
|
|
|
12-02-2014, 01:19 PM
|
#4
|
Human being with feelings
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
|
Quote:
Originally Posted by Lawrence
I ask here because you guys are talented.
|
Definitely - but for generic programming questions (i.e. not EEL/JesuSonic, not related specifically to anything REAPER/audio/dsp), Stack Overflow may get you much better answers.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
|
|
|
12-02-2014, 02:35 PM
|
#5
|
Human being with feelings
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
|
Quote:
Originally Posted by Banned
Definitely - but for generic programming questions (i.e. not EEL/JesuSonic, not related specifically to anything REAPER/audio/dsp), Stack Overflow may get you much better answers.
|
+1 to that! (I am not telling Lawrence to go away from these Reaper forums, but I think the programmers spending time here on these Cockos forums mainly know more about VST and Reaper extension plugins, C/C++, Eel/Jesusonic and such topics...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
|
|
|
01-15-2015, 09:13 PM
|
#6
|
Human being with feelings
Join Date: Jan 2015
Location: Vancouver
Posts: 3
|
You could check out javascript.net, which itself is based on Google's V8 engine. It should let you marshal objects in and out of javascript code.
You could use this sort of thing to let a user control bits of your plugin's internals with user created javascript.
|
|
|
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 06:46 PM.
|