Improved window finding

This commit is contained in:
CreepyCrafter24 2020-04-04 12:05:42 +02:00
parent 1ad691ad99
commit 46bfdfe49e
15 changed files with 133 additions and 371 deletions

View File

@ -662,8 +662,7 @@ namespace CC_Functions.Misc
/// Returns a standard textual representation of the cell.
/// </summary>
public override string ToString() =>
"DataGridViewNumericUpDownCell { ColumnIndex=" + ColumnIndex.ToString(CultureInfo.CurrentCulture) +
", RowIndex=" + RowIndex.ToString(CultureInfo.CurrentCulture) + " }";
$"DataGridViewNumericUpDownCell {{ ColumnIndex={ColumnIndex.ToString(CultureInfo.CurrentCulture)}, RowIndex={RowIndex.ToString(CultureInfo.CurrentCulture)} }}";
/// <summary>
/// Little utility function used by both the cell and column types to translate a DataGridViewContentAlignment value

View File

@ -4,12 +4,9 @@
<RootNamespace>CC_Functions.Misc</RootNamespace>
<AssemblyName>CC_Functions.Misc</AssemblyName>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<Deterministic>false</Deterministic>
<!--<GeneratePackageOnBuild>true</GeneratePackageOnBuild>-->
<PackageId>CC-Functions.Misc</PackageId>
<Title>CC-Functions.Misc</Title>
<Authors>CC24</Authors>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
</configuration>

View File

@ -59,7 +59,7 @@
this.wnd_action_title_get = new System.Windows.Forms.Button();
this.wnd_action_title_set = new System.Windows.Forms.Button();
this.wnd_select_title_box = new System.Windows.Forms.TextBox();
this.wnd_selet_class_button = new System.Windows.Forms.Button();
this.wnd_select_class_button = new System.Windows.Forms.Button();
this.wnd_select_title_button = new System.Windows.Forms.Button();
this.wnd_select_selected = new System.Windows.Forms.Label();
this.wnd_select_self = new System.Windows.Forms.Button();
@ -444,13 +444,13 @@
//
// wnd_selet_class_button
//
this.wnd_selet_class_button.Location = new System.Drawing.Point(7, 89);
this.wnd_selet_class_button.Name = "wnd_selet_class_button";
this.wnd_selet_class_button.Size = new System.Drawing.Size(94, 27);
this.wnd_selet_class_button.TabIndex = 4;
this.wnd_selet_class_button.Text = "Select (class):";
this.wnd_selet_class_button.UseVisualStyleBackColor = true;
this.wnd_selet_class_button.Click += new System.EventHandler(this.Wnd_selet_class_button_Click);
this.wnd_select_class_button.Location = new System.Drawing.Point(7, 89);
this.wnd_select_class_button.Name = "wnd_select_class_button";
this.wnd_select_class_button.Size = new System.Drawing.Size(94, 27);
this.wnd_select_class_button.TabIndex = 4;
this.wnd_select_class_button.Text = "Select (class):";
this.wnd_select_class_button.UseVisualStyleBackColor = true;
this.wnd_select_class_button.Click += new System.EventHandler(this.Wnd_select_class_button_Click);
//
// wnd_select_title_button
//
@ -505,7 +505,7 @@
this.wnd.Controls.Add(this.wnd_action_title_set);
this.wnd.Controls.Add(this.wnd_select_title_box);
this.wnd.Controls.Add(this.wnd_select_class_box);
this.wnd.Controls.Add(this.wnd_selet_class_button);
this.wnd.Controls.Add(this.wnd_select_class_button);
this.wnd.Controls.Add(this.wnd_select_title_button);
this.wnd.Controls.Add(this.wnd_select_selected);
this.wnd.Controls.Add(this.wnd_select_self);
@ -825,7 +825,7 @@
private System.Windows.Forms.Button wnd_action_title_get;
private System.Windows.Forms.Button wnd_action_title_set;
private System.Windows.Forms.TextBox wnd_select_title_box;
private System.Windows.Forms.Button wnd_selet_class_button;
private System.Windows.Forms.Button wnd_select_class_button;
private System.Windows.Forms.Button wnd_select_title_button;
private System.Windows.Forms.Label wnd_select_selected;
private System.Windows.Forms.Button wnd_select_self;

