Old 02-18-2018, 07:51 PM   #1
mb945
Human being with feelings
 
Join Date: Jan 2017
Posts: 113
Default HTTP Requests from ReaScript

Is it possible to access the internet and do HTTP PUT requests via Lua or EEL or some other way?

I am trying to control Hue lights from within Reaper and I have a solution working but it shows a popup of the Windows command window each time and is distracting. I would like to find a way to prevent that.

Currently there is a Lua script that calls one of two javascripts that change the light color based on the recording status.

What I would like is to eliminate the external javascript files and do this all from ReaScript with no popup windows. Is that possible? Thanks!!

Here are the files I'm using currently:
http://files.civilaudio.com/b/NMtI4CBqcvSnrg0X2VEr
mb945 is offline   Reply With Quote
Old 02-18-2018, 11:44 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Heda VIP dowbload is able to download things without opening CMD.

Cfillion did create ShellExecute reascript function which will allows on windows to not open the cmd windows with CLI commands. It is waiting to be metge in next SWS release.

Also, maybe check cURL. I think it is possible to call that for http post request from reascript (I dont know how to use it though).
X-Raym is offline   Reply With Quote
Old 02-19-2018, 05:43 AM   #3
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

cURL + reaper.ExecProcess should work without briefly flashing the command prompt.

Code:
curl -X PUT -d '{"on":false,"bri":1,"sat":255,"hue":0}' http://192.168.1.102/api/USERID/lights/1/state
Quote:
Originally Posted by X-Raym View Post
Cfillion did create ShellExecute reascript function which will allows on windows to not open the cmd windows with CLI commands. It is waiting to be metge in next SWS release.
ShellExecute isn't for running arbitrary commands: it takes a file or URL and opens it in the default application. It's a better alternative to the "start" command. It's pretty much the same as the existing BR_Win32_ShellExecute without the unneeded arguments + returning the same values on every OS.

Last edited by cfillion; 02-19-2018 at 05:59 AM.
cfillion is offline   Reply With Quote
Old 02-19-2018, 11:11 AM   #4
mb945
Human being with feelings
 
Join Date: Jan 2017
Posts: 113
Default

Quote:
Originally Posted by Veto View Post
(Answering here instead of the original thread) using reaper.ExecProcess what about this?
This works!!
Thank you.

For reference, here is the working solution:
http://files.civilaudio.com/b/NMtI4CBqcvSnrg0X2VEr
mb945 is offline   Reply With Quote
Old 02-19-2018, 11:27 AM   #5
mb945
Human being with feelings
 
Join Date: Jan 2017
Posts: 113
Default

Quote:
Originally Posted by Veto View Post
Great!
btw others to load the script into Reaper would need to remove the ".txt" extension from the lua file.
(at least I'm not able to import a .txt here)
Yes, I only had the .txt there so it was viewable in the browser without downloading. Switched it to the .lua version now. Thanks again to everyone for your help!
mb945 is offline   Reply With Quote
Old 02-19-2018, 12:05 PM   #6
mb945
Human being with feelings
 
Join Date: Jan 2017
Posts: 113
Default

I added a new post for clarity that details all of the instructions on how to get this setup. Let me know or post in that thread if you'd like to comment/clarify anything. Thanks again for everyone's help!
https://forum.cockos.com/showthread.php?p=1956540
mb945 is offline   Reply With Quote
Old 03-17-2020, 12:00 PM   #7
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by cfillion View Post
cURL + reaper.ExecProcess should work without briefly flashing the command prompt.

Code:
curl -X PUT -d '{"on":false,"bri":1,"sat":255,"hue":0}' http://192.168.1.102/api/USERID/lights/1/state
But reaper.ExecProcess doesn't seem to work at all on the Mac, or am I missing something?
cohler is offline   Reply With Quote
Old 03-17-2020, 12:07 PM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

IMHO Curl should be in some extension-plugin.
Working with command-line-tools is sometimes really slow, as every time you run a command, it will open a new instance of the command-line.
This is ok for few files or requests but the more it becomes, the worse it gets, probably.

Making this perform sufficiently is probably a heavy task.

Have no idea though, how to do it practically, especially the receive part, as send/receive is probably very asynchronous in regards of http/web-requests.
__________________
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 03-17-2020, 12:08 PM   #9
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,937
Default

Quote:
Originally Posted by cohler View Post
But reaper.ExecProcess doesn't seem to work at all on the Mac, or am I missing something?
It requires an absolute path to the executable on macOS and Linux.
cfillion is offline   Reply With Quote
Old 03-22-2020, 09:41 AM   #10
cohler
Banned
 
Join Date: Dec 2018
Posts: 642
Default

Quote:
Originally Posted by cfillion View Post
It requires an absolute path to the executable on macOS and Linux.
Thanks!
cohler 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 09:26 AM.


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