Remove share screenshot option - DataTransferManager - c#

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.

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.

C# - UWP open new instance of a window when middle-mouse clicking on the app's taskbar icon

Perhaps this is a silly question, however I've searched around quite a bit and not been able to find an answer related to UWP apps.
How can one trigger an instance of their app's main window to open when middle-mouse clicking the taskbar icon? Edge can do it, so I'm assuming it's possible, just not documented or frequently done.
Thanks in advance!
By default, UWP apps support only one view (window) per app at one time so when user tries to open an UWP app that is already running, system switches to the running app rather then creating a new instance.
So you have to support multiple views in your app in order to create new instance when middle-clicked on taskbar.
You can find some documentation about multiple views in UWP app on MSDN, for example in this article.

How to make shortcuts to existing apps (WP7)

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.

How can I set a video call to start in full screen programmatically? (Lync SDK)

I am trying to find a way to start my video conferencing in full screen view, I'm writing a WPF application using Lync SDK.
I've been looking over Lync SDK and practicing the examples on MSDN for a week now, but I did not see a property or a method to set the view to full screen in video call. Intellisense didn't helped me either.
So how can I set the video view in full screen? Also should I do it after I dock it?
Here is the code I use for calling someone;
Dictionary<AutomationModalitySettings, object> _ModalitySettings =
new Dictionary<AutomationModalitySettings, object>();
List<string> inviteeList = new List<string>();
inviteeList.Add("elise#contoso.com");
IAsyncResult Iar = _automation.BeginStartConversation(
AutomationModalities.Video
, inviteeList
, _ModalitySettings
, callbackVideo
, null);
_automation.EndStartConversation(Iar);
And here is the docking method I call from my delegate on new conversation event (Both codes are just slightly edited codes from MSDN);
private void DockTheConversation(string ConversationId)
{
_LyncModel.WindowPanelHandle(ConversationId,
myFormsHost.Child.Handle.ToInt32());
}
I can access the ConversationManager, ConversationWindow, Conversation(the one that is being docked), LyncClient and Automation. But I couldn't found any related methods or properties in any.
ConversationWindow.IsFullScreen property is readonly so that doesn't work either. And I don't know how can I edit;
Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.FullScreenMode
Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.WindowState
properties, or whether if they would work or not.
I'm already running my WPF application on full screen (WindowState, WindowStyle) but I also want the hosted Lync ConversationWindow to fill the screen, like when you push the button on the top right.
Any help is appreciated! Thanks!
I'm pretty sure you won't be able to do this using the Lync SDK. If you were running your app with Lync in UI suppressed mode, you could get access to the underlying VideoWindow so you would be free to place it anywhere on the screen, but that only works in UI supressed mode.
I'm thinking that it would probably be possible using Win32 calls. You should be able to determine the inividual windows that make up the conversation window, find the Video window and then use SetParent to remove this from the parent conversation window. You could then use e.g the Win32 ShowWindow to maximise the window.
I've not tried this, but i'm fairly sure it would work given the right Win32 calls. If you're not familiar with Win32, then PInvoke.net is a great Win32 reference, and might be a good place to start.
If you want to create full screen, You should write property changed of conversation window as the following code:
InputSimulator.SimulateKeyPress(VirtualKeyCode.F5);

How can a Windows Service start a process when a Timer event is raised?

I have created a Windows Service with Timer and in firing event of timer.Elapsed I am creating a process (System.Diagnostics.Process.Start(exe path)) at interval of 5 seconds. But this process does not get created on the firing of an event.
Is there any other way of doing this?
Thanks in advance.
private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Process pr = new Process();
pr.StartInfo.FileName = #"C:\Program Files\Messenger\msmsgs.exe";
pr.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
pr.StartInfo.CreateNoWindow = false;
pr.Start();
}
You're adding descriptions of the problem in the comments as you go along that would have been helpful to know at the outset. The reason that you can see the process has started but no window ever gets opened is because of security model changes that were made to Windows Services under Windows Vista and later. You haven't mentioned it specifically yet, but I have a strong suspicion that you're trying to run this under one of those operating systems. The real issue is not starting a process, it's showing a UI.
What you're trying to accomplish is called an "Interactive Service", which is one that is allowed to interact directly with the user and the desktop (i.e., show a window or dialog).If you're using Windows XP (and your service will only ever have to run under Windows XP), you can follow the instructions in that article to enable your service to run in interactive mode, which will allow you to display the Adobe Acrobat application window as you expect. However, as that documentation also indicates, this feature does not work under Windows Vista and later:
Important Services cannot directly interact with a user as of Windows Vista.
Therefore, the techniques mentioned in the section titled Using an Interactive Service
should not be used in new code.
More specifically, in those versions, changes were made to how services and applications are run. Services are now isolated by the system in Session 0, while applications are run in other sessions. This is intended to isolate services from attacks that originate in application code. Hence, no UI shown by a service will ever be visible to any user on the system, including a simple message box. You can read the white paper that explains these changes in more detail here. If you're a more visual person, refer to following diagram illustrating the new model, paying specific attention to the dividing lines:
The upshot is that if you're targeting those versions, or might ever need to target those versions, you can't use this loophole. I say "loophole" because the bottom line, as I mentioned in a comment, is that Windows Services are not intended to be interactive. What you're trying to do here runs contrary to the purpose and design of a service. It wasn't recommended before, and now it flat doesn't work at all. If you need this particular functionality, you should create a different kind of application. Both Windows Forms and WPF are intended for user-mode applications, and both can start processes and open new windows as necessary. I strongly recommend that you convert to this style of application instead.
Since you won't get a process to show UI from the service, I recommend that you run the helper process when the user logs on and start your process from it.
I realize I'm a little late to this party. But since this question came up in my search for a solution, I'll provide an answer to the OP's question.
You can start a program from a service using CreateProcessAsUser, using the token of the logged-on user. MSDN provides a nice sample app demonstrating this; look for CSCreateProcessAsUserFromService:
https://code.msdn.microsoft.com/windowsapps/CSCreateProcessAsUserFromSe-b682134e#content
I tried it, and it works. I'm able to create a new process for my existing .NET application from a service, and it works just fine. I set the service Log On properties to Local System account, but left the "Allow service to interact with desktop" unchecked. My application is created when the timer expires, and works just like it does when started normally, including GUI presentation and user interaction.
Whether this is an improper or undesirable thing to do is another discussion. But it is indeed possible, and really not all that difficult.
There is a kind of work around, but i would advice to only do this if YOU ARE SURE TO ACCEPT THE SECURITY ISSUE!
This could be the Answer to your Problem:
CreateProcessAsUser.
The sample demonstrates how to create/launch a process interactively in the session of the logged-on user from a service application written in C#.Net.

Categories