In my application I need to take a picture of a hand-written signature. Similar to what Preview does when signing a PDF on a Mac. I can do that with an Automator app plus an Apple Script. But when I copy the Automator App from the Resources Folder to Application Support folder, the Automator app can not be opened. If I do this file copy manually I can make it work. The application is Sandboxed to be distributed in the Apple Store.
I have a module for this (using the iSight Camera). I can post it in several hours when I get back to my computer.
That would be great! Thanks
for Mac? You can use AVFoundation classes in MBS Plugin.
I own Barcode and Cocoa plugins licenses not AVFoundation but when using the examples on the AVFoundation folder I get this error: Can´t find a type with this name - CALayerMBS
CALayerMBS is in Leopard plugin.
You also probably need Cocoa plugins and MacOSX plugins.
Jason could you please kindly post the module you mentioned? Thanks
Sorry its been a busy day and I’m just getting to it now. Here it is:
You will need the blocks plugin from @Joe Ranieri located here for everything to work: https://forum.xojo.com/conversation/post/24713
Disclaimer: One thing to note is that this solution will not be fully supported by Xojo because it uses some pragmas to allow an async operation to occur and execute Xojo code on another thread. ANY method that is called by the callback or subsequent methods MUST have the following pragmas at the top to prevent a crash, although I recommend that you do as little as possible in the callback and just store the picture object to be used later somewhere else when you are back on the main thread:
#Pragma StackOverflowChecking false
Good luck, let me know if you have questions and I will do my to answer them.
Don’t forget to make sure your entitlements contain the key required for the camera.
If you use App Wrapper, it’s under the hardware section on the “Capabilities” tab.
Depending on what your Apple Script is targeting, you may be able to use it still, you’ll need to use special code to execute Apple Script once the application is Sandboxed (and again you’ll need the correct entitlements). Both MBS and my own Sandbox Kit have a Sandbox safe Apple Script class.
Although in all honesty, if you can take the picture via APIs, you’re more likely to get approval from the App Store reviewers (they’ve very sensitive when it comes to Apple Script).
Last resort is using this tool: http://iharder.sourceforge.net/current/macosx/imagesnap/
Include it in your application package and call it with a Shell session.
[quote=213646:@Massimo Valle]Last resort is using this tool: http://iharder.sourceforge.net/current/macosx/imagesnap/
Include it in your application package and call it with a Shell session.[/quote]
For this to run in a Sandboxed application, the helper application will need to be Sandboxed also and the OP will need to use NSTask to execute the Sandboxed helper.
Last resort, I said.
But the tool is available is source, so it may be sandboxed eventually…
I wasn’t saying it couldn’t be done, App Wrapper can help with Sandboxing the helper tool (although some console apps really don’t behave very well once Sandboxed). It’s just that the OP will need to do this in order to use it in a Sandboxed app.
Sorry if it seemed like I was saying it couldn’t be done. Just trying to add what will need to be done in order to use that tool.
Jason, I was trying your example application but it does not seem to activate the camera. It just keep for a couple of seconds Launching Application… and then stops. No green light on camera, no flash, no photo. I previously installed the blocks plugin in xojo’s plugins folder.
Please re-download from here: https://www.dropbox.com/s/79ajg4szh7w0p2k/iSightCamera%202.0.xojo_binary_project?dl=0
The problem was because of a compiler change from a few releases ago and a bad constant (I hadn’t touched the code in a while). Everything should work for you now since it works for me on 10.10.4.
This time camera was activated, window1 launched with a black backdrop but no picture was taken
I am on OS X 10.10.5 and Xojo 2015 r2.3
Hmm, I see what you mean. Its actually not black, the image is just very dark (If you turn on a bright light you will be able to see it). I decided to rip out some classes from iOSKit to do this and move them to Desktop. With almost the exact same code as the image capture example view in iOSKit I was able to make the desktop version work. Check it out here:
This solution is no doubt hitting a small nail with a very large sledge hammer, but since it works I don’t want to spend unnecessary time trying to remove dependencies between unneeded classes since the compiler does that already.
For me it works (version 1 and 2 - with my USB Webcam)
OS X 10.10.5 , Xojo 2015 R1