Page 1 of 1
Launch eye tribe server from application
Posted:
14 Apr 2015, 14:49
by sreedev
Hello,
I started out with the calibration example provided at Github. But it seems that I need to launch the eye tribe server application separately before my application can make use of the eye tracker. Is there any way of launching the server from my application?
Thanks.
Re: Launch eye tribe server from application
Posted:
14 Apr 2015, 16:02
by Martin
Certainly possible. Here's one way of doing it.
First, we determine if the server is running already
- Code: Select all
private static bool IsServerProcessRunning()
{
try
{
foreach(Process p in Process.GetProcesses())
{
if(p.ProcessName.ToLower() == "eyetribe")
return true;
}
}
catch (Exception)
{ }
return false;
}
If the server is not running we locate the executable by the method GetServerExecutablePath() and then start it:
- Code: Select all
private static void StartServerProcess()
{
ProcessStartInfo psi = new ProcessStartInfo();
psi.WindowStyle = ProcessWindowStyle.Minimized;
psi.FileName = GetServerExecutablePath();
if (psi.FileName == string.Empty || File.Exists(psi.FileName) == false)
return;
Process processServer = new Process();
processServer.StartInfo = psi;
processServer.Start();
Thread.Sleep(3000); // wait for it to spin up
}
- Code: Select all
private static string GetServerExecutablePath()
{
// check default paths
const string x86 = "C:\\Program Files (x86)\\EyeTribe\\Server\\EyeTribe.exe";
if (File.Exists(x86))
return x86;
const string x64 = "C:\\Program Files\\EyeTribe\\Server\\EyeTribe.exe";
if (File.Exists(x64))
return x64;
// Still not found, let user select file
OpenFileDialog dlg = new OpenFileDialog();
dlg.DefaultExt = ".exe";
dlg.Title = "Please select the Eye Tribe server executable";
dlg.Filter = "Executable Files (*.exe)|*.exe";
if (dlg.ShowDialog() == true)
return dlg.FileName;
return string.Empty;
}
Hope this helps
Re: Launch eye tribe server from application
Posted:
14 Apr 2015, 18:29
by sreedev
I haven't tried the code yet. But it seems to me that what you suggested launches the already installed server. What I am actually looking for is not to launch the already existing server but to have it within my application and run in background without the command line window popping up.
Re: Launch eye tribe server from application
Posted:
15 Apr 2015, 00:22
by Martin
No can do, it's not a DLL. It needs to run as it's own process (for many reasons). Perhaps minimize the application window programmatically?
What are you trying to accomplish?
Re: Launch eye tribe server from application
Posted:
15 Apr 2015, 20:37
by sreedev
Thanks for your reply. I solved the issue by setting the window style to hidden.