Posts Tagged ‘c#’

Make Pomodoro timer open in tray

Wednesday, September 10th, 2014

Cold day outside. Got into kinda hackish mood. Started my laptop and seen that annoying window again. Let me explain. I run a program called Pomodoro timer on Startup. If you don’t know it, behold: Pomodoro Technique. But back to the Pomodoro timer issue. I hate how the “Settings” window is showing up every time I boot. I want it to start in tray. Can I make it start in tray?

Get the code

The sources are free on GitHub. If you have console (e.g. Cygwin) with working subversion so you simply run:

svn checkout svn://svn.code.sf.net/p/pomodorotimer/code/trunk pomodorotimer-code

to checkout the repository into pomodorotimer-code directory. If or you don’t use console you can use TortoiseSVN. Then go to the directory you just created.

You can see some .cs and .csproj files. That just screams C# and some .NET Forms app. Let’s look for the Main method:

grep -iR main *

It’s in Program.cs

Do the job

I just want the program to open in tray every time, that all. I don’t need to see settings window unless I manually open it. In .NET Forms you can hide window (form) by simply calling the form.Hide() method. So in the Program.cs, replace this line:

Application.Run(new SettingsForm());

with this:

SettingsForm form = new SettingsForm();
form.Hide();
Application.Run();

That’s it. Compile:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe Program.csproj

Now you can find your brand new bin/Debug/Program.exe. Simply copy it into Program Files or wherever you keep your Pomodoro program.

Howgh