Allow getting a list of windows, added SelectBox
This commit is contained in:
parent
8141ae1941
commit
a21a89f051
@ -58,9 +58,18 @@
|
|||||||
<Compile Include="IO.cs" />
|
<Compile Include="IO.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Security.cs" />
|
<Compile Include="Security.cs" />
|
||||||
|
<Compile Include="SelectBox.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="SelectBox.Designer.cs">
|
||||||
|
<DependentUpon>SelectBox.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="HIDClasses.txt" />
|
<EmbeddedResource Include="HIDClasses.txt" />
|
||||||
|
<EmbeddedResource Include="SelectBox.resx">
|
||||||
|
<DependentUpon>SelectBox.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
61
Misc/SelectBox.Designer.cs
generated
Normal file
61
Misc/SelectBox.Designer.cs
generated
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
namespace CC_Functions.Misc
|
||||||
|
{
|
||||||
|
partial class SelectBox<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.listBox1 = new System.Windows.Forms.ListBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// listBox1
|
||||||
|
//
|
||||||
|
this.listBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.listBox1.FormattingEnabled = true;
|
||||||
|
this.listBox1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.listBox1.Name = "listBox1";
|
||||||
|
this.listBox1.Size = new System.Drawing.Size(433, 145);
|
||||||
|
this.listBox1.TabIndex = 0;
|
||||||
|
this.listBox1.SelectedIndexChanged += new System.EventHandler(this.listBox1_SelectedIndexChanged);
|
||||||
|
//
|
||||||
|
// SelectBox
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(433, 145);
|
||||||
|
this.Controls.Add(this.listBox1);
|
||||||
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||||
|
this.Name = "SelectBox";
|
||||||
|
this.Text = "SelectBox";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.ListBox listBox1;
|
||||||
|
}
|
||||||
|
}
|
38
Misc/SelectBox.cs
Normal file
38
Misc/SelectBox.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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;
|
||||||
|
namespace CC_Functions.Misc
|
||||||
|
{
|
||||||
|
partial class SelectBox<T> : Form
|
||||||
|
{
|
||||||
|
public T result;
|
||||||
|
public SelectBox(T[] Options, string title = "")
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
Text = title;
|
||||||
|
listBox1.Items.AddRange(Options.Select(s => (object)s).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
result = (T)listBox1.SelectedItem;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SelectBox
|
||||||
|
{
|
||||||
|
public static T Show<T>(T[] Options, string title = "")
|
||||||
|
{
|
||||||
|
SelectBox<T> sb = new SelectBox<T>(Options, title);
|
||||||
|
return sb.ShowDialog() == DialogResult.OK ? sb.result : default(T);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
Misc/SelectBox.resx
Normal file
120
Misc/SelectBox.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<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" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</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" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
39
W32.Test/Form1.Designer.cs
generated
39
W32.Test/Form1.Designer.cs
generated
@ -64,11 +64,12 @@
|
|||||||
this.wnd_select_selected = new System.Windows.Forms.Label();
|
this.wnd_select_selected = new System.Windows.Forms.Label();
|
||||||
this.wnd_select_self = new System.Windows.Forms.Button();
|
this.wnd_select_self = new System.Windows.Forms.Button();
|
||||||
this.wnd = new System.Windows.Forms.GroupBox();
|
this.wnd = new System.Windows.Forms.GroupBox();
|
||||||
|
this.wnd_action_overlay = new System.Windows.Forms.CheckBox();
|
||||||
this.wnd_action_style = new System.Windows.Forms.ComboBox();
|
this.wnd_action_style = new System.Windows.Forms.ComboBox();
|
||||||
this.wnd_action_visible = new System.Windows.Forms.CheckBox();
|
this.wnd_action_visible = new System.Windows.Forms.CheckBox();
|
||||||
this.wnd_action_icon = new System.Windows.Forms.Panel();
|
this.wnd_action_icon = new System.Windows.Forms.Panel();
|
||||||
this.wnd_select_class_box = new System.Windows.Forms.TextBox();
|
this.wnd_select_class_box = new System.Windows.Forms.TextBox();
|
||||||
this.wnd_action_overlay = new System.Windows.Forms.CheckBox();
|
this.wnd_select_list = new System.Windows.Forms.Button();
|
||||||
this.keyboard.SuspendLayout();
|
this.keyboard.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_h_bar)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_h_bar)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_w_bar)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_w_bar)).BeginInit();
|
||||||
@ -346,7 +347,7 @@
|
|||||||
// wnd_action_enabled
|
// wnd_action_enabled
|
||||||
//
|
//
|
||||||
this.wnd_action_enabled.AutoSize = true;
|
this.wnd_action_enabled.AutoSize = true;
|
||||||
this.wnd_action_enabled.Location = new System.Drawing.Point(6, 110);
|
this.wnd_action_enabled.Location = new System.Drawing.Point(113, 110);
|
||||||
this.wnd_action_enabled.Name = "wnd_action_enabled";
|
this.wnd_action_enabled.Name = "wnd_action_enabled";
|
||||||
this.wnd_action_enabled.Size = new System.Drawing.Size(65, 17);
|
this.wnd_action_enabled.Size = new System.Drawing.Size(65, 17);
|
||||||
this.wnd_action_enabled.TabIndex = 9;
|
this.wnd_action_enabled.TabIndex = 9;
|
||||||
@ -422,6 +423,7 @@
|
|||||||
//
|
//
|
||||||
// wnd
|
// wnd
|
||||||
//
|
//
|
||||||
|
this.wnd.Controls.Add(this.wnd_select_list);
|
||||||
this.wnd.Controls.Add(this.wnd_action_overlay);
|
this.wnd.Controls.Add(this.wnd_action_overlay);
|
||||||
this.wnd.Controls.Add(this.wnd_action_style);
|
this.wnd.Controls.Add(this.wnd_action_style);
|
||||||
this.wnd.Controls.Add(this.wnd_action_visible);
|
this.wnd.Controls.Add(this.wnd_action_visible);
|
||||||
@ -454,6 +456,17 @@
|
|||||||
this.wnd.TabStop = false;
|
this.wnd.TabStop = false;
|
||||||
this.wnd.Text = "CC-Functions.W32.Wnd32";
|
this.wnd.Text = "CC-Functions.W32.Wnd32";
|
||||||
//
|
//
|
||||||
|
// wnd_action_overlay
|
||||||
|
//
|
||||||
|
this.wnd_action_overlay.AutoSize = true;
|
||||||
|
this.wnd_action_overlay.Location = new System.Drawing.Point(136, 135);
|
||||||
|
this.wnd_action_overlay.Name = "wnd_action_overlay";
|
||||||
|
this.wnd_action_overlay.Size = new System.Drawing.Size(62, 17);
|
||||||
|
this.wnd_action_overlay.TabIndex = 25;
|
||||||
|
this.wnd_action_overlay.Text = "Overlay";
|
||||||
|
this.wnd_action_overlay.UseVisualStyleBackColor = true;
|
||||||
|
this.wnd_action_overlay.CheckedChanged += new System.EventHandler(this.wnd_action_overlay_CheckedChanged);
|
||||||
|
//
|
||||||
// wnd_action_style
|
// wnd_action_style
|
||||||
//
|
//
|
||||||
this.wnd_action_style.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.wnd_action_style.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
@ -467,7 +480,7 @@
|
|||||||
// wnd_action_visible
|
// wnd_action_visible
|
||||||
//
|
//
|
||||||
this.wnd_action_visible.AutoSize = true;
|
this.wnd_action_visible.AutoSize = true;
|
||||||
this.wnd_action_visible.Location = new System.Drawing.Point(77, 110);
|
this.wnd_action_visible.Location = new System.Drawing.Point(184, 110);
|
||||||
this.wnd_action_visible.Name = "wnd_action_visible";
|
this.wnd_action_visible.Name = "wnd_action_visible";
|
||||||
this.wnd_action_visible.Size = new System.Drawing.Size(56, 17);
|
this.wnd_action_visible.Size = new System.Drawing.Size(56, 17);
|
||||||
this.wnd_action_visible.TabIndex = 23;
|
this.wnd_action_visible.TabIndex = 23;
|
||||||
@ -479,7 +492,7 @@
|
|||||||
//
|
//
|
||||||
this.wnd_action_icon.BackColor = System.Drawing.SystemColors.ControlLight;
|
this.wnd_action_icon.BackColor = System.Drawing.SystemColors.ControlLight;
|
||||||
this.wnd_action_icon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
this.wnd_action_icon.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||||
this.wnd_action_icon.Location = new System.Drawing.Point(217, 106);
|
this.wnd_action_icon.Location = new System.Drawing.Point(217, 131);
|
||||||
this.wnd_action_icon.Name = "wnd_action_icon";
|
this.wnd_action_icon.Name = "wnd_action_icon";
|
||||||
this.wnd_action_icon.Size = new System.Drawing.Size(23, 23);
|
this.wnd_action_icon.Size = new System.Drawing.Size(23, 23);
|
||||||
this.wnd_action_icon.TabIndex = 22;
|
this.wnd_action_icon.TabIndex = 22;
|
||||||
@ -491,16 +504,15 @@
|
|||||||
this.wnd_select_class_box.Size = new System.Drawing.Size(104, 20);
|
this.wnd_select_class_box.Size = new System.Drawing.Size(104, 20);
|
||||||
this.wnd_select_class_box.TabIndex = 5;
|
this.wnd_select_class_box.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// wnd_action_overlay
|
// wnd_select_list
|
||||||
//
|
//
|
||||||
this.wnd_action_overlay.AutoSize = true;
|
this.wnd_select_list.Location = new System.Drawing.Point(6, 106);
|
||||||
this.wnd_action_overlay.Location = new System.Drawing.Point(139, 110);
|
this.wnd_select_list.Name = "wnd_select_list";
|
||||||
this.wnd_action_overlay.Name = "wnd_action_overlay";
|
this.wnd_select_list.Size = new System.Drawing.Size(81, 23);
|
||||||
this.wnd_action_overlay.Size = new System.Drawing.Size(62, 17);
|
this.wnd_select_list.TabIndex = 26;
|
||||||
this.wnd_action_overlay.TabIndex = 25;
|
this.wnd_select_list.Text = "Select (list)";
|
||||||
this.wnd_action_overlay.Text = "Overlay";
|
this.wnd_select_list.UseVisualStyleBackColor = true;
|
||||||
this.wnd_action_overlay.UseVisualStyleBackColor = true;
|
this.wnd_select_list.Click += new System.EventHandler(this.wnd_select_list_Click);
|
||||||
this.wnd_action_overlay.CheckedChanged += new System.EventHandler(this.wnd_action_overlay_CheckedChanged);
|
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
@ -575,5 +587,6 @@
|
|||||||
private System.Windows.Forms.CheckBox wnd_action_visible;
|
private System.Windows.Forms.CheckBox wnd_action_visible;
|
||||||
private System.Windows.Forms.ComboBox wnd_action_style;
|
private System.Windows.Forms.ComboBox wnd_action_style;
|
||||||
private System.Windows.Forms.CheckBox wnd_action_overlay;
|
private System.Windows.Forms.CheckBox wnd_action_overlay;
|
||||||
|
private System.Windows.Forms.Button wnd_select_list;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using CC_Functions.Misc;
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -55,6 +56,8 @@ namespace CC_Functions.W32.Test
|
|||||||
|
|
||||||
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.getVisible(), "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);
|
private void Wnd_select_title_button_Click(object sender, EventArgs e) => 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, null);
|
private void Wnd_selet_class_button_Click(object sender, EventArgs e) => tmpWnd = Wnd32.fromMetadata(wnd_select_class_box.Text, null);
|
||||||
|
@ -82,6 +82,10 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Misc\Misc.csproj">
|
||||||
|
<Project>{B80D5E09-B935-4602-A173-BAF7C1974999}</Project>
|
||||||
|
<Name>Misc</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\W32\W32.csproj">
|
<ProjectReference Include="..\W32\W32.csproj">
|
||||||
<Project>{23de4ae0-5075-4ccc-8440-4d131ca0fbba}</Project>
|
<Project>{23de4ae0-5075-4ccc-8440-4d131ca0fbba}</Project>
|
||||||
<Name>W32</Name>
|
<Name>W32</Name>
|
||||||
|
30
W32/Wnd32.cs
30
W32/Wnd32.cs
@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -25,6 +27,18 @@ namespace CC_Functions.W32
|
|||||||
|
|
||||||
public static Wnd32 foreground() => fromHandle(GetForegroundWindow());
|
public static Wnd32 foreground() => fromHandle(GetForegroundWindow());
|
||||||
|
|
||||||
|
public static Wnd32[] getVisible()
|
||||||
|
{
|
||||||
|
WindowHandles = new List<IntPtr>();
|
||||||
|
if (!EnumDesktopWindows(IntPtr.Zero, FilterCallback, IntPtr.Zero))
|
||||||
|
{
|
||||||
|
throw new Win32Exception("There was a native error. This should never happen!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return WindowHandles.Select(s => fromHandle(s)).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion CreateInstance
|
#endregion CreateInstance
|
||||||
|
|
||||||
#region InstanceActions
|
#region InstanceActions
|
||||||
@ -264,6 +278,22 @@ namespace CC_Functions.W32
|
|||||||
[DllImport("user32.dll", SetLastError = true)]
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", EntryPoint = "EnumDesktopWindows", ExactSpelling = false, CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
private static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumDelegate lpEnumCallbackFunction, IntPtr lParam);
|
||||||
|
|
||||||
|
// Define the callback delegate's type.
|
||||||
|
private delegate bool EnumDelegate(IntPtr hWnd, int lParam);
|
||||||
|
private static List<IntPtr> WindowHandles;
|
||||||
|
private static bool FilterCallback(IntPtr hWnd, int lParam)
|
||||||
|
{
|
||||||
|
StringBuilder sb_title = new StringBuilder(1024);
|
||||||
|
GetWindowText(hWnd, sb_title, sb_title.Capacity);
|
||||||
|
if (IsWindowVisible(hWnd) && string.IsNullOrEmpty(sb_title.ToString()) == false)
|
||||||
|
{
|
||||||
|
WindowHandles.Add(hWnd);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endregion W32
|
#endregion W32
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user