I am writing an Add in for a Desktop Application. I do not have the access to code the Desktop app but I need to capture all windows that are related to that from within my Add in. Anything not related to app should not be captured. All windows might not be the new processes. Any idea How can i achieve this?
You could try to do the following:
Identify the desktop app's process id and any child processed it may have spawned
Build a list of all windows that belong to the process id(s) identified previously (try #Konstantin Spirin's proposed solution)
Do a screenshot of each of the windows (try out #Maurice Flanagan's solution)
Related
I'm new in programming with .Net and C# and, as said in the title, I have a WPF app which is accessible in a system tray icon and I want to run it a windows service.
Typically, I want an output like it was described in an answer provided in a discussion here.
If you want it in the system tray I think what you'll have to do is make it a Windows service. I've only written 1 Windows Service and that was years ago, but I believe that's what you'll have to do. If I'm correct about writing a Windows service, then what I would suggest you do is create a new Visual Studio solution and add two projects to it. One would be a DLL which would run as a Windows service. The second project would be a WPF project that will be your UI the user interacts with. Then you'll have to use some messaging system to communicate between the two. For the action messages that would mimic what Outlook does, I've used some WPF toast messages to accomplish that. If you Bing/Google "WPF toast popup" you'll get lots of results.
I have many searched in Internet and find some helpful answers like:
URL1
You can't, not directly, because the windows service will necessarily start when the machine does, not when a user logs in. The service will also be running in a different context, likely as a different user. What you can do is to write a separate system tray based "controller" that interacts with the service.
URL2
It needs some effort to achieve. Well, just two hints: 1) use static property System.Environment.UserInteractive to detect in which mode your application is running, see http://msdn.microsoft.com/en-us/library/system.environment.userinteractive.aspx; 2) get rid of app.xaml, because it will force starting WPF Application in all cases; instead, create and run and instance of System.Windows.Application (or better, a specially derived class) explicitly and only for interactive mode, see http://msdn.microsoft.com/en-us/library/system.windows.application.aspx.
And, I could not apply their instructions.
Thanks advance!
I have two applications. One is the main application and the other is the updater.
A user launches with the updater - if an update is available it will download and extract, otherwise it will just launch the main application. I used two applications for this so that I am able to overwrite the main applcation.
The issue is that the users have pinned the "Launcher" application on their taskbar, but when the main application launches it is not grouped under that icon and very confusing for them.
Is there any way around this?
You should be able to do that using Windows API Code Pack.
You need to use Microsoft.WindowsAPICodePack.Taskbar namespace from the Microsoft.WindowsAPICodePack.Shell assembly.
Call TaskbarManager.Instance.SetApplicationIdForSpecificWindow( window, string appId ); method. You can specify either an IntPtr windows handle if you're using WinForms, or a Window instance if you're using WPF.
Do this step in both your processes immediately after launch, and specify the same appId for both.
you can refer [ How to group my apps in windows taskbar? ] of George's answer,
by forcefully make two process share the same APP_ID(string)
simply by calling shell32!SetCurrentProcessExplicitAppUserModelID at each process's main()
It was already mentioned to set the Application user Model ID.
But then you still have the problem that when the Application is pinned, it will not pin to the Launcher. But there is also a solution for this, that the Launcher/Updater is pinned instead of the Application: Pinning to the taskbar a "chained process"
I need to know how can I create a registry that allow the Silverlight applications access to camera and mic.
Scenario:
I have a Silverlight application that start the WebCam, before it works it shows a Silverlight dialog asking if the user allows the application to access it.
Finally I'm creating a desktop app that loads the Silverlight application in a web browser. I want my application desktop to creates a registry or something like that to allow this access and stopping to show the Silverlight dialog.
Exists some solution to this?? If yes, how can I do this?
For someone who has the same issue here is the solution:
https://stackoverflow.com/a/17829842/2882534
Just create a subkey named whit your Url plus port(ex: http://localhost:54895) at the HKEY_CURRENT_USER\Software\AppDataLow\Software\Microsoft\Silverlight\Permissions
After that, create a registry named WebcamAndMicrophone with DWORD and value 11.
Shazan! The silverlight dialog is not more necessary.
Tutorial to manipulate registrys:
http://www.codeproject.com/Articles/4808/All-you-wanted-to-know-about-the-Registry-with-C-P
This is based on C#. I am having a classlibrary in which I would like to know specifically if its being called from a windows based application
I searched a lot but all I found was code to know if it was called from a Console application.
I only want to know if its called from a windows based application or not
Please Help
If you want to know whether the application is running as a service or system app and thus cannot display a dialogue, test the state of Environment.UserInteractive.
There is no easy way to determine if the application is a windows or cmd-based application. For example, I might build a winforms-based application that doesn't create a window and instead runs as command-line style application by not opening a window.
Two (not necessarily reliable) ways of testing if it's a windows-based app would be to test Application.OpenForms (if it contains forms, then it's a windows app) or Environment.GetCommandLineArgs() (if 0 args, assume it's a windows app).
If you absolutely need to know whether the app is a console or windows one, then you need to step out of the world of managed code and start delving into the exe file using unmanaged C++ code. There is just one byte difference between the two in the PE header of the exe file: Subsystem is set to 2 for a windows app and 3 for a cmd app. See http://msdn.microsoft.com/en-us/library/ms809762.aspx and http://support.microsoft.com/kb/90493/en-us for details if you really want to do this.
I need to write a .NET application that captures screenshots of various web pages periodically. The application needs to run as a windows service in unattended mode - when there is no user session or when the workstation is locked. A situation similar to: (Screenshot of process under Windows Service), only, I need to do this on web pages rather than processes.
When I try to use PrintWindow API, I am able to capture inactive or hidden windows, but get a black image when the workstation is locked. Tried this approach (www.devnewsgroups.net/group/microsoft.public.dotnet.framework.windowsforms/topic34231.aspx) but doesn't work.
I know this is possible since there are apps like WebShot (www.websitescreenshots.com) that are able to do it - capture screenshots of web pages even when the workstation is locked or when it runs as a service.
What am I missing? How do I get this to work?
Thanks much for your time.
Edit: More on my approach - I'm using the .NET WebBrowser control created programmatically. I load the webpage in the browser control and capture the image from it using the PrintWindow API. This I'm able to do whether the control is visible or not, but it trips me up when the workstation is locked.
BrowserShots (http://browsershots.org/ http://browsershots.org/) is an open source application that seems to have similar goals to you - they may already have solved your problem. Unfortunately their site seems a bit broken at present.
Since you are only rendering websites and not getting screenshots of different programs you could try WebBrowser.DrawToBitmap.
That way you would wouldn't have to worry about login state
http://thepursuitofalife.com/the-missing-drawtobitmap-function-in-the-net-webbrowser-class/