How to make shortcuts to existing apps (WP7) - c#

I'm developing an app that shows the time, local weather and stuff like that..
The problem I have.. is I can't for the life of me find a way to create a shorcut to apps..
I'm trying to make shortcuts to launch existing apss like calculator, marketplace, whatsapp, etc.
Is this possible using button like:
private void button1_Click(object sender, RoutedEventArgs e)
{
}
and add content inside the brackets..??
I'm sort of a newbie so don't go all crazy on me.. :-)

Sorry to say, but this generally isn't going to be possible under the current (and probably future) versions of the OS. Apps run in a sandboxed environment, and aren't supposed to have access to those kind of things.
You can launch to some of the inbuilt tasks, such as Marketplace:
MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
marketplaceSearchTask.SearchTerms = "games";
marketplaceSearchTask.Show();
But the number of tasks available are very limited.

Related

Is there a way to link apps in UWP?

At the moment I am creating an app to simulate simple mechanical motion in UWP. Instead of creating them all in one blank app I have created multiple different apps for the different types of simulation, eg: single particle, connected particles, pulleys etc... I was wondering if there was a way in which I could have a menu and then when a specific button is clicked the app associated with that button is opened, for example:
private void OpenSingleParticle_Click(object sender, RoutedEventArgs e)
{
//open single particle app
}
Thanks for any help that you can offer
Matt
You need to register app to handle custom URI, then you can call this app using launch app from uri. Take a look at msdn articles:
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/handle-uri-activation
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/launch-app-with-uri
Moreover you can even launch other apps for result as it's possible in Android.

Remove share screenshot option - DataTransferManager

In windows 8.1 apps, while invoking the share UI using
Windows.ApplicationModel.DataTransfer.DataTransferManager.ShowShareUI();
we get an option to share the screenshot of the current app by default. Is there a way to remove this feature?
The data I am passing from the app to be shared is a URL.
private void DataTransferManager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
{
args.Request.Data.SetWebLink(new Uri(myUrl));
}
When the share pane appears, user is presented with an option to share the screen shot also. The scenario is explained in this link
I tried setting ApplicationView.IsScreenCaptureEnabled to false. It still listed "share screenshot". But when tried to share, shared an empty black screen. Can I do something to remove that option from share pane?
No, all the apps that I know of, have this option listed, so I would say this is a system built-in option, that you cannot remove in your app code.

Go back to start (windows phone 8) [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Windows Phone 7 close application
How do I programmatically close a WP7 application?
You can always call an exit by doing this at your landing page use this code on click of your application back button:
if (NavigationService.CanGoBack)
{
while (NavigationService.RemoveBackEntry() != null)
{
NavigationService.RemoveBackEntry();
}
}
This will remove back entries from the stack, and you will press a back button it will close the application without any exception.
Acknowledging known solutions to provide "Exit" buttons, currently I do not see a compelling reason to implement an "exit" from a WP7 application.
The platform is fully capable of managing closure of apps. The more apps don't provide an exit, the quicker users will become accustomed to not thinking about app house keeping, and let the platform manage it.
The user will just navigate their device using start, back, etc.
If the user wants out of the current app to go do something else quickly - easy - they just hit start.
.Exit(), whilst available for xna, really isn't required anymore either. There was a cert requirement during CTP that games had to provide an exit button. This is now gone.
Non game apps never had the need to implement this.
The more this topic's discussed (and it really has been given a good run around the block), the more the indicators to me suggest there is no need to code an exit.
It should also be mentioned the app cert reqts are specific that apps should not have unhandled exceptions.
There isn't really a good way to do it. There is a nice explanation/overview of your options here.
For short, if this is a Silverlight app (not XNA), it is not supported. You can simply throw an unhandled exception, and the app will quit. I wouldn't recommend that, it seems like a hack and a rather crude way of doing it.
Here is a way to make it look nicer, but at the end of the day it still throws an exception. I don't know if the application certification process looks at whether you are throwing unhandled exceptions, but I guess it could be an issue.
Simplest thing to do is simulate back from your root/home page. I'm guessing this is exactly what apps (those which have quit button) like Fruit Ninja do.
if ( NavigationService.CanGoBack )
{
NavigationService.GoBack();
}
Btw, above snippet works for a silverlight app.
Another way to exit the application is calling the exit function of the Game class of Microsoft Xna framework.
For example:
Microsoft.Xna.Framework.Game game = new Microsoft.Xna.Framework.Game();
game.Exit();
private void exitBUtton_ONclick(object sender, RoutedEventArgs e)
{
throw new Exception("ExitAppException");
}

How to get calculator amount on text box

I have a application in which i want to open a calculator on a button click and once the operation are performed on calculator and calculator is closed, I want that value back to my text box.
How can I achieve this functionality.
private void btnDollarTransferHelp_Click(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = System.Diagnostics.Process.Start("calc.exe");
}
I am using C# 4.0 and its a window based application.
Regards and Thanks
You may use the Microsoft Script Control to implement the calculator functionality in your C# app. The control has a simple Eval() method to evaluate expressions that may range from simple "2+2" to VBScript commands. More information here:
http://msdn.microsoft.com/en-us/library/aa227637(v=vs.60).aspx
It is indeed simpler to implement a calculator in your app: reading the content of another's process window is not trivial! And being notified when the calculator is "about to close" is even harder.
It involves, for sure, widows API (FindMessage/SendMessage) (see for example https://stackoverflow.com/a/360247/863564), probably P/Invoke, probably even hooking calc.exe (the technique used by Spy++ -- you need it to capture the WM_CLOSE message - see here what happens when you are closing a window)
(You need to capture WM_CLOSE, because it is the latest sensible moment to grab the result from the control on the window)
So, the alternative: a great one is scriptcs, but it may be well too much! A quick search revealed
some
great
projects
Either way, have fun!
you could use an existing library e.g. http://nclac.codeplex.com to provide calculation within your application.

Faking window focus (sandbox?, App-V?)

I'm trying to figure out how I'd be able to essentially trick a window into thinking it has focus. What I've found out through some searching, is that I'd need some sort of sandbox to accomplish this. An intermediate layer between the OS and the window.
I'd appreciate some assistance in pointing me in the right direction of how I'd be able to accomplish this through C# (with pinvoke, etc, if necessary). To essentially launch another executable from the C# program, and set it up in some fashion to be on a faux desktop, with constant window focus. But still be able to interact with the window as normal (like a window wrapper, if you will, that can lose focus all it wants, but the window contained within will never think it's out of focus).
I'm sure this is quite an undertaking (though, maybe it won't be, perhaps someone knows an elegant solution to this), but I know it's possible, as I've seen something similar done in a commercial product. (I'm trying to emulate one of the behaviors of this sandbox product).
First of all, try calling an activation event:
private void Form1_Activated(object sender, EventArgs e)
{
//Code
}
Then out of any functions, declare an eventarg:
private EventArgs ev;
Finally, when you want to fake a focus, call the activated function:
Form1_Activated(this, ev);
Hope that help!
You could try injecting a WM_ACTIVATE message into the target windows message queue. This may trick it into thinking it has focus, even when it does not. It really depends on how the application is checking for focus.

Categories