Is it possible to spawn a child process from Windows 8 Metro Style App? - windows-8

We'd like to use couple of legacy utilities in our Metro style application. It'd be waste of time trying to recompile and wrap them into WinRT components as they have very simple interfaces.
Is it possible to spawn a child process (which will stay within sandbox) from Metro Style app? Metro style IE seems be able to do it, however as we all know it's "special".

You should be able to package your process as an out-of-proc COM object and use CoCreateInstanceFromApp to launch it.
There are likely to be some challenges related to getting the proxy/stubs for your COM interfaces to work - the low level C++/IDL authoring experience isn't well documented currently so building the proxy/stubs will be difficult, but it absolutely is possible to do.

There is no API in metro like SellExecute or createprocess so you cannot launch other programs as is.
You can however use protocol Handlers. A metro app can register a protocol handler, or use existing handlers. Think of http:// or mail:// that launches the default app registered for that handler. You can use custom handler if they are not yet registered ...

CoCreateInstanceFromApp() only allows you to create in process COM classes that are packaged with your app. You need to write an out of process WinRT EXE server. Please see this sample:
http://code.msdn.microsoft.com/windowsapps/Hybrid-app-Exe-server-79bc4bca

Related

make an AIR desktop application the default web browser

I would like to make my AIR desktop browser be the default web browser on a system, how can I go about and do this ?
I would also like to know how I can retrieve the link that has been clicked (in an email for example) to interact with the application.
thanks !
As far as I'm aware this is impossible in AIR. You can associate your app with file types using the air-app.xml descriptor or by calling NativeApplication.setAsDefaultApplication() (Read about it here). Opening files after using either of these methods will trigger your application to launch with an InvokeEvent (Read Here). You can read a good tutorial for this here.
However, if I understand correctly, you also want your app to take over any HTTP requests from inside any other app. To do this you have to override the protocol default application, which requires a registry edit and (I believe) that AIR can't do that. You may be able to write an external script in C or Java to do that for you (This might help with that).

Can we package our existing HTML5 JS App for Windows 8

I have read some posts on S/O and also around the web. We are producing a HTML5 JS based web app that runs on the web. We are packaging it up for Google apps, and also for phonegap.
Can we package this app for windows 8? Of course, I appreciate it won't use the windows 8 features. But, will the app run none the less, as it stands. So that we can place it in the store and build out windows 8 features as we move forward.
I appreciate this is a slightly non-concise question, but I guess the real point is what is our quickest route to take our existing HTML 5, CSS, JS App and deploy it in the store and get it working on this platform.
In general, the answer is yes. The transition is not seamless, but you will be able to use a ton, if not all, of the application artifacts in Win8. A good test is if you can run it in IE10, you can run the app as a Win8 app. Again, this is a very broad brush - things you need to worry about are things like all scripts files need to be local (no CDN), changes to web and security contexts, and the fact that Win8 is a horizontal paradigm whereas most web apps are vertical. But in general, you should be able to make the move. Usual caveat - your mileage will vary.
Yes, although not recommended, you can package your existing app for Win8. You'll need to add a few bits of code though. The minimum would be to embed your app's start/init code within WinJS's first promise callback, like so:
args.setPromise(WinJS.UI.processAll().then(function () {
// your init code
}
You'll also need to create a couple of icons for the start screen and an image for your app's launch screen.
It is possible that you'll run into a few issues, like some security related restrictions, where you'll have to modify your code to use some native WinJS functions. This all depends on you app's implementation.
You can also check Microsoft's guidelines for migrating a web app to win8, here: http://msdn.microsoft.com/en-us/library/windows/apps/hh465143

How to do UI Automation of Metro-Style Apps?

I've downloaded and installed the windows 8 consumer preview, and I'd like to figure out how to use the UI Automation API's to get data from metro style applications.
Background: I have a lot of automated tests which use the Microsoft UI Automation API's to interact with applications. The scripts are written in IronRuby against .NET 4
Initially, I'd simply like to check if the start menu is visible (and if so, close it)
According to Microsoft, the normal UI Automation API's should be able to access and control metro style applications, but the problem is, I can't figure out how my code can actually access the UI of metro applications? Our normal way of viewing UI automation data is using UISpy, however when I run UI spy under windows 8 and bring up a metro app, there is no mention of it... it seems like metro apps (including the start screen) are walled off from the desktop.
If I can't find the metro apps in UISpy, how can I find what their automation ID's are, and how could I find them from my automated test scripts?
A few resources on UI automation which works in Metro style apps:
Here is a sample demonstrating it.
Here is a blog post explaining it.
This is a forum thread on the subject.
There is nothing about the app that stops traditional UI automation from working correctly. You may have to get updated tools to view the Metro style apps. Some ship with the Consumer Preview. Look for inspect.exe.
UI Automation tools can automate Metro applications. Check RIATest for example.
Stating from version 6.0 a number of features in RIATest are specifically targeted at Metro style application automation, particularly:
Ability to stay on top of Metro UI to allow you to simultaneously see your Metro application and RIATest IDE and minimize switching from Desktop to Metro screens when automating a Metro application.
Recording of actions performed on native Windows GUI elements (including Metro GUI). The recorder analyses your script code and reuses your variable names to generate cleaner recorded scripts similar to how you would hand-code an automation script.
Seamless workaround for bugs like this in Windows UI Automation implementation in Metro UI.
Disclaimer: I work for Cogitek, the RIATest company.
WinRT (aka "Metro Style") applications run in an sandbox. You cannot pierce the walls between applications, including to Desktop applications. This includes network isolation (you cannot refer back to localhost for example except in a development environment). There are a couple of exceptions to this such as the Share and Search contacts which allow for very specific types of interactions between apps.
It is this sandbox that is preventing UISpy from seeing the executing WinRT application in the background. I'm not sure how UISpy could work around this issue without some kind of development environment exception to the sandbox (similar to the network isolation exception) that isn't available in the consumer preview.
I'm also unaware of any announcements regarding when/if the UI Automation API will be supported for WinRT applications at this time.

How to trigger a share operation with windows 8

Is it possible to trigger the share action from within a metro style app without using the charm bar?
It's not really recommended, but there is an API available.
// javascript
Windows.ApplicationModel.DataTransfer.DataTransferManager.showShareUI();
// or C#
Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
More info located # http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.datatransfer.datatransfermanager.showshareui.aspx
the recommended way is to open a share contract and do it via charm.
one reason to doing so is that if all developers do it via charm. user will know exactly where to find the share feature across all app and it helps to keep the whole windows 8 ecosystem clean

how to load injection lib in mac applications at application start?

I have a dynamic library, I intent to inject in running application & newly launched applications.
I can inject it in running applications with the help of a process running with root user permissions.
Now I am trying that library should get loaded as soon as application is launched. I know one such library capable of doing this called, application enhancer. I am looking for similar behavior.
Does anyone has an Idea how can this be achieved?
Look at SIMBL agent code. It adds a observer to application launch notification and then injects. You can follow the same approach.