Process[] processes = Process.GetProcessesByName("chrome");
string name = processes.MainWindowTitle;
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static IntPtr FindWindow(string caption)
{
return FindWindow(null, caption);
}
if (FindWindow("MemoryHackers - MH - Google Chrome") == IntPtr.Zero)
{
MessageBox.Show("Site Açık Değil");
}
else
{
Form2 f2 = new Form2();
this.hide();
f2.Show();
}
oradaki string name zaten chrome'de aktif olan title'ı çekiyoBu chrome acik olursa ben chrome icindeki site acik olursa istiyorum
if ( name == "aradağın title")
{
//eğer istediğin title açık ise.
} else {
//eğer istediğin title açık değilse.
}
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
var browserList = new List<string> { "chrome", "opera" };
var browserPads = new List<string> { " - Google Chrome", " - Opera" };
var title = "MemoryHackers - MH";
var isValid = browserList.Any(x => Process.GetProcessesByName(x).Where(y => y.MainWindowTitle == title + browserPads[browserList.IndexOf(x)]).Any());
if (!isValid)
//Sayfa bulunamadi
else
{
this.Hide();
Application.Run(new Form2());
}
Mainwindowstitle yazarken hata veriyor
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading;
using System.Linq;
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?