Associated File Launching a Standalone or Handling Associated File Input

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
reflectedpixel
Posts: 6
Joined: Thu Jan 17, 2019 7:37 pm

Associated File Launching a Standalone or Handling Associated File Input

Post by reflectedpixel » Thu Jan 17, 2019 7:43 pm

What message shows up when another app or associated file sends the launch command to my app?

I'm building an app to receive images from a camera. The camera app (EOS Utility) has the option to associate another app. Most apps (photoshop etc.) will just open the newly downloaded image file. I don't know what message to handle when I associate my own app. I tried "launchDataChanged" My app just launches and every time a new file is sent, it launches another instance of the app. I don't see anything in the Message Watcher if I associate the Livecode IDE to open the files.

I can capture the filepath by using the "on startup" and $1 But a new instance of my app is started every time I double click a new file?


Thanks!!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Associated File Launching a Standalone or Handling Associated File Input

Post by FourthWorld » Thu Jan 17, 2019 9:01 pm

The relaunch message allows you to control whether you want one or multiple instances of your app running when launched with documents on Windows:
https://livecode.com/resources/api/#liv ... t/relaunch
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

reflectedpixel
Posts: 6
Joined: Thu Jan 17, 2019 7:37 pm

Re: Associated File Launching a Standalone or Handling Associated File Input

Post by reflectedpixel » Fri Jan 18, 2019 10:33 pm

Thank you so much!
Now I'm working on making this work on the Mac. is on appleEvent the best way to do this?
I'm actually trying to get EOS Utility (Canon Camera Software) to use my app as a linked app to open newly downloaded camera files. I only need the filename. If I use an on appleEvent it gives me the path when dropping an image on the standalone icon manually, or when associating the file from the finder and double clicking, but EOS Utility gives me an error "The application can't be launched" So I'm missing something in communicating through apple events somehow. Here's what I've been playing with. Is there another way to do something like this?
Thanks

on appleEvent pClass, pEventID, pSender
if pClass is "aevt" then
request appleEvent data
put it into tFilename
put tfilename into field "Field1"
if pEventID is "odoc" then
put tfilename after field "display"
end if
end if
pass appleEvent
end appleEvent

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Associated File Launching a Standalone or Handling Associated File Input

Post by FourthWorld » Fri Jan 18, 2019 11:09 pm

Are you building the Mac app on a Mac, or on Windows and copying it over?

If the latter, you may need to set the executable bit of the executable within the bundle.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

reflectedpixel
Posts: 6
Joined: Thu Jan 17, 2019 7:37 pm

Re: Associated File Launching a Standalone or Handling Associated File Input

Post by reflectedpixel » Sat Jan 19, 2019 1:29 pm

Thanks!
I'm building the mac on a mac and the windows on windows as I couldn't get it to launch otherwise. I have just figured out what makes it work. For some reason I have to do something with the pSender. I added this line to the start of the apple event handler and it all works. I'm not doing anything with the field. I was just trying to see what info was being passed.
put pClass & " "& pEventID & " " & pSender into field "pClass"
So now I'm moving along in my project.
Thanks for your great help
Jon

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Associated File Launching a Standalone or Handling Associated File Input

Post by FourthWorld » Sun Jan 20, 2019 12:30 am

Glad that worked out. Keep us posted if there's anything else we can help with.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”