using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using SHDocVw;
using System.IO;
namespace WindowsCMD
{
public partial class Form1 : Form
{
public Form1()
{
// Initialize form components
InitializeComponent();
// Set the toolstripstatus label to current time of localhost machine
toolStripStatusLabel1.Text = System.DateTime.Now.ToString();
// Use a timer that will update Time and Date inside toolstripstatus label
timer1.Enabled = true; // enable timer
timer1.Interval = 1000; // set timer to fire every 1000ms = 1s
}
private void toolStripStatusLabel1_Click(object sender, EventArgs e)
{
// disable welcome message if someone click on Clock in toolstripstatus label
MessageBox.Show(“Hello! :)”, “WindowsCMD”);
}
private void button1_Click(object sender, EventArgs e)
{
// SHDocVw (Microsoft Internet Controls) – allow the app to access windows explorer
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows();
// Create a list with opened “Explorer” windows
ArrayList windows = new ArrayList();
string filename;
string directoryPath;
Uri basePathUri;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals(“explorer”))
{
if(ie.LocationURL.Count() == 0)
{
}
else
{
basePathUri = new Uri(ie.LocationURL.ToString());
directoryPath = basePathUri.ToString();
windows.Add(directoryPath.Substring(8));
}
}
else
{
MessageBox.Show(“error”);
}
}
listBox1.DataSource = windows;
}
private void button2_Click(object sender, EventArgs e)
{
string strCmdText;
if(listBox1.Items.Count == 0)
{
strCmdText = @”\”;
}
else
{
strCmdText = listBox1.SelectedItem.ToString();
}
strCmdText = “/K cd ” + strCmdText;
System.Diagnostics.Process.Start(“CMD.exe”, strCmdText);
}
private void timer1_Tick(object sender, EventArgs e)
{
toolStripStatusLabel1.Text = System.DateTime.Now.ToString();
}
}
}