View File

@ -11,34 +11,33 @@ namespace CC_Functions.W32.Test
{
public partial class MainForm : Form
{
private static Wnd32 tmpWnd32_obj;
private static MainForm mainF;
private static Form frm;
private static Label lab;
private readonly KeyboardHook kHook;
private readonly MouseHook mHook;
private readonly Label[] readerLabels;
private static Wnd32 _tmpWnd32Obj;
private static MainForm _mainF;
private readonly KeyboardHook _kHook;
private readonly MouseHook _mHook;
private readonly Label[] _readerLabels;
public MainForm()
{
_wndSelectMouseCurrent = this.GetWnd32();
InitializeComponent();
mainF = this;
tmpWnd32_obj = Wnd32.FromForm(this);
_mainF = this;
_tmpWnd32Obj = Wnd32.FromForm(this);
#if DEBUG
tmpWnd32_obj.MakeOverlay();
#endif
set_up_box(power_mode_box, typeof(ShutdownMode));
set_up_box(power_reason_box, typeof(ShutdownReason));
set_up_box(power_mod_box, typeof(ShutdownMod));
mHook = new MouseHook();
kHook = new KeyboardHook();
_mHook = new MouseHook();
_kHook = new KeyboardHook();
wnd_action_pos_x_bar.Maximum = Screen.PrimaryScreen.Bounds.Width;
wnd_action_pos_y_bar.Maximum = Screen.PrimaryScreen.Bounds.Height;
wnd_action_pos_w_bar.Maximum = Screen.PrimaryScreen.Bounds.Width;
wnd_action_pos_h_bar.Maximum = Screen.PrimaryScreen.Bounds.Height;
wnd_action_style.DataSource = Enum.GetValues(typeof(FormWindowState));
wnd_action_style.SelectedItem = tmpWnd32_obj.State;
readerLabels = Enum.GetValues(typeof(Keys)).OfType<Keys>().OrderBy(s => s.ToString()).Select(s =>
wnd_action_style.SelectedItem = _tmpWnd32Obj.State;
_readerLabels = Enum.GetValues(typeof(Keys)).OfType<Keys>().OrderBy(s => s.ToString()).Select(s =>
{
Label lab = new Label {Tag = s};
readerFlow.Controls.Add(lab);
@ -50,17 +49,17 @@ namespace CC_Functions.W32.Test
time_select.Value = DateTime.Now;
}
private Wnd32 tmpWnd
private Wnd32 TmpWnd
{
get => tmpWnd32_obj;
get => _tmpWnd32Obj;
set
{
tmpWnd32_obj = value;
_tmpWnd32Obj = value;
Wnd_action_title_get_Click(null, null);
}
}
public void set_up_box(ComboBox box, Type enumT)
private static void set_up_box(ComboBox box, Type enumT)
{
box.DataSource = Enum.GetNames(enumT);
Array tmp = Enum.GetValues(enumT);
@ -73,38 +72,38 @@ namespace CC_Functions.W32.Test
}
}
public object get_box_value(ComboBox box) => ((object[]) box.Tag)[box.SelectedIndex];
private static object get_box_value(ListControl box) => ((object[]) box.Tag)[box.SelectedIndex];
private void Power_execute_Click(object sender, EventArgs e) => RaiseEvent(
(ShutdownMode) get_box_value(power_mode_box), (ShutdownReason) get_box_value(power_reason_box),
(ShutdownMod) get_box_value(power_mod_box));
private void Wnd_select_self_Click(object sender, EventArgs e) => tmpWnd = Wnd32.FromForm(this);
private void Wnd_select_self_Click(object sender, EventArgs e) => TmpWnd = Wnd32.FromForm(this);
private void wnd_select_list_Click(object sender, EventArgs e) =>
tmpWnd = SelectBox.Show(Wnd32.Visible, "Please select a window") ?? tmpWnd;
TmpWnd = SelectBox.Show(Wnd32.Visible, "Please select a window") ?? TmpWnd;
private void Wnd_select_title_button_Click(object sender, EventArgs e) =>
tmpWnd = Wnd32.FromMetadata(null, wnd_select_title_box.Text);
TmpWnd = Wnd32.FromMetadata(null, wnd_select_title_box.Text);
private void Wnd_selet_class_button_Click(object sender, EventArgs e) =>
tmpWnd = Wnd32.FromMetadata(wnd_select_class_box.Text);
private void Wnd_select_class_button_Click(object sender, EventArgs e) =>
TmpWnd = Wnd32.FromMetadata(wnd_select_class_box.Text);
private void Wnd_action_title_set_Click(object sender, EventArgs e) => tmpWnd.Title = wnd_select_title_box.Text;
private void Wnd_action_title_set_Click(object sender, EventArgs e) => TmpWnd.Title = wnd_select_title_box.Text;
private void Wnd_action_title_get_Click(object sender, EventArgs e)
{
if (!tmpWnd.StillExists)
tmpWnd = Wnd32.FromForm(this);
wnd_select_title_box.Text = tmpWnd.Title;
wnd_action_enabled.Checked = tmpWnd.Enabled;
wnd_select_selected.Text = "Selected: " + tmpWnd.HWnd;
wnd_action_style.SelectedIndex = (int) tmpWnd.State;
wnd_select_class_box.Text = tmpWnd.ClassName;
wnd_action_visible.Checked = tmpWnd.Shown;
if (!TmpWnd.StillExists)
TmpWnd = Wnd32.FromForm(this);
wnd_select_title_box.Text = TmpWnd.Title;
wnd_action_enabled.Checked = TmpWnd.Enabled;
wnd_select_selected.Text = $"Selected: {TmpWnd.HWnd}";
wnd_action_style.SelectedIndex = (int) TmpWnd.State;
wnd_select_class_box.Text = TmpWnd.ClassName;
wnd_action_visible.Checked = TmpWnd.Shown;
try
{
wnd_action_icon.BackgroundImage = tmpWnd.Icon.ToBitmap();
wnd_action_icon.BackgroundImage = TmpWnd.Icon.ToBitmap();
}
catch
{
@ -113,93 +112,112 @@ namespace CC_Functions.W32.Test
try
{
wnd_action_pos_x_bar.Value = tmpWnd.Position.X;
wnd_action_pos_x_bar.Value = TmpWnd.Position.X;
}
catch
{
// ignored
}
try
{
wnd_action_pos_y_bar.Value = tmpWnd.Position.Y;
wnd_action_pos_y_bar.Value = TmpWnd.Position.Y;
}
catch
{
// ignored
}
try
{
wnd_action_pos_w_bar.Value = tmpWnd.Position.Width;
wnd_action_pos_w_bar.Value = TmpWnd.Position.Width;
}
catch
{
// ignored
}
try
{
wnd_action_pos_h_bar.Value = tmpWnd.Position.Height;
wnd_action_pos_h_bar.Value = TmpWnd.Position.Height;
}
catch
{
// ignored
}
}
private void Wnd_action_enabled_CheckedChanged(object sender, EventArgs e) =>
tmpWnd.Enabled = wnd_action_enabled.Checked;
TmpWnd.Enabled = wnd_action_enabled.Checked;
private void Wnd_action_visible_CheckedChanged(object sender, EventArgs e) =>
tmpWnd.Shown = wnd_action_visible.Checked;
TmpWnd.Shown = wnd_action_visible.Checked;
private void Wnd_action_front_Click(object sender, EventArgs e) => tmpWnd.IsForeground = true;
private void Wnd_action_front_Click(object sender, EventArgs e) => TmpWnd.IsForeground = true;
private void Wnd_action_destroy_Click(object sender, EventArgs e) => tmpWnd.Destroy();
private void Wnd_action_destroy_Click(object sender, EventArgs e) => TmpWnd.Destroy();
private static Wnd32 _wndSelectMouseCurrent;
private void Wnd_select_mouse_Click(object sender, EventArgs e)
{
WindowState = FormWindowState.Minimized;
tmpWnd = Wnd32.FromForm(this);
tmpWnd.Enabled = false;
frm = new Form();
frm.BackColor = Color.White;
frm.Opacity = 0.4f;
frm.FormBorderStyle = FormBorderStyle.None;
frm.WindowState = FormWindowState.Maximized;
frm.Click += Frm_Click;
frm.MouseMove += Frm_MouseMove;
lab = new Label();
TmpWnd = Wnd32.FromForm(this);
TmpWnd.Enabled = false;
Form frm = new Form
{
BackColor = Color.White,
Opacity = 0.4f,
FormBorderStyle = FormBorderStyle.None,
WindowState = FormWindowState.Maximized
};
Label lab = new Label {AutoSize = true};
frm.Controls.Add(lab);
frm.Show();
Wnd32.FromForm(frm).Overlay = true;
Panel pan = new Panel {BackColor = Color.Red};
frm.Controls.Add(pan);
void MouseEventHandler(object sender1, MouseEventArgs e1)
{
_wndSelectMouseCurrent = Wnd32.AllFromPoint(MousePosition, true).First(s => s != frm.GetWnd32());
lab.Text = $"{_wndSelectMouseCurrent.Title} ({_wndSelectMouseCurrent.HWnd})";
lab.Location = new Point(Cursor.Position.X + 5, Cursor.Position.Y + 5);
pan.Bounds = _wndSelectMouseCurrent.Position;
}
private void Frm_Click(object sender, EventArgs e)
void EventHandler(object sender1, EventArgs e1)
{
frm.Hide();
frm.WindowState = FormWindowState.Minimized;
Wnd32 tmp = Wnd32.FromPoint(MousePosition);
tmpWnd.Enabled = true;
tmpWnd.IsForeground = true;
tmpWnd = tmp;
mainF.WindowState = FormWindowState.Normal;
Wnd32 tmp = _wndSelectMouseCurrent;
TmpWnd.Enabled = true;
TmpWnd.IsForeground = true;
TmpWnd = tmp;
_mainF.WindowState = FormWindowState.Normal;
frm.Close();
}
private void Frm_MouseMove(object sender, MouseEventArgs e)
{
lab.Text = Wnd32.FromPoint(MousePosition).ToString();
lab.Location = new Point(Cursor.Position.X + 5, Cursor.Position.Y + 5);
frm.Click += EventHandler;
pan.Click += EventHandler;
lab.Click += EventHandler;
frm.MouseMove += MouseEventHandler;
pan.MouseMove += MouseEventHandler;
lab.MouseMove += MouseEventHandler;
frm.Show();
_wndSelectMouseCurrent = frm.GetWnd32();
Cursor.Position = Cursor.Position;
frm.GetWnd32().Overlay = true;
}
private void Mouse_enabled_CheckedChanged(object sender, EventArgs e)
{
if (mouse_enabled.Checked)
mHook.OnMouse += MHook_OnMouse;
_mHook.OnMouse += MHook_OnMouse;
else
mHook.OnMouse -= MHook_OnMouse;
_mHook.OnMouse -= MHook_OnMouse;
}
private void MHook_OnMouse(MouseHookEventArgs args) =>
mouse_log.Text = args.Message + " -|- " + args.Point + "\r\n" + mouse_log.Text;
mouse_log.Text = $"{args.Message} -|- {args.Point}\r\n{mouse_log.Text}";
private void Mouse_log_TextChanged(object sender, EventArgs e) =>
mouse_log.Lines = mouse_log.Lines.Take(9).ToArray();
@ -207,35 +225,34 @@ namespace CC_Functions.W32.Test
private void Keyboard_enabled_CheckedChanged(object sender, EventArgs e)
{
if (keyboard_enabled.Checked)
kHook.OnKeyPress += KHook_OnKeyPress;
_kHook.OnKeyPress += KHook_OnKeyPress;
else
kHook.OnKeyPress -= KHook_OnKeyPress;
_kHook.OnKeyPress -= KHook_OnKeyPress;
}
private void KHook_OnKeyPress(KeyboardHookEventArgs args) =>
keyboard_log.Text = args.Key + "\r\n" + keyboard_log.Text;
keyboard_log.Text = $"{args.Key}\r\n{keyboard_log.Text}";
private void Keyboard_log_TextChanged(object sender, EventArgs e) =>
keyboard_log.Lines = keyboard_log.Lines.Take(8).ToArray();
private void Wnd_action_pos_Click(object sender, EventArgs e) =>
tmpWnd.Position = new Rectangle(wnd_action_pos_x_bar.Value, wnd_action_pos_y_bar.Value,
TmpWnd.Position = new Rectangle(wnd_action_pos_x_bar.Value, wnd_action_pos_y_bar.Value,
wnd_action_pos_w_bar.Value, wnd_action_pos_h_bar.Value);
private void Wnd_action_style_SelectedIndexChanged(object sender, EventArgs e)
{
Enum.TryParse(wnd_action_style.SelectedValue.ToString(), out FormWindowState status);
tmpWnd.State = status;
TmpWnd.State = status;
}
private void wnd_action_overlay_CheckedChanged(object sender, EventArgs e) =>
tmpWnd.Overlay = wnd_action_overlay.Checked;
TmpWnd.Overlay = wnd_action_overlay.Checked;
private void readerUpdate_Tick(object sender, EventArgs e)
{
for (int i = 0; i < readerLabels.Length; i++)
foreach (Label s in _readerLabels)
{
Label s = readerLabels[i];
Keys key = (Keys) s.Tag;
s.Text = $"{key.ToString()}: {key.IsDown()}";
}
@ -248,17 +265,17 @@ namespace CC_Functions.W32.Test
using IDCDrawer drawer = DeskMan.CreateGraphics();
Graphics g = drawer.Graphics;
Pen eye = new Pen(new SolidBrush(Color.Red), 2);
g.DrawCurve(eye, new[] {makePoint(20, 50), makePoint(50, 65), makePoint(80, 50)});
g.DrawCurve(eye, new[] {makePoint(20, 50), makePoint(50, 35), makePoint(80, 50)});
g.DrawCurve(eye, new[] {MakePoint(20, 50), MakePoint(50, 65), MakePoint(80, 50)});
g.DrawCurve(eye, new[] {MakePoint(20, 50), MakePoint(50, 35), MakePoint(80, 50)});
g.DrawEllipse(eye,
new RectangleF(PointF.Subtract(makePoint(50, 50), makeSizeY(15, 15)), makeSizeY(30, 30)));
new RectangleF(PointF.Subtract(MakePoint(50, 50), MakeSizeY(15, 15)), MakeSizeY(30, 30)));
}
public static PointF makePoint(float xPercent, float yPercent) => new PointF(
private static PointF MakePoint(float xPercent, float yPercent) => new PointF(
(Screen.PrimaryScreen.Bounds.Width * xPercent) / 100,
(Screen.PrimaryScreen.Bounds.Height * yPercent) / 100);
public static SizeF makeSizeY(float xPercent, float yPercent) => new SizeF(
private static SizeF MakeSizeY(float xPercent, float yPercent) => new SizeF(
(Screen.PrimaryScreen.Bounds.Height * xPercent) / 100,
(Screen.PrimaryScreen.Bounds.Height * yPercent) / 100);
@ -277,10 +294,10 @@ namespace CC_Functions.W32.Test
using IDCDrawer drawer = ScreenMan.GetDrawer(false);
Graphics g = drawer.Graphics;
Pen eye = new Pen(new SolidBrush(Color.Red), 2);
g.DrawCurve(eye, new[] {makePoint(20, 50), makePoint(50, 65), makePoint(80, 50)});
g.DrawCurve(eye, new[] {makePoint(20, 50), makePoint(50, 35), makePoint(80, 50)});
g.DrawCurve(eye, new[] {MakePoint(20, 50), MakePoint(50, 65), MakePoint(80, 50)});
g.DrawCurve(eye, new[] {MakePoint(20, 50), MakePoint(50, 35), MakePoint(80, 50)});
g.DrawEllipse(eye,
new RectangleF(PointF.Subtract(makePoint(50, 50), makeSizeY(15, 15)), makeSizeY(30, 30)));
new RectangleF(PointF.Subtract(MakePoint(50, 50), MakeSizeY(15, 15)), MakeSizeY(30, 30)));
}
private void time_set_Click(object sender, EventArgs e) => Time.Set(time_select.Value);

View File

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("W32.Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("W32.Test")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6121a6d3-7c73-4ede-a5a9-09dc52150824")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.*")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -1,63 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CC_Functions.W32.Test.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CC_Functions.W32.Test.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -1,117 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,26 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace CC_Functions.W32.Test.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -1,7 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@ -5,8 +5,6 @@
<RootNamespace>CC_Functions.W32.Test</RootNamespace>
<AssemblyName>CC_Functions.W32.Test</AssemblyName>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<Deterministic>false</Deterministic>
</PropertyGroup>
@ -14,10 +12,10 @@
<PostBuildEvent>if exist "$(SolutionDir)Data\pkgtool.exe" ($(SolutionDir)Data\pkgtool.exe build --noLogo --binDir .) else if exist "%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" ("%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" build --noLogo --binDir .) else echo Cound not find Package build tools, skipping</PostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DocumentationFile>bin\Debug\W32.Test.xml</DocumentationFile>
<DocumentationFile></DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DocumentationFile>bin\Release\W32.Test.xml</DocumentationFile>
<DocumentationFile></DocumentationFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Misc\Misc.csproj" />

View File

@ -15,8 +15,8 @@ namespace CC_Functions.W32
get
{
using (Bitmap bmpTemp =
new Bitmap(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) +
@"\Microsoft\Windows\Themes\TranscodedWallpaper"))
new Bitmap(
$@"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\Microsoft\Windows\Themes\TranscodedWallpaper"))
{
return (Image) bmpTemp.Clone();
}

View File

@ -14,6 +14,6 @@ namespace CC_Functions.W32.Hooks
public Point Point { get; }
public MouseHook.MouseMessages Message { get; }
public override string ToString() => Message + "; " + Point;
public override string ToString() => $"{Message}; {Point}";
}
}

View File

@ -4,12 +4,9 @@
<RootNamespace>CC_Functions.W32</RootNamespace>
<AssemblyName>CC-Functions.W32</AssemblyName>
<LangVersion>8</LangVersion>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
<Deterministic>false</Deterministic>
<!--<GeneratePackageOnBuild>true</GeneratePackageOnBuild>-->
<Authors>CC24</Authors>
<Description>W32 Additions for CC-Functions</Description>
<Copyright>Copyright 2020</Copyright>

View File

@ -54,6 +54,14 @@ namespace CC_Functions.W32
/// <returns>The window. Might be IntPtr.Zero</returns>
public static Wnd32 FromPoint(Point point) => FromHandle(user32.WindowFromPoint(point.X, point.Y));
/// <summary>
/// Gets all windows at the specific point
/// </summary>
/// <param name="point">The point to scan</param>
/// <param name="visible">Whether windows need to be visible</param>
/// <returns>The windows</returns>
public static Wnd32[] AllFromPoint(Point point, bool visible = false) => All.Where(s => s.Position.Contains(point) && s.Shown || !visible).ToArray();
/// <summary>
/// Gets the window associated with the forms handle
/// </summary>
@ -72,15 +80,15 @@ namespace CC_Functions.W32
_windowHandles = new List<IntPtr>();
if (!user32.EnumDesktopWindows(IntPtr.Zero, FilterCallback, IntPtr.Zero))
throw new Win32Exception("There was a native error. This should never happen!");
return _windowHandles.Select(s => FromHandle(s)).ToArray();
return _windowHandles.Select(FromHandle).ToArray();
}
}
/// <summary>
/// Gets all visible windows with valid titles
/// Gets all visible windows
/// </summary>
public static Wnd32[] Visible =>
All.Where(s => user32.IsWindowVisible(s.HWnd) && !string.IsNullOrEmpty(s.Title)).ToArray();
All.Where(s => s.Shown).ToArray();
/// <summary>
/// Gets the foreground window