2014-05-28 21:47:25 +02:00
|
|
|
|
using Microsoft.Win32;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text.RegularExpressions;
|
2015-02-08 22:51:52 +01:00
|
|
|
|
|
2014-05-28 21:47:25 +02:00
|
|
|
|
using System.Xml;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
2014-05-28 21:47:25 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
namespace DS4Windows
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
|
|
|
|
public partial class WinProgs : Form
|
|
|
|
|
{
|
|
|
|
|
ToolTip tp = new ToolTip();
|
2014-05-30 22:39:39 +02:00
|
|
|
|
ComboBox[] cbs;
|
2014-11-18 22:23:41 +01:00
|
|
|
|
public DS4Form form;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
//C:\ProgramData\Microsoft\Windows\Start Menu\Programs
|
|
|
|
|
string steamgamesdir, origingamesdir;
|
|
|
|
|
protected String m_Profile = Global.appdatapath + "\\Auto Profiles.xml";
|
2014-06-06 22:38:52 +02:00
|
|
|
|
protected XmlDocument m_Xdoc = new XmlDocument();
|
|
|
|
|
List<string> programpaths = new List<string>();
|
|
|
|
|
List<string> lodsf = new List<string>();
|
|
|
|
|
bool appsloaded = false;
|
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
public WinProgs(string[] oc, DS4Form main)
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
form = main;
|
|
|
|
|
cbs = new ComboBox[4] { cBProfile1, cBProfile2, cBProfile3, cBProfile4 };
|
2014-05-30 22:39:39 +02:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
{
|
|
|
|
|
cbs[i].Items.AddRange(oc);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
cbs[i].Items.Add(Properties.Resources.noneProfile);
|
2014-06-06 22:38:52 +02:00
|
|
|
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
2014-05-30 22:39:39 +02:00
|
|
|
|
}
|
2014-05-28 21:47:25 +02:00
|
|
|
|
if (!File.Exists(Global.appdatapath + @"\Auto Profiles.xml"))
|
|
|
|
|
Create();
|
2014-06-06 22:38:52 +02:00
|
|
|
|
LoadP();
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
if (Directory.Exists(@"C:\Program Files (x86)\Steam\steamapps\common"))
|
|
|
|
|
steamgamesdir = @"C:\Program Files (x86)\Steam\steamapps\common";
|
|
|
|
|
else if (Directory.Exists(@"C:\Program Files\Steam\steamapps\common"))
|
|
|
|
|
steamgamesdir = @"C:\Program Files\Steam\steamapps\common";
|
2014-06-09 01:41:36 +02:00
|
|
|
|
else
|
|
|
|
|
cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem);
|
|
|
|
|
|
|
|
|
|
if (Directory.Exists(@"C:\Program Files (x86)\Origin Games"))
|
|
|
|
|
origingamesdir = @"C:\Program Files (x86)\Origin Games";
|
|
|
|
|
else if (Directory.Exists(@"C:\Program Files\Origin Games"))
|
|
|
|
|
origingamesdir = @"C:\Program Files\Origin Games";
|
|
|
|
|
else
|
|
|
|
|
cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem);
|
|
|
|
|
}
|
2014-05-28 21:47:25 +02:00
|
|
|
|
|
|
|
|
|
public bool Create()
|
|
|
|
|
{
|
|
|
|
|
Boolean Saved = true;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
XmlNode Node;
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateXmlDeclaration("1.0", "utf-8", String.Empty);
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateComment(String.Format(" Auto-Profile Configuration Data. {0} ", DateTime.Now));
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateWhitespace("\r\n");
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
Node = m_Xdoc.CreateNode(XmlNodeType.Element, "Programs", "");
|
2014-05-28 21:47:25 +02:00
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
m_Xdoc.Save(m_Profile);
|
|
|
|
|
}
|
|
|
|
|
catch { Saved = false; }
|
|
|
|
|
|
|
|
|
|
return Saved;
|
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
2014-11-18 22:23:41 +01:00
|
|
|
|
public void ShowMainWindow()
|
|
|
|
|
{
|
|
|
|
|
form.Show();
|
2014-11-18 23:07:27 +01:00
|
|
|
|
form.WindowState = FormWindowState.Normal;
|
|
|
|
|
form.Focus();
|
2014-11-18 22:23:41 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
public void LoadP()
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
programpaths.Clear();
|
|
|
|
|
if (!File.Exists(Global.appdatapath + "\\Auto Profiles.xml"))
|
|
|
|
|
return;
|
|
|
|
|
doc.Load(Global.appdatapath + "\\Auto Profiles.xml");
|
|
|
|
|
XmlNodeList programslist = doc.SelectNodes("Programs/Program");
|
|
|
|
|
foreach (XmlNode x in programslist)
|
|
|
|
|
programpaths.Add(x.Attributes["path"].Value);
|
|
|
|
|
foreach (string st in programpaths)
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (File.Exists(st))
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
2014-06-14 21:14:27 +02:00
|
|
|
|
int index = programpaths.IndexOf(st);
|
|
|
|
|
if (string.Empty != st)
|
|
|
|
|
{
|
|
|
|
|
iLIcons.Images.Add(Icon.ExtractAssociatedIcon(st));
|
|
|
|
|
ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(st), index);
|
|
|
|
|
lvi.SubItems.Add(st);
|
|
|
|
|
lvi.Checked = true;
|
|
|
|
|
lvi.ToolTipText = st;
|
|
|
|
|
lVPrograms.Items.Add(lvi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
RemoveP(st, false, false);
|
2014-05-28 21:47:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
}
|
2014-05-28 21:47:25 +02:00
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
|
|
|
|
private void bnLoadSteam_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
2014-05-28 21:47:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
|
|
|
|
private void GetApps(string path)
|
2014-06-06 22:38:52 +02:00
|
|
|
|
{
|
2014-06-09 01:41:36 +02:00
|
|
|
|
lodsf.Clear();
|
|
|
|
|
lodsf.AddRange(Directory.GetFiles(path, "*.exe", SearchOption.AllDirectories));
|
2014-06-06 22:38:52 +02:00
|
|
|
|
appsloaded = true;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void GetShortcuts(string path)
|
|
|
|
|
{
|
|
|
|
|
lodsf.Clear();
|
|
|
|
|
lodsf.AddRange(Directory.GetFiles(path, "*.lnk", SearchOption.AllDirectories));
|
|
|
|
|
lodsf.AddRange(Directory.GetFiles(@"C:\ProgramData\Microsoft\Windows\Start Menu\Programs", "*.lnk", SearchOption.AllDirectories));
|
|
|
|
|
for (int i = 0; i < lodsf.Count; i++)
|
|
|
|
|
lodsf[i] = GetTargetPath(lodsf[i]);
|
|
|
|
|
appsloaded = true;
|
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
|
|
|
|
void appstimer_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (appsloaded)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnAddPrograms.Text = Properties.Resources.AddingToList;
|
2014-06-06 22:38:52 +02:00
|
|
|
|
for (int i = lodsf.Count - 1; i >= 0; i--)
|
|
|
|
|
if (lodsf[i].Contains("etup") || lodsf[i].Contains("dotnet") || lodsf[i].Contains("SETUP")
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|| lodsf[i].Contains("edist") || lodsf[i].Contains("nstall") || String.IsNullOrEmpty(lodsf[i]))
|
2014-06-06 22:38:52 +02:00
|
|
|
|
lodsf.RemoveAt(i);
|
|
|
|
|
for (int i = lodsf.Count - 1; i >= 0; i--)
|
|
|
|
|
for (int j = programpaths.Count - 1; j >= 0; j--)
|
2014-06-13 21:52:25 +02:00
|
|
|
|
if (lodsf[i].ToLower().Replace('/', '\\') == programpaths[j].ToLower().Replace('/', '\\'))
|
2014-06-06 22:38:52 +02:00
|
|
|
|
lodsf.RemoveAt(i);
|
|
|
|
|
foreach (string st in lodsf)
|
|
|
|
|
{
|
2014-06-09 01:41:36 +02:00
|
|
|
|
if (File.Exists(st))
|
|
|
|
|
{
|
|
|
|
|
int index = programpaths.IndexOf(st);
|
|
|
|
|
iLIcons.Images.Add(Icon.ExtractAssociatedIcon(st));
|
|
|
|
|
ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(st), iLIcons.Images.Count + index);
|
|
|
|
|
lvi.SubItems.Add(st);
|
Rest of DS4Windows has been upped to .NET 4.5 (If you have .net 4/already can run DS4Windows, this won't affect you), thanks to this update, you can now...
Add delay to macros from one millisecond to 60 seconds, macros with delays only run once until pressed again. Without delays, the macro can be repeated while held down.
Profiles and settings are now back inside the application folder to help portability. It will remain in appdata as previous versions if DS4Windows is in a admin folder, I may try to add a setting for location saving.
Import profile option will automatically go to the appdata profile folder, auto profiles and settings will automatically copy over.
Option to delete the appdata folder if not in use in the settings tab, this way it helps with cleanup.
Another fix for auto profiles startup bug
Better reading of autoprofile program path names
Now only one instance of DS4Windows is possible, if another DS4Tool or DS4Windows that is not this version is started, this DS4Windows comes back into focus.
UI fixes
2014-06-10 21:45:09 +02:00
|
|
|
|
lvi.ToolTipText = st;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
lVPrograms.Items.Add(lvi);
|
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
}
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnAddPrograms.Text = Properties.Resources.AddPrograms;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
bnAddPrograms.Enabled = true;
|
2014-06-06 22:38:52 +02:00
|
|
|
|
appsloaded = false;
|
|
|
|
|
((Timer)sender).Stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
public void Save(string name)
|
|
|
|
|
{
|
|
|
|
|
m_Xdoc.Load(m_Profile);
|
|
|
|
|
XmlNode Node;
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.CreateComment(String.Format(" Auto-Profile Configuration Data. {0} ", DateTime.Now));
|
|
|
|
|
foreach (XmlNode node in m_Xdoc.SelectNodes("//comment()"))
|
|
|
|
|
node.ParentNode.ReplaceChild(Node, node);
|
|
|
|
|
|
|
|
|
|
Node = m_Xdoc.SelectSingleNode("Programs");
|
|
|
|
|
string programname;
|
|
|
|
|
programname = Path.GetFileNameWithoutExtension(name);
|
|
|
|
|
XmlElement el = m_Xdoc.CreateElement("Program");
|
|
|
|
|
el.SetAttribute("path", name);
|
|
|
|
|
el.AppendChild(m_Xdoc.CreateElement("Controller1")).InnerText = cBProfile1.Text;
|
|
|
|
|
el.AppendChild(m_Xdoc.CreateElement("Controller2")).InnerText = cBProfile2.Text;
|
|
|
|
|
el.AppendChild(m_Xdoc.CreateElement("Controller3")).InnerText = cBProfile3.Text;
|
|
|
|
|
el.AppendChild(m_Xdoc.CreateElement("Controller4")).InnerText = cBProfile4.Text;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
XmlNode oldxmlprocess = m_Xdoc.SelectSingleNode("/Programs/Program[@path=\"" + lBProgramPath.Text + "\"]");
|
|
|
|
|
Node.ReplaceChild(el, oldxmlprocess);
|
|
|
|
|
}
|
|
|
|
|
catch { Node.AppendChild(el); }
|
|
|
|
|
m_Xdoc.AppendChild(Node);
|
|
|
|
|
m_Xdoc.Save(m_Profile);
|
|
|
|
|
if (lVPrograms.SelectedItems.Count > 0)
|
|
|
|
|
lVPrograms.SelectedItems[0].Checked = true;
|
|
|
|
|
form.LoadP();
|
2014-06-09 01:41:36 +02:00
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
|
|
|
|
public void LoadP(string name)
|
2014-05-30 22:39:39 +02:00
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
doc.Load(m_Profile);
|
|
|
|
|
XmlNodeList programs = doc.SelectNodes("Programs/Program");
|
|
|
|
|
XmlNode Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]");
|
|
|
|
|
if (Item != null)
|
2014-05-30 22:39:39 +02:00
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2014-05-30 22:39:39 +02:00
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]" + "/Controller" + (i + 1));
|
|
|
|
|
for (int j = 0; j < cbs[i].Items.Count; j++)
|
|
|
|
|
if (cbs[i].Items[j].ToString() == Item.InnerText)
|
2014-05-30 22:39:39 +02:00
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
cbs[i].SelectedIndex = j;
|
|
|
|
|
bnSave.Enabled = false;
|
|
|
|
|
break;
|
2014-05-30 22:39:39 +02:00
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
else
|
|
|
|
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
2014-05-30 22:39:39 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
|
|
|
|
bnSave.Enabled = false;
|
|
|
|
|
}
|
2014-05-30 22:39:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-14 21:14:27 +02:00
|
|
|
|
public void RemoveP(string name, bool uncheck, bool reload = true)
|
2014-05-28 21:47:25 +02:00
|
|
|
|
{
|
|
|
|
|
|
2014-06-06 22:38:52 +02:00
|
|
|
|
XmlDocument doc = new XmlDocument();
|
|
|
|
|
doc.Load(m_Profile);
|
|
|
|
|
XmlNode Node = doc.SelectSingleNode("Programs");
|
|
|
|
|
XmlNode Item = doc.SelectSingleNode("/Programs/Program[@path=\"" + name + "\"]");
|
|
|
|
|
if (Item != null)
|
|
|
|
|
Node.RemoveChild(Item);
|
|
|
|
|
doc.AppendChild(Node);
|
2014-06-09 01:41:36 +02:00
|
|
|
|
doc.Save(m_Profile);
|
2014-06-06 22:38:52 +02:00
|
|
|
|
if (lVPrograms.SelectedItems.Count > 0 && uncheck)
|
|
|
|
|
lVPrograms.SelectedItems[0].Checked = false;
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
|
|
|
|
bnSave.Enabled = false;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (reload)
|
2014-06-06 22:38:52 +02:00
|
|
|
|
form.LoadP();
|
2014-06-09 01:41:36 +02:00
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
|
|
|
|
private void CBProfile_IndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int last = cbs[0].Items.Count - 1;
|
|
|
|
|
if (lBProgramPath.Text != string.Empty)
|
|
|
|
|
bnSave.Enabled = true;
|
|
|
|
|
if (cbs[0].SelectedIndex == last && cbs[1].SelectedIndex == last &&
|
|
|
|
|
cbs[2].SelectedIndex == last && cbs[3].SelectedIndex == last)
|
|
|
|
|
bnSave.Enabled = false;
|
2014-05-28 21:47:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-06 22:38:52 +02:00
|
|
|
|
if (lBProgramPath.Text != "")
|
2014-06-09 01:41:36 +02:00
|
|
|
|
Save(lBProgramPath.Text);
|
2014-06-06 22:38:52 +02:00
|
|
|
|
bnSave.Enabled = false;
|
2014-05-28 21:47:25 +02:00
|
|
|
|
}
|
2014-06-06 22:38:52 +02:00
|
|
|
|
|
|
|
|
|
private void bnAddPrograms_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-06-09 01:41:36 +02:00
|
|
|
|
cMSPrograms.Show(bnAddPrograms, new Point(0, bnAddPrograms.Height));
|
2014-06-06 22:38:52 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lBProgramPath_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lBProgramPath.Text != "")
|
|
|
|
|
LoadP(lBProgramPath.Text);
|
|
|
|
|
else
|
|
|
|
|
for (int i = 0; i < 4; i++)
|
|
|
|
|
cbs[i].SelectedIndex = cbs[i].Items.Count - 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnDelete_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
RemoveP(lBProgramPath.Text, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void lBProgramPath_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lVPrograms.SelectedItems.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
if (lVPrograms.SelectedIndices[0] > -1)
|
|
|
|
|
lBProgramPath.Text = lVPrograms.SelectedItems[0].SubItems[1].Text;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
lBProgramPath.Text = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void listView1_ItemCheck(object sender, ItemCheckEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lVPrograms.Items[e.Index].Checked)
|
|
|
|
|
RemoveP(lVPrograms.Items[e.Index].SubItems[1].Text, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void bnHideUnchecked_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
form.RefreshAutoProfilesPage();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
|
|
|
|
private void addSteamGamesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var AppCollectionThread = new System.Threading.Thread(() => GetApps(steamgamesdir));
|
|
|
|
|
AppCollectionThread.IsBackground = true;
|
|
|
|
|
AppCollectionThread.Start();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
bnAddPrograms.Enabled = false;
|
|
|
|
|
cMSPrograms.Items.Remove(addSteamGamesToolStripMenuItem);
|
|
|
|
|
Timer appstimer = new Timer();
|
|
|
|
|
appstimer.Start();
|
|
|
|
|
appstimer.Tick += appstimer_Tick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void browseForOtherProgramsToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
Version 1.4.222
Added Press/Toggle Key to Special Actions, you can hold a trigger to
hold a key or toggle a key with one set of buttons, and untoggle it by
pressing or releasing another set of buttons
Added Disconnect BT to Special Actions, PS+Options to d/c is now added
to Special actions and can be enabled for each profile. You can now set
Disconnect BT to any control(s) and how long you need to hold the
control(s) to take affect
Added Partial German Translation (Thanks Michél)
Added 95% Finished Russian Translation (Thanks overclockers.ru members:
KoNoRIMCI & Sr_psycho)
Added Partial Italian Translation (Thanks Giulio)
Updates to the translations sheets, they should now have every bit of
text in DS4Windows, minus the controls of the controller
English Spelling fixes
Main/Starting tab only shows info for connected controllers, and context
menu only shows options for connected controllers.
Mouse wheel scrolling with analog sticks/triggers/gyro, the mouse now
scrolls smoothly
Slightly reworked analog mouse movement + mouse acceleration (not as
janky anymore)
When starting DS4Windows, if no controllers are connected, DS4Windows
defaults to the profile tab
Certain log warnings (Like unable to get controller exclusively) shows
up in red
Easter egg: try pressing a few buttons in sequence while in the log tab
Fixed Start Profile with TP off being unchecked next time a profile is
opened
Other minor Bug Fixes, such as clearing the log then moving to a new tab
crashing DS4W
2015-01-17 21:16:48 +01:00
|
|
|
|
openProgram.Filter = Properties.Resources.Programs+"|*.exe|" + Properties.Resources.Shortcuts + "|*.lnk";
|
2014-06-09 01:41:36 +02:00
|
|
|
|
if (openProgram.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
string file = openProgram.FileName;
|
|
|
|
|
if (file.EndsWith(".lnk"))
|
|
|
|
|
{
|
|
|
|
|
file = GetTargetPath(file);
|
|
|
|
|
}
|
|
|
|
|
lBProgramPath.Text = file;
|
|
|
|
|
iLIcons.Images.Add(Icon.ExtractAssociatedIcon(file));
|
|
|
|
|
ListViewItem lvi = new ListViewItem(Path.GetFileNameWithoutExtension(file), lVPrograms.Items.Count);
|
|
|
|
|
lvi.SubItems.Add(file);
|
|
|
|
|
lVPrograms.Items.Insert(0, lvi);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addOriginGamesToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var AppCollectionThread = new System.Threading.Thread(() => GetApps(origingamesdir));
|
|
|
|
|
AppCollectionThread.IsBackground = true;
|
|
|
|
|
AppCollectionThread.Start();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
bnAddPrograms.Enabled = false;
|
|
|
|
|
cMSPrograms.Items.Remove(addOriginGamesToolStripMenuItem);
|
|
|
|
|
Timer appstimer = new Timer();
|
|
|
|
|
appstimer.Start();
|
|
|
|
|
appstimer.Tick += appstimer_Tick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void addProgramsFromStartMenuToolStripMenuItem_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//MessageBox.Show(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var AppCollectionThread = new System.Threading.Thread(() => GetShortcuts(Environment.GetFolderPath(Environment.SpecialFolder.StartMenu) + "\\Programs"));
|
|
|
|
|
AppCollectionThread.IsBackground = true;
|
|
|
|
|
AppCollectionThread.Start();
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
2014-08-17 00:09:15 +02:00
|
|
|
|
bnAddPrograms.Text = Properties.Resources.Loading;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
bnAddPrograms.Enabled = false;
|
|
|
|
|
cMSPrograms.Items.Remove(addProgramsFromStartMenuToolStripMenuItem);
|
|
|
|
|
Timer appstimer = new Timer();
|
|
|
|
|
appstimer.Start();
|
|
|
|
|
appstimer.Tick += appstimer_Tick;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetTargetPath(string filePath)
|
|
|
|
|
{
|
|
|
|
|
string targetPath = ResolveMsiShortcut(filePath);
|
|
|
|
|
if (targetPath == null)
|
|
|
|
|
{
|
|
|
|
|
targetPath = ResolveShortcut(filePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return targetPath;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetInternetShortcut(string filePath)
|
|
|
|
|
{
|
|
|
|
|
string url = "";
|
|
|
|
|
|
|
|
|
|
using (TextReader reader = new StreamReader(filePath))
|
|
|
|
|
{
|
|
|
|
|
string line = "";
|
|
|
|
|
while ((line = reader.ReadLine()) != null)
|
|
|
|
|
{
|
|
|
|
|
if (line.StartsWith("URL="))
|
|
|
|
|
{
|
|
|
|
|
string[] splitLine = line.Split('=');
|
|
|
|
|
if (splitLine.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
url = splitLine[1];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return url;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-13 21:12:03 +01:00
|
|
|
|
public static string ResolveShortcut(string filePath)
|
2014-06-09 01:41:36 +02:00
|
|
|
|
{
|
|
|
|
|
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
|
|
|
|
|
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
|
|
|
|
return shortcut.TargetPath;
|
|
|
|
|
}
|
|
|
|
|
catch (COMException)
|
|
|
|
|
{
|
|
|
|
|
// A COMException is thrown if the file is not a valid shortcut (.lnk) file
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-13 21:12:03 +01:00
|
|
|
|
public static string ResolveShortcutAndArgument(string filePath)
|
|
|
|
|
{
|
|
|
|
|
// IWshRuntimeLibrary is in the COM library "Windows Script Host Object Model"
|
|
|
|
|
IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(filePath);
|
|
|
|
|
return shortcut.TargetPath + " " + shortcut.Arguments;
|
|
|
|
|
}
|
|
|
|
|
catch (COMException)
|
|
|
|
|
{
|
|
|
|
|
// A COMException is thrown if the file is not a valid shortcut (.lnk) file
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string ResolveMsiShortcut(string file)
|
2014-06-09 01:41:36 +02:00
|
|
|
|
{
|
2015-02-08 22:51:52 +01:00
|
|
|
|
StringBuilder product = new StringBuilder(NativeMethods2.MaxGuidLength + 1);
|
|
|
|
|
StringBuilder feature = new StringBuilder(NativeMethods2.MaxFeatureLength + 1);
|
|
|
|
|
StringBuilder component = new StringBuilder(NativeMethods2.MaxGuidLength + 1);
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
2015-02-08 22:51:52 +01:00
|
|
|
|
NativeMethods2.MsiGetShortcutTarget(file, product, feature, component);
|
2014-06-09 01:41:36 +02:00
|
|
|
|
|
2015-02-08 22:51:52 +01:00
|
|
|
|
int pathLength = NativeMethods2.MaxPathLength;
|
2014-06-09 01:41:36 +02:00
|
|
|
|
StringBuilder path = new StringBuilder(pathLength);
|
|
|
|
|
|
2015-02-08 22:51:52 +01:00
|
|
|
|
NativeMethods2.InstallState installState = NativeMethods2.MsiGetComponentPath(product.ToString(), component.ToString(), path, ref pathLength);
|
|
|
|
|
if (installState == NativeMethods2.InstallState.Local)
|
2014-06-09 01:41:36 +02:00
|
|
|
|
{
|
|
|
|
|
return path.ToString();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-02-08 22:51:52 +01:00
|
|
|
|
class NativeMethods2
|
2014-06-09 01:41:36 +02:00
|
|
|
|
{
|
|
|
|
|
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
|
|
|
|
public static extern uint MsiGetShortcutTarget(string targetFile, StringBuilder productCode, StringBuilder featureID, StringBuilder componentCode);
|
|
|
|
|
|
|
|
|
|
[DllImport("msi.dll", CharSet = CharSet.Auto)]
|
|
|
|
|
public static extern InstallState MsiGetComponentPath(string productCode, string componentCode, StringBuilder componentPath, ref int componentPathBufferSize);
|
|
|
|
|
|
|
|
|
|
public const int MaxFeatureLength = 38;
|
|
|
|
|
public const int MaxGuidLength = 38;
|
|
|
|
|
public const int MaxPathLength = 1024;
|
|
|
|
|
|
|
|
|
|
public enum InstallState
|
|
|
|
|
{
|
|
|
|
|
NotUsed = -7,
|
|
|
|
|
BadConfig = -6,
|
|
|
|
|
Incomplete = -5,
|
|
|
|
|
SourceAbsent = -4,
|
|
|
|
|
MoreData = -3,
|
|
|
|
|
InvalidArg = -2,
|
|
|
|
|
Unknown = -1,
|
|
|
|
|
Broken = 0,
|
|
|
|
|
Advertised = 1,
|
|
|
|
|
Removed = 1,
|
|
|
|
|
Absent = 2,
|
|
|
|
|
Local = 3,
|
|
|
|
|
Source = 4,
|
|
|
|
|
Default = 5
|
|
|
|
|
}
|
2014-05-28 21:47:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|