How to start Firefox in hidden mode from C#? - c#

how can I start Firefox as hidden application in my C# application?

The ProcessStartInfo.CreateNoWindow property only applies to console mode apps. A regular GUI app requires a window to be functional. It is supposed to observe the ProcessStartInfo.WindowStyle property but not all GUI apps are well behaved, particularly when you ask for ProcessWindowStyle.Hidden. Which presents a user interface problem, can't get the window activated when it is hidden.
A minimized window is usually the best you can get, with a taskbar button.

I think. You are asking how to run a program without displaying in Task manager. ?? if its true, then You Can Set ShowInTaskBar Property to false of that Form. if not then can u explain what "Hidden Mode" means ? so that it is easy to solve the problem
Form.ShowInTaskBar=false;
http://msdn.microsoft.com/en-us/library/system.windows.forms.form.showintaskbar.aspx

Related

Activate a window from other process which has ShowInTaskbar = false

I was using this single instance implementation:
http://sanity-free.org/143/csharp_dotnet_single_instance_application.html
However, It stopped working when I added a NotifyIcon and I set ShowInTaskbar = false when the window is minimized. In this state the windows doesn't get the broadcast event.
So I changed the code to find the window using EnumWindows and matching the window title, which is a flimsy solution. I tried SetProp, GetProp, but the window handled is recreated when the value in ShowInTaskbar changes. I'm in .net core so I can't use the visual basic class WindowsFormsApplicationBase.
Is there a better good simple solution for activating the first window? Hopefully without sockets, pipes and stuff like that?

Debugging WPF window is in the way blocking the editor

Whenever I debug a WPF program or any windows program in Visual Studio at the initialization code, using step into feature, the wpf window always goes on top of the editor and I cant see whats behind it, this is of course during the process of initializing the main app which becomes unresponsive thus not able to move the idling window out of the way so I can see what I am debugging.
Is there a way around this? This might be a silly question if there is an obvious solution I apologize in advanced. Hopefully the question make sense.
Update: Here is the screen shot of what I'm dealing with.
As you can see in here "Ernanis Renamer" window blocks the view, and if I try to drag it and move it away, It wont let me as it is suspended and need to continue until all component is displayed.
**Update:** Here is a video of a simple annoyance that I keep getting every time I try to debug during initialization.
<div style="position:relative;height:0;padding-bottom:56.25%"><iframe src="https://www.youtube.com/embed/RmbMGqcMtiU?ecver=2" width="640" height="360" frameborder="0" style="position:absolute;width:100%;height:100%;left:0" allowfullscreen></iframe></div>
The "topmost" behaviour might be being added in a non-obvious manner (e.g. a window style, or some quirky codebehind), which is why you can't find it.
To definitively answer the question as to whether your "Window" is being made to be "Always On Top" / "TopMost", download Windows Detective.
http://windowdetective.sourceforge.net/
Install it, and run it with "Administration Rights".
"Pick"/"Find" your application window (make sure it is the outermost/main frame window) while it is running, and then choose "Edit Properties" (as it shows the flag clearer).
You then have various ways to "handle" the situation your errant window.
1) Use Window Detective to turn ON the Always on Top for Visual Studio - so it can come before your app window
2) Use Window Detective to turn OFF the Always on Top for your app window
3) Put some code into your app (after the window intialization but before where you are debugging/tracing) so it turns OFF topmost IF you are attached/running it from a debugger e.g.
if (System.Diagnostics.Debugger.IsAttached)
{
this.Topmost = false;
}
You then won't forget to "keep" the "topmost" behaviour if that is "part" of your design.

getting correct window style as configured by windows shortcut

When you create a shortcut in windows to an application, in its properties you can define under "Run:" the initial window state (Minimized / Maximized / Normal).
C# applications do not, apparently, start up their forms according to this configuration out-of-the-box, so I figured I need to get this information somehow and write a code that does that programmatically on start up.
I cannot find a way to get this information in my c# application.
I have tried:
Process.GetCurrentProcess().StartInfo.WindowStyle
But for some reason this is always "Normal" regardless of the configuration in the file shortcut.
Does anyone have any idea how to come around this?
Just made a quick test and it does work out-of-the-box only if your main form is set to start as Normal window state. If you choose Minimized or Maximized it will override the shortcut settings.
In case your main form is set as Normal you can detect the actual state using such code:
FormWindowState actualState = Application.OpenForms["Form1"].WindowState;
if (actualState != FormWindowState.Normal)
{
//probably launched via shortcut overriding the state, handle.
}

C# Application Not starting minimizied

I've built a C# app that I want to start just in the notification area. The icon appears when it is run, and it does not appear in the task bar (due to ShowInTaskbar = false & WindowState = Minimized). However when it first runs I can still alt-tab to it. Is there anyway to prevent this behaviour? Or have I missed a setting somewhere?
Thanks,
Psy
What you are seeing is correct behaviour, Alt+Tab will restore minimized windows.
It looks like you want a tray application, but be a bit more specific.
Take a look at this question.

How to bring Windows Taskbar on foreground while running maximized?

I've got an app running maximized in a borderless window and need access to the windows taskbar on a given user event.
How would I bring the taskbar in foreground in .NET while running maximized?
Also an hint with regards to how to make it reliably go away wouldn't hurt! :)
EDIT: please note that I don't want the taskbar always on, I want it popping up on foreground just on a given user event, and then I want it to go away at will!
Um, don't run fullscreen? Maybe run maximized? Fullscreen app with taskbar is not a standard UI pattern.
What you could try doing is run maximized without the UI chrome (borderless window). Would let the taskbar in on the fun while still looking like a fullscreen app.
Interestingly enough, your desired solution seems to be the problem that caused this question. See my answer there. You may have to experiment a little with setting the FormBorderStyle and WindowState properties in a certain order, and try to minimize disturbance for the user.

Categories

Resources