Page 1 of 1

Associated File Launching a Standalone or Handling Associated File Input

Posted: Thu Jan 17, 2019 7:43 pm
by reflectedpixel
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!!

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

Posted: Thu Jan 17, 2019 9:01 pm
by FourthWorld
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

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

Posted: Fri Jan 18, 2019 10:33 pm
by reflectedpixel
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

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

Posted: Fri Jan 18, 2019 11:09 pm
by FourthWorld
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.

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

Posted: Sat Jan 19, 2019 1:29 pm
by reflectedpixel
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

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

Posted: Sun Jan 20, 2019 12:30 am
by FourthWorld
Glad that worked out. Keep us posted if there's anything else we can help with.