Using "send to program" to open & download. webpage
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Using "send to program" to open & download. webpage
Is there a way to use LC's "send to program" (on a Mac) to first open then download a WebPage providing the URL?
Re: Using "send to program" to open & download. webpage
Hi.
"Send to Program" derives from Hypercard, where I used it extensively to communicate between machines on a network. The "program" I always was sending to was Hypercard itself.
It does not have the power that it once did, though. For my use, I had to consider sockets instead. What program would you think would be at the other end? Something like "send "openThis" to program "Safari" with "XURL"?
Craig
"Send to Program" derives from Hypercard, where I used it extensively to communicate between machines on a network. The "program" I always was sending to was Hypercard itself.
It does not have the power that it once did, though. For my use, I had to consider sockets instead. What program would you think would be at the other end? Something like "send "openThis" to program "Safari" with "XURL"?
Craig
Last edited by dunbarx on Tue Oct 25, 2022 12:12 am, edited 1 time in total.
Re: Using "send to program" to open & download. webpage
Hi Craig,
*and* then another instruction to download the uploaded page (which is a page created after a PHP request)
Exactly this. Send "OpenThis" to (a modern browser) with ThisURLWhat program would you think would be at the other end? Something like "send "openThis" to program "Safari" with "XURL"?
*and* then another instruction to download the uploaded page (which is a page created after a PHP request)
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Using "send to program" to open & download. webpage
To launch a browser to display a given URL:
To download a file from a web server:
Code: Select all
launch url "http://fourthworld.com"
Code: Select all
put url "http://fourthworld.com/products/devolution/4wDevo.livecode.gz" \
into url ("binfile:/Some/Path/To/Local/File.extension")
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Using "send to program" to open & download. webpage
Richard.
In you opinion, then, what benefit does the "Send to Program" command still offer? I found it hobbled to say the least.
Craig
In you opinion, then, what benefit does the "Send to Program" command still offer? I found it hobbled to say the least.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Using "send to program" to open & download. webpage
None. LC Ltd recommends launching URLs with the "launch URL" command.
AFAIK "send to <program>" and "answer program" were dependent on OS APIs only available in Mac Classic/Carbon, no longer maintained in current macOS. And being directly bound to Apple events, they're Mac-only anyway and therefore non-starters for any cross-platform use.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Using "send to program" to open & download. webpage
For mac-only development you can achieve quite a lot more with AppleScript, especially as there are many hooks into all sorts of apps and the OS.
LC does provide the do as syntax for this:
for example
There is a huge online resource for AppleScripts so for more complex tasks that LC doesn't cater for directly (eg integrating with iCal etc), and probably fills the gap for 'send to program' quite nicely...
LC does provide the do as syntax for this:
Code: Select all
do <script> as <alternateLanguage>
Code: Select all
do ("tell application" && quote & "Finder" & quote && "to activate") as "applescript"
Re: Using "send to program" to open & download. webpage
Thanks so much, as always, Craig, Richrad, for your answers
Now I'm pondering stam's (thanks to!! ) useful comments…
In my opinion, this is a nice example of the situation where you would appreciate something akin to the "Send to Program" command. By using the
you may get nothing useful from a page using JavaScript to load its content. But if you were able to tell the app to download the URL and then do something with it…put url "http://fourthworld.com/products/devolut ... ivecode.gz" \
into url ("binfile:/Some/Path/To/Local/File.extension")
Now I'm pondering stam's (thanks to!! ) useful comments…
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Using "send to program" to open & download. webpage
How can AppleScript be used to trigger JavaScript functions inside of a web page?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Using "send to program" to open & download. webpage
I mentioned AppleScript as a way to “send to a program” that is above and beyond a browser. A huge degree of automation is possible, but alas is MacOS only.
Having said that, I imagine you can control browsers to a higher degree than LC can.
Admittedly this doesn’t answer the OP which was to “download a page by providing a URL” [in LC]. No one would use AppleScript for that, although I’m sure it’s possible in the same way it is in LC (and FWIW I’m not sure “triggering JavaScript functions” was the specific question, unless you mean as part of loading the desired web page - in this would be done in the browser controlled by AS).
But I mentioned this as an alternative to a “send to program” generically, since the OS specified was MacOS.
Having said that, I imagine you can control browsers to a higher degree than LC can.
Admittedly this doesn’t answer the OP which was to “download a page by providing a URL” [in LC]. No one would use AppleScript for that, although I’m sure it’s possible in the same way it is in LC (and FWIW I’m not sure “triggering JavaScript functions” was the specific question, unless you mean as part of loading the desired web page - in this would be done in the browser controlled by AS).
But I mentioned this as an alternative to a “send to program” generically, since the OS specified was MacOS.
Re: Using "send to program" to open & download. webpage
I don't think you can (but I'm not an expert on AppleScript)FourthWorld wrote: ↑Tue Oct 25, 2022 1:43 amHow can AppleScript be used to trigger JavaScript functions inside of a web page?
Re: Using "send to program" to open & download. webpage
How did triggering JavaScript functions enter the conversation?
FWIW:
- there is a “do JavaScript” command in AppleScript.
- for related conversations see here: https://forum.latenightsw.com/t/scripti ... script/996
Particularly in response to the OP if you wanted to go down the AppleScript route:
http://www.cubemg.com/how-to-extract-in ... plescript/
As I said, AppleScript is an often overlooked gem… but sadly MacOS only.
FWIW:
- there is a “do JavaScript” command in AppleScript.
- for related conversations see here: https://forum.latenightsw.com/t/scripti ... script/996
Particularly in response to the OP if you wanted to go down the AppleScript route:
http://www.cubemg.com/how-to-extract-in ... plescript/
As I said, AppleScript is an often overlooked gem… but sadly MacOS only.
Last edited by stam on Wed Oct 26, 2022 10:47 am, edited 1 time in total.
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Using "send to program" to open & download. webpage
Daniel's been working at trying to get dynamically-rendered data from a site:
https://forums.livecode.com/viewtopic.p ... 54#p218540
Since the site is licensed under Creative Commons, it may be that they have a copy of the data available for download, or will add a REST API as they finish the site. Either would greatly simplify his task.
The way to find out would be to write them. I don't know if he's done that.
LiveCode has a similar function built into the browser widget, allowing you to execute JavaScript within the page the widget displays.FWIW:
- there is a “do JavaScript” command in AppleScript.
AFAIK it works on every platform where the browser widget is available. But since that doesn't include modern Ubuntu I've never used it and don't recall the syntax for accessing that offhand. But I'd guess that a quick trip through the See Alsos of most browser widget entries in the Dictionary would turn that up quickly.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Using "send to program" to open & download. webpage
Not arguing that for LC projects it’s easier to use LC commands.
Just mentioning as an alternative for other things.
But on the specific question of being able to do this with AS, please see the URL I linked above:
http://www.cubemg.com/how-to-extract-in ... plescript/
Just mentioning as an alternative for other things.
But on the specific question of being able to do this with AS, please see the URL I linked above:
http://www.cubemg.com/how-to-extract-in ... plescript/
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Using "send to program" to open & download. webpage
It seems like a good tutorial, and likely a good starting point for the rich simulated interactions he'll need to get to the snippet he's looking for.
Or when he writes them he may find they've finished their open source repository and he can just have all the snippets he needs ready to go with no extra effort at all.
I guess we'll find out after he writes to them.
Or when he writes them he may find they've finished their open source repository and he can just have all the snippets he needs ready to go with no extra effort at all.
I guess we'll find out after he writes to them.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn