first commit
This commit is contained in:
commit
7059c64c16
|
@ -0,0 +1,512 @@
|
|||
|
||||
# Created by https://www.gitignore.io/api/csharp,visualstudio
|
||||
# Edit at https://www.gitignore.io/?templates=csharp,visualstudio
|
||||
|
||||
### Csharp ###
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
### VisualStudio ###
|
||||
|
||||
# User-specific files
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
|
||||
# Mono auto generated files
|
||||
|
||||
# Build results
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
|
||||
# MSTest test Results
|
||||
|
||||
# NUnit
|
||||
|
||||
# Build Results of an ATL Project
|
||||
|
||||
# Benchmark Results
|
||||
|
||||
# .NET Core
|
||||
|
||||
# StyleCop
|
||||
|
||||
# Files built by Visual Studio
|
||||
|
||||
# Chutzpah Test files
|
||||
|
||||
# Visual C++ cache files
|
||||
|
||||
# Visual Studio profiler
|
||||
|
||||
# Visual Studio Trace Files
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
|
||||
# TeamCity is a build add-in
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
|
||||
# Visual Studio code coverage results
|
||||
|
||||
# NCrunch
|
||||
|
||||
# MightyMoose
|
||||
|
||||
# Web workbench (sass)
|
||||
|
||||
# Installshield output folder
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
|
||||
# Click-Once directory
|
||||
|
||||
# Publish Web Output
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
|
||||
# NuGet Packages
|
||||
# NuGet Symbol Packages
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
# except build/, which is used as an MSBuild target.
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
|
||||
# Windows Store app package directories and files
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
# but keep track of directories ending in .cache
|
||||
|
||||
# Others
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
|
||||
# RIA/Silverlight projects
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
|
||||
# SQL Server files
|
||||
|
||||
# Business Intelligence projects
|
||||
|
||||
# Microsoft Fakes
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
|
||||
# Visual Studio 6 build log
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
|
||||
# Paket dependency manager
|
||||
|
||||
# FAKE - F# Make
|
||||
|
||||
# CodeRush personal settings
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
|
||||
# BizTalk build output
|
||||
|
||||
# OpenCover UI analysis results
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
|
||||
# Local History for Visual Studio
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
|
||||
# End of https://www.gitignore.io/api/csharp,visualstudio
|
|
@ -0,0 +1,37 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29230.47
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "W32", "W32\W32.csproj", "{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Misc", "Misc\Misc.csproj", "{B80D5E09-B935-4602-A173-BAF7C1974999}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "W32.Test", "W32.Test\W32.Test.csproj", "{6121A6D3-7C73-4EDE-A5A9-09DC52150824}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B80D5E09-B935-4602-A173-BAF7C1974999}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B80D5E09-B935-4602-A173-BAF7C1974999}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B80D5E09-B935-4602-A173-BAF7C1974999}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B80D5E09-B935-4602-A173-BAF7C1974999}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6121A6D3-7C73-4EDE-A5A9-09DC52150824}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6121A6D3-7C73-4EDE-A5A9-09DC52150824}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6121A6D3-7C73-4EDE-A5A9-09DC52150824}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6121A6D3-7C73-4EDE-A5A9-09DC52150824}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {259AAEE6-E7A2-4D49-BD12-FAA5F1BFEB84}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC_Functions.Misc
|
||||
{
|
||||
public static class ArrayFormatter
|
||||
{
|
||||
public static string ArrayToString(object[] Input, string Seperator = "\r\n")
|
||||
{
|
||||
try
|
||||
{
|
||||
string a = "";
|
||||
for (int i = 0; i < Input.Length; i++)
|
||||
a += Input[i].ToString() + Seperator;
|
||||
return a.Remove(a.Length - 1 - Seperator.Length);
|
||||
}
|
||||
catch { throw; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B80D5E09-B935-4602-A173-BAF7C1974999}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CC_Functions.Misc</RootNamespace>
|
||||
<AssemblyName>CC_Functions.Misc</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ArrayFormatter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Security.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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("Misc")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Misc")]
|
||||
[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("b80d5e09-b935-4602-a173-baf7c1974999")]
|
||||
|
||||
// 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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
public static class MiscFunctions
|
||||
{
|
||||
public static bool IsAdministrator => new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
|
||||
public static long GetDirectorySize(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] a = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
|
||||
long size = 0;
|
||||
for (int i = 0; i < a.Length; i++)
|
||||
{
|
||||
size += new FileInfo(a[i]).Length;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
catch { throw; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,539 @@
|
|||
namespace CC_Functions.W32.Test
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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.exit = new System.Windows.Forms.Button();
|
||||
this.keyboard_log = new System.Windows.Forms.TextBox();
|
||||
this.keyboard = new System.Windows.Forms.GroupBox();
|
||||
this.keyboard_enabled = new System.Windows.Forms.CheckBox();
|
||||
this.mouse_log = new System.Windows.Forms.TextBox();
|
||||
this.mouse_enabled = new System.Windows.Forms.CheckBox();
|
||||
this.wnd_action_pos_h_label = new System.Windows.Forms.Label();
|
||||
this.wnd_action_pos_w_label = new System.Windows.Forms.Label();
|
||||
this.wnd_action_pos_h_bar = new System.Windows.Forms.TrackBar();
|
||||
this.wnd_action_pos_w_bar = new System.Windows.Forms.TrackBar();
|
||||
this.wnd_action_pos_y_label = new System.Windows.Forms.Label();
|
||||
this.wnd_action_pos_x_label = new System.Windows.Forms.Label();
|
||||
this.wnd_action_pos_y_bar = new System.Windows.Forms.TrackBar();
|
||||
this.wnd_action_pos_x_bar = new System.Windows.Forms.TrackBar();
|
||||
this.wnd_action_pos = new System.Windows.Forms.Button();
|
||||
this.mouse = new System.Windows.Forms.GroupBox();
|
||||
this.power = new System.Windows.Forms.GroupBox();
|
||||
this.power_execute = new System.Windows.Forms.Button();
|
||||
this.power_reason_label = new System.Windows.Forms.Label();
|
||||
this.power_mod_label = new System.Windows.Forms.Label();
|
||||
this.power_mod_box = new System.Windows.Forms.ComboBox();
|
||||
this.power_reason_box = new System.Windows.Forms.ComboBox();
|
||||
this.power_mode_label = new System.Windows.Forms.Label();
|
||||
this.power_mode_box = new System.Windows.Forms.ComboBox();
|
||||
this.wnd_select_mouse = new System.Windows.Forms.Button();
|
||||
this.wnd_action_destroy = new System.Windows.Forms.Button();
|
||||
this.wnd_action_overlay = new System.Windows.Forms.Button();
|
||||
this.wnd_action_front = new System.Windows.Forms.Button();
|
||||
this.wnd_action_enabled = new System.Windows.Forms.CheckBox();
|
||||
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_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();
|
||||
this.wnd = new System.Windows.Forms.GroupBox();
|
||||
this.wnd_select_class_box = new System.Windows.Forms.TextBox();
|
||||
this.keyboard.SuspendLayout();
|
||||
((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_y_bar)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_x_bar)).BeginInit();
|
||||
this.mouse.SuspendLayout();
|
||||
this.power.SuspendLayout();
|
||||
this.wnd.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// exit
|
||||
//
|
||||
this.exit.BackColor = System.Drawing.Color.Black;
|
||||
this.exit.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.exit.ForeColor = System.Drawing.Color.White;
|
||||
this.exit.Location = new System.Drawing.Point(264, 117);
|
||||
this.exit.Name = "exit";
|
||||
this.exit.Size = new System.Drawing.Size(35, 37);
|
||||
this.exit.TabIndex = 9;
|
||||
this.exit.Text = "°";
|
||||
this.exit.UseVisualStyleBackColor = false;
|
||||
this.exit.Click += new System.EventHandler(this.Exit_Click);
|
||||
this.exit.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Exit_MouseDown);
|
||||
this.exit.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Exit_MouseMove);
|
||||
this.exit.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Exit_MouseUp);
|
||||
//
|
||||
// keyboard_log
|
||||
//
|
||||
this.keyboard_log.Location = new System.Drawing.Point(6, 42);
|
||||
this.keyboard_log.Multiline = true;
|
||||
this.keyboard_log.Name = "keyboard_log";
|
||||
this.keyboard_log.ReadOnly = true;
|
||||
this.keyboard_log.Size = new System.Drawing.Size(286, 123);
|
||||
this.keyboard_log.TabIndex = 2;
|
||||
this.keyboard_log.TextChanged += new System.EventHandler(this.Keyboard_log_TextChanged);
|
||||
//
|
||||
// keyboard
|
||||
//
|
||||
this.keyboard.Controls.Add(this.keyboard_log);
|
||||
this.keyboard.Controls.Add(this.keyboard_enabled);
|
||||
this.keyboard.Location = new System.Drawing.Point(264, 160);
|
||||
this.keyboard.Name = "keyboard";
|
||||
this.keyboard.Size = new System.Drawing.Size(298, 171);
|
||||
this.keyboard.TabIndex = 8;
|
||||
this.keyboard.TabStop = false;
|
||||
this.keyboard.Text = "CC-Functions.W32.KeyboardHook";
|
||||
//
|
||||
// keyboard_enabled
|
||||
//
|
||||
this.keyboard_enabled.AutoSize = true;
|
||||
this.keyboard_enabled.Location = new System.Drawing.Point(6, 19);
|
||||
this.keyboard_enabled.Name = "keyboard_enabled";
|
||||
this.keyboard_enabled.Size = new System.Drawing.Size(65, 17);
|
||||
this.keyboard_enabled.TabIndex = 0;
|
||||
this.keyboard_enabled.Text = "Enabled";
|
||||
this.keyboard_enabled.UseVisualStyleBackColor = true;
|
||||
this.keyboard_enabled.CheckedChanged += new System.EventHandler(this.Keyboard_enabled_CheckedChanged);
|
||||
//
|
||||
// mouse_log
|
||||
//
|
||||
this.mouse_log.Location = new System.Drawing.Point(6, 42);
|
||||
this.mouse_log.Multiline = true;
|
||||
this.mouse_log.Name = "mouse_log";
|
||||
this.mouse_log.ReadOnly = true;
|
||||
this.mouse_log.Size = new System.Drawing.Size(245, 95);
|
||||
this.mouse_log.TabIndex = 1;
|
||||
this.mouse_log.TextChanged += new System.EventHandler(this.Mouse_log_TextChanged);
|
||||
//
|
||||
// mouse_enabled
|
||||
//
|
||||
this.mouse_enabled.AutoSize = true;
|
||||
this.mouse_enabled.Location = new System.Drawing.Point(6, 19);
|
||||
this.mouse_enabled.Name = "mouse_enabled";
|
||||
this.mouse_enabled.Size = new System.Drawing.Size(65, 17);
|
||||
this.mouse_enabled.TabIndex = 0;
|
||||
this.mouse_enabled.Text = "Enabled";
|
||||
this.mouse_enabled.UseVisualStyleBackColor = true;
|
||||
this.mouse_enabled.CheckedChanged += new System.EventHandler(this.Mouse_enabled_CheckedChanged);
|
||||
//
|
||||
// wnd_action_pos_h_label
|
||||
//
|
||||
this.wnd_action_pos_h_label.AutoSize = true;
|
||||
this.wnd_action_pos_h_label.Location = new System.Drawing.Point(116, 185);
|
||||
this.wnd_action_pos_h_label.Name = "wnd_action_pos_h_label";
|
||||
this.wnd_action_pos_h_label.Size = new System.Drawing.Size(18, 13);
|
||||
this.wnd_action_pos_h_label.TabIndex = 19;
|
||||
this.wnd_action_pos_h_label.Text = "H:";
|
||||
//
|
||||
// wnd_action_pos_w_label
|
||||
//
|
||||
this.wnd_action_pos_w_label.AutoSize = true;
|
||||
this.wnd_action_pos_w_label.Location = new System.Drawing.Point(116, 161);
|
||||
this.wnd_action_pos_w_label.Name = "wnd_action_pos_w_label";
|
||||
this.wnd_action_pos_w_label.Size = new System.Drawing.Size(21, 13);
|
||||
this.wnd_action_pos_w_label.TabIndex = 18;
|
||||
this.wnd_action_pos_w_label.Text = "W:";
|
||||
//
|
||||
// wnd_action_pos_h_bar
|
||||
//
|
||||
this.wnd_action_pos_h_bar.Location = new System.Drawing.Point(136, 185);
|
||||
this.wnd_action_pos_h_bar.Name = "wnd_action_pos_h_bar";
|
||||
this.wnd_action_pos_h_bar.Size = new System.Drawing.Size(104, 45);
|
||||
this.wnd_action_pos_h_bar.TabIndex = 21;
|
||||
//
|
||||
// wnd_action_pos_w_bar
|
||||
//
|
||||
this.wnd_action_pos_w_bar.Location = new System.Drawing.Point(136, 161);
|
||||
this.wnd_action_pos_w_bar.Name = "wnd_action_pos_w_bar";
|
||||
this.wnd_action_pos_w_bar.Size = new System.Drawing.Size(104, 45);
|
||||
this.wnd_action_pos_w_bar.TabIndex = 20;
|
||||
//
|
||||
// wnd_action_pos_y_label
|
||||
//
|
||||
this.wnd_action_pos_y_label.AutoSize = true;
|
||||
this.wnd_action_pos_y_label.Location = new System.Drawing.Point(6, 185);
|
||||
this.wnd_action_pos_y_label.Name = "wnd_action_pos_y_label";
|
||||
this.wnd_action_pos_y_label.Size = new System.Drawing.Size(17, 13);
|
||||
this.wnd_action_pos_y_label.TabIndex = 15;
|
||||
this.wnd_action_pos_y_label.Text = "Y:";
|
||||
//
|
||||
// wnd_action_pos_x_label
|
||||
//
|
||||
this.wnd_action_pos_x_label.AutoSize = true;
|
||||
this.wnd_action_pos_x_label.Location = new System.Drawing.Point(6, 161);
|
||||
this.wnd_action_pos_x_label.Name = "wnd_action_pos_x_label";
|
||||
this.wnd_action_pos_x_label.Size = new System.Drawing.Size(17, 13);
|
||||
this.wnd_action_pos_x_label.TabIndex = 13;
|
||||
this.wnd_action_pos_x_label.Text = "X:";
|
||||
//
|
||||
// wnd_action_pos_y_bar
|
||||
//
|
||||
this.wnd_action_pos_y_bar.Location = new System.Drawing.Point(17, 185);
|
||||
this.wnd_action_pos_y_bar.Name = "wnd_action_pos_y_bar";
|
||||
this.wnd_action_pos_y_bar.Size = new System.Drawing.Size(104, 45);
|
||||
this.wnd_action_pos_y_bar.TabIndex = 17;
|
||||
//
|
||||
// wnd_action_pos_x_bar
|
||||
//
|
||||
this.wnd_action_pos_x_bar.Location = new System.Drawing.Point(17, 161);
|
||||
this.wnd_action_pos_x_bar.Name = "wnd_action_pos_x_bar";
|
||||
this.wnd_action_pos_x_bar.Size = new System.Drawing.Size(104, 45);
|
||||
this.wnd_action_pos_x_bar.TabIndex = 16;
|
||||
//
|
||||
// wnd_action_pos
|
||||
//
|
||||
this.wnd_action_pos.Location = new System.Drawing.Point(87, 135);
|
||||
this.wnd_action_pos.Name = "wnd_action_pos";
|
||||
this.wnd_action_pos.Size = new System.Drawing.Size(75, 23);
|
||||
this.wnd_action_pos.TabIndex = 14;
|
||||
this.wnd_action_pos.Text = "Set Position";
|
||||
this.wnd_action_pos.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_pos.Click += new System.EventHandler(this.Wnd_action_pos_Click);
|
||||
//
|
||||
// mouse
|
||||
//
|
||||
this.mouse.Controls.Add(this.mouse_log);
|
||||
this.mouse.Controls.Add(this.mouse_enabled);
|
||||
this.mouse.Location = new System.Drawing.Point(305, 11);
|
||||
this.mouse.Name = "mouse";
|
||||
this.mouse.Size = new System.Drawing.Size(257, 143);
|
||||
this.mouse.TabIndex = 7;
|
||||
this.mouse.TabStop = false;
|
||||
this.mouse.Text = "CC-Functions.W32.MouseHook";
|
||||
//
|
||||
// power
|
||||
//
|
||||
this.power.Controls.Add(this.power_execute);
|
||||
this.power.Controls.Add(this.power_reason_label);
|
||||
this.power.Controls.Add(this.power_mod_label);
|
||||
this.power.Controls.Add(this.power_mod_box);
|
||||
this.power.Controls.Add(this.power_reason_box);
|
||||
this.power.Controls.Add(this.power_mode_label);
|
||||
this.power.Controls.Add(this.power_mode_box);
|
||||
this.power.Location = new System.Drawing.Point(12, 11);
|
||||
this.power.Name = "power";
|
||||
this.power.Size = new System.Drawing.Size(287, 100);
|
||||
this.power.TabIndex = 5;
|
||||
this.power.TabStop = false;
|
||||
this.power.Text = "CC-Functions.W32.Power";
|
||||
//
|
||||
// power_execute
|
||||
//
|
||||
this.power_execute.BackColor = System.Drawing.Color.DarkRed;
|
||||
this.power_execute.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.power_execute.ForeColor = System.Drawing.Color.White;
|
||||
this.power_execute.Location = new System.Drawing.Point(200, 19);
|
||||
this.power_execute.Name = "power_execute";
|
||||
this.power_execute.Size = new System.Drawing.Size(81, 75);
|
||||
this.power_execute.TabIndex = 6;
|
||||
this.power_execute.Text = "DO IT";
|
||||
this.power_execute.UseVisualStyleBackColor = false;
|
||||
this.power_execute.Click += new System.EventHandler(this.Power_execute_Click);
|
||||
//
|
||||
// power_reason_label
|
||||
//
|
||||
this.power_reason_label.AutoSize = true;
|
||||
this.power_reason_label.Location = new System.Drawing.Point(6, 49);
|
||||
this.power_reason_label.Name = "power_reason_label";
|
||||
this.power_reason_label.Size = new System.Drawing.Size(44, 13);
|
||||
this.power_reason_label.TabIndex = 5;
|
||||
this.power_reason_label.Text = "Reason";
|
||||
//
|
||||
// power_mod_label
|
||||
//
|
||||
this.power_mod_label.AutoSize = true;
|
||||
this.power_mod_label.Location = new System.Drawing.Point(6, 76);
|
||||
this.power_mod_label.Name = "power_mod_label";
|
||||
this.power_mod_label.Size = new System.Drawing.Size(28, 13);
|
||||
this.power_mod_label.TabIndex = 4;
|
||||
this.power_mod_label.Text = "Mod";
|
||||
//
|
||||
// power_mod_box
|
||||
//
|
||||
this.power_mod_box.FormattingEnabled = true;
|
||||
this.power_mod_box.Location = new System.Drawing.Point(56, 73);
|
||||
this.power_mod_box.Name = "power_mod_box";
|
||||
this.power_mod_box.Size = new System.Drawing.Size(138, 21);
|
||||
this.power_mod_box.TabIndex = 2;
|
||||
//
|
||||
// power_reason_box
|
||||
//
|
||||
this.power_reason_box.FormattingEnabled = true;
|
||||
this.power_reason_box.Location = new System.Drawing.Point(56, 46);
|
||||
this.power_reason_box.Name = "power_reason_box";
|
||||
this.power_reason_box.Size = new System.Drawing.Size(138, 21);
|
||||
this.power_reason_box.TabIndex = 3;
|
||||
//
|
||||
// power_mode_label
|
||||
//
|
||||
this.power_mode_label.AutoSize = true;
|
||||
this.power_mode_label.Location = new System.Drawing.Point(6, 22);
|
||||
this.power_mode_label.Name = "power_mode_label";
|
||||
this.power_mode_label.Size = new System.Drawing.Size(34, 13);
|
||||
this.power_mode_label.TabIndex = 1;
|
||||
this.power_mode_label.Text = "Mode";
|
||||
//
|
||||
// power_mode_box
|
||||
//
|
||||
this.power_mode_box.FormattingEnabled = true;
|
||||
this.power_mode_box.Location = new System.Drawing.Point(56, 19);
|
||||
this.power_mode_box.Name = "power_mode_box";
|
||||
this.power_mode_box.Size = new System.Drawing.Size(138, 21);
|
||||
this.power_mode_box.TabIndex = 0;
|
||||
//
|
||||
// wnd_select_mouse
|
||||
//
|
||||
this.wnd_select_mouse.Location = new System.Drawing.Point(190, 19);
|
||||
this.wnd_select_mouse.Name = "wnd_select_mouse";
|
||||
this.wnd_select_mouse.Size = new System.Drawing.Size(50, 23);
|
||||
this.wnd_select_mouse.TabIndex = 12;
|
||||
this.wnd_select_mouse.Text = "Mouse";
|
||||
this.wnd_select_mouse.UseVisualStyleBackColor = true;
|
||||
this.wnd_select_mouse.Click += new System.EventHandler(this.Wnd_select_mouse_Click);
|
||||
//
|
||||
// wnd_action_destroy
|
||||
//
|
||||
this.wnd_action_destroy.Location = new System.Drawing.Point(6, 135);
|
||||
this.wnd_action_destroy.Name = "wnd_action_destroy";
|
||||
this.wnd_action_destroy.Size = new System.Drawing.Size(75, 23);
|
||||
this.wnd_action_destroy.TabIndex = 2;
|
||||
this.wnd_action_destroy.Text = "Destroy";
|
||||
this.wnd_action_destroy.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_destroy.Click += new System.EventHandler(this.Wnd_action_destroy_Click);
|
||||
//
|
||||
// wnd_action_overlay
|
||||
//
|
||||
this.wnd_action_overlay.Location = new System.Drawing.Point(158, 106);
|
||||
this.wnd_action_overlay.Name = "wnd_action_overlay";
|
||||
this.wnd_action_overlay.Size = new System.Drawing.Size(79, 23);
|
||||
this.wnd_action_overlay.TabIndex = 11;
|
||||
this.wnd_action_overlay.Text = "Overlay";
|
||||
this.wnd_action_overlay.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_overlay.Click += new System.EventHandler(this.Wnd_action_overlay_Click);
|
||||
//
|
||||
// wnd_action_front
|
||||
//
|
||||
this.wnd_action_front.Location = new System.Drawing.Point(77, 106);
|
||||
this.wnd_action_front.Name = "wnd_action_front";
|
||||
this.wnd_action_front.Size = new System.Drawing.Size(75, 23);
|
||||
this.wnd_action_front.TabIndex = 10;
|
||||
this.wnd_action_front.Text = "To Front";
|
||||
this.wnd_action_front.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_front.Click += new System.EventHandler(this.Wnd_action_front_Click);
|
||||
//
|
||||
// wnd_action_enabled
|
||||
//
|
||||
this.wnd_action_enabled.AutoSize = true;
|
||||
this.wnd_action_enabled.Location = new System.Drawing.Point(6, 110);
|
||||
this.wnd_action_enabled.Name = "wnd_action_enabled";
|
||||
this.wnd_action_enabled.Size = new System.Drawing.Size(65, 17);
|
||||
this.wnd_action_enabled.TabIndex = 9;
|
||||
this.wnd_action_enabled.Text = "Enabled";
|
||||
this.wnd_action_enabled.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_enabled.CheckedChanged += new System.EventHandler(this.Wnd_action_enabled_CheckedChanged);
|
||||
//
|
||||
// wnd_action_title_get
|
||||
//
|
||||
this.wnd_action_title_get.Location = new System.Drawing.Point(200, 77);
|
||||
this.wnd_action_title_get.Name = "wnd_action_title_get";
|
||||
this.wnd_action_title_get.Size = new System.Drawing.Size(37, 23);
|
||||
this.wnd_action_title_get.TabIndex = 8;
|
||||
this.wnd_action_title_get.Text = "Get";
|
||||
this.wnd_action_title_get.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_title_get.Click += new System.EventHandler(this.Wnd_action_title_get_Click);
|
||||
//
|
||||
// wnd_action_title_set
|
||||
//
|
||||
this.wnd_action_title_set.Location = new System.Drawing.Point(200, 48);
|
||||
this.wnd_action_title_set.Name = "wnd_action_title_set";
|
||||
this.wnd_action_title_set.Size = new System.Drawing.Size(37, 23);
|
||||
this.wnd_action_title_set.TabIndex = 7;
|
||||
this.wnd_action_title_set.Text = "Set";
|
||||
this.wnd_action_title_set.UseVisualStyleBackColor = true;
|
||||
this.wnd_action_title_set.Click += new System.EventHandler(this.Wnd_action_title_set_Click);
|
||||
//
|
||||
// wnd_select_title_box
|
||||
//
|
||||
this.wnd_select_title_box.Location = new System.Drawing.Point(93, 50);
|
||||
this.wnd_select_title_box.Name = "wnd_select_title_box";
|
||||
this.wnd_select_title_box.Size = new System.Drawing.Size(101, 20);
|
||||
this.wnd_select_title_box.TabIndex = 6;
|
||||
//
|
||||
// wnd_selet_class_button
|
||||
//
|
||||
this.wnd_selet_class_button.Location = new System.Drawing.Point(6, 77);
|
||||
this.wnd_selet_class_button.Name = "wnd_selet_class_button";
|
||||
this.wnd_selet_class_button.Size = new System.Drawing.Size(81, 23);
|
||||
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);
|
||||
//
|
||||
// wnd_select_title_button
|
||||
//
|
||||
this.wnd_select_title_button.Location = new System.Drawing.Point(6, 48);
|
||||
this.wnd_select_title_button.Name = "wnd_select_title_button";
|
||||
this.wnd_select_title_button.Size = new System.Drawing.Size(81, 23);
|
||||
this.wnd_select_title_button.TabIndex = 2;
|
||||
this.wnd_select_title_button.Text = "Select (title):";
|
||||
this.wnd_select_title_button.UseVisualStyleBackColor = true;
|
||||
this.wnd_select_title_button.Click += new System.EventHandler(this.Wnd_select_title_button_Click);
|
||||
//
|
||||
// wnd_select_selected
|
||||
//
|
||||
this.wnd_select_selected.AutoSize = true;
|
||||
this.wnd_select_selected.Location = new System.Drawing.Point(93, 24);
|
||||
this.wnd_select_selected.Name = "wnd_select_selected";
|
||||
this.wnd_select_selected.Size = new System.Drawing.Size(91, 13);
|
||||
this.wnd_select_selected.TabIndex = 1;
|
||||
this.wnd_select_selected.Text = "Selected: 123456";
|
||||
//
|
||||
// wnd_select_self
|
||||
//
|
||||
this.wnd_select_self.Location = new System.Drawing.Point(6, 19);
|
||||
this.wnd_select_self.Name = "wnd_select_self";
|
||||
this.wnd_select_self.Size = new System.Drawing.Size(81, 23);
|
||||
this.wnd_select_self.TabIndex = 0;
|
||||
this.wnd_select_self.Text = "Select self";
|
||||
this.wnd_select_self.UseVisualStyleBackColor = true;
|
||||
this.wnd_select_self.Click += new System.EventHandler(this.Wnd_select_self_Click);
|
||||
//
|
||||
// wnd
|
||||
//
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_h_label);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_w_label);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_h_bar);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_w_bar);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_y_label);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_x_label);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_y_bar);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos_x_bar);
|
||||
this.wnd.Controls.Add(this.wnd_action_pos);
|
||||
this.wnd.Controls.Add(this.wnd_select_mouse);
|
||||
this.wnd.Controls.Add(this.wnd_action_destroy);
|
||||
this.wnd.Controls.Add(this.wnd_action_overlay);
|
||||
this.wnd.Controls.Add(this.wnd_action_front);
|
||||
this.wnd.Controls.Add(this.wnd_action_enabled);
|
||||
this.wnd.Controls.Add(this.wnd_action_title_get);
|
||||
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_title_button);
|
||||
this.wnd.Controls.Add(this.wnd_select_selected);
|
||||
this.wnd.Controls.Add(this.wnd_select_self);
|
||||
this.wnd.Location = new System.Drawing.Point(12, 117);
|
||||
this.wnd.Name = "wnd";
|
||||
this.wnd.Size = new System.Drawing.Size(246, 214);
|
||||
this.wnd.TabIndex = 6;
|
||||
this.wnd.TabStop = false;
|
||||
this.wnd.Text = "CC-Functions.W32.Wnd32";
|
||||
//
|
||||
// wnd_select_class_box
|
||||
//
|
||||
this.wnd_select_class_box.Location = new System.Drawing.Point(93, 79);
|
||||
this.wnd_select_class_box.Name = "wnd_select_class_box";
|
||||
this.wnd_select_class_box.Size = new System.Drawing.Size(101, 20);
|
||||
this.wnd_select_class_box.TabIndex = 5;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(574, 342);
|
||||
this.Controls.Add(this.exit);
|
||||
this.Controls.Add(this.keyboard);
|
||||
this.Controls.Add(this.mouse);
|
||||
this.Controls.Add(this.power);
|
||||
this.Controls.Add(this.wnd);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
this.MaximizeBox = false;
|
||||
this.Name = "Form1";
|
||||
this.Text = "CC-Functions.W32.Test";
|
||||
this.keyboard.ResumeLayout(false);
|
||||
this.keyboard.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_h_bar)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_w_bar)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_y_bar)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.wnd_action_pos_x_bar)).EndInit();
|
||||
this.mouse.ResumeLayout(false);
|
||||
this.mouse.PerformLayout();
|
||||
this.power.ResumeLayout(false);
|
||||
this.power.PerformLayout();
|
||||
this.wnd.ResumeLayout(false);
|
||||
this.wnd.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button exit;
|
||||
private System.Windows.Forms.TextBox keyboard_log;
|
||||
private System.Windows.Forms.GroupBox keyboard;
|
||||
private System.Windows.Forms.CheckBox keyboard_enabled;
|
||||
private System.Windows.Forms.TextBox mouse_log;
|
||||
private System.Windows.Forms.CheckBox mouse_enabled;
|
||||
private System.Windows.Forms.Label wnd_action_pos_h_label;
|
||||
private System.Windows.Forms.Label wnd_action_pos_w_label;
|
||||
private System.Windows.Forms.TrackBar wnd_action_pos_h_bar;
|
||||
private System.Windows.Forms.TrackBar wnd_action_pos_w_bar;
|
||||
private System.Windows.Forms.Label wnd_action_pos_y_label;
|
||||
private System.Windows.Forms.Label wnd_action_pos_x_label;
|
||||
private System.Windows.Forms.TrackBar wnd_action_pos_y_bar;
|
||||
private System.Windows.Forms.TrackBar wnd_action_pos_x_bar;
|
||||
private System.Windows.Forms.Button wnd_action_pos;
|
||||
private System.Windows.Forms.GroupBox mouse;
|
||||
private System.Windows.Forms.GroupBox power;
|
||||
private System.Windows.Forms.Button power_execute;
|
||||
private System.Windows.Forms.Label power_reason_label;
|
||||
private System.Windows.Forms.Label power_mod_label;
|
||||
private System.Windows.Forms.ComboBox power_mod_box;
|
||||
private System.Windows.Forms.ComboBox power_reason_box;
|
||||
private System.Windows.Forms.Label power_mode_label;
|
||||
private System.Windows.Forms.ComboBox power_mode_box;
|
||||
private System.Windows.Forms.Button wnd_select_mouse;
|
||||
private System.Windows.Forms.Button wnd_action_destroy;
|
||||
private System.Windows.Forms.Button wnd_action_overlay;
|
||||
private System.Windows.Forms.Button wnd_action_front;
|
||||
private System.Windows.Forms.CheckBox wnd_action_enabled;
|
||||
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_title_button;
|
||||
private System.Windows.Forms.Label wnd_select_selected;
|
||||
private System.Windows.Forms.Button wnd_select_self;
|
||||
private System.Windows.Forms.GroupBox wnd;
|
||||
private System.Windows.Forms.TextBox wnd_select_class_box;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
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 CC_Functions.W32;
|
||||
using static CC_Functions.W32.Power;
|
||||
|
||||
namespace CC_Functions.W32.Test
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
MouseHook mHook;
|
||||
KeyboardHook kHook;
|
||||
public static Wnd32 tmpWnd;
|
||||
public static Form1 mainF;
|
||||
public static Form frm;
|
||||
public static Label lab;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
mainF = this;
|
||||
tmpWnd = Wnd32.fromForm(this);
|
||||
#if DEBUG
|
||||
tmpWnd.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();
|
||||
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;
|
||||
}
|
||||
|
||||
public void set_up_box(ComboBox box, Type enumT)
|
||||
{
|
||||
box.DataSource = Enum.GetNames(enumT);
|
||||
var tmp = Enum.GetValues(enumT);
|
||||
box.Tag = new object[tmp.Length];
|
||||
int i = 0;
|
||||
foreach (object o in tmp)
|
||||
{
|
||||
((object[])box.Tag)[i] = o;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
public object get_box_value(ComboBox 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_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_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)
|
||||
{
|
||||
wnd_select_title_box.Text = tmpWnd.title;
|
||||
wnd_action_enabled.Enabled = tmpWnd.enabled;
|
||||
wnd_select_selected.Text = "Selected: " + tmpWnd.hWnd.ToString();
|
||||
try { wnd_action_pos_x_bar.Value = tmpWnd.position.X; } catch { }
|
||||
try { wnd_action_pos_y_bar.Value = tmpWnd.position.Y; } catch { }
|
||||
try { wnd_action_pos_w_bar.Value = tmpWnd.position.Width; } catch { }
|
||||
try { wnd_action_pos_h_bar.Value = tmpWnd.position.Height; } catch { }
|
||||
}
|
||||
|
||||
private void Wnd_action_enabled_CheckedChanged(object sender, EventArgs e) => tmpWnd.enabled = wnd_action_enabled.Enabled;
|
||||
|
||||
private void Wnd_action_front_Click(object sender, EventArgs e) => tmpWnd.isForeground = true;
|
||||
|
||||
private void Wnd_action_overlay_Click(object sender, EventArgs e) => tmpWnd.MakeOverlay();
|
||||
|
||||
private void Wnd_action_destroy_Click(object sender, EventArgs e) => tmpWnd.Destroy();
|
||||
|
||||
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();
|
||||
frm.Controls.Add(lab);
|
||||
frm.Show();
|
||||
Wnd32.fromForm(frm).MakeOverlay();
|
||||
}
|
||||
|
||||
private void Frm_Click(object sender, EventArgs e)
|
||||
{
|
||||
frm.Hide();
|
||||
frm.WindowState = FormWindowState.Minimized;
|
||||
Wnd32 tmp = Wnd32.fromPoint(MousePosition);
|
||||
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);
|
||||
}
|
||||
|
||||
private void Mouse_enabled_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (mouse_enabled.Checked)
|
||||
{
|
||||
mHook.OnMouse += MHook_OnMouse;
|
||||
}
|
||||
else
|
||||
{
|
||||
mHook.OnMouse -= MHook_OnMouse;
|
||||
}
|
||||
}
|
||||
|
||||
private void MHook_OnMouse(MouseHookEventArgs _args)
|
||||
{
|
||||
mouse_log.Text = _args.Message.ToString() + " -|- " + _args.Point.ToString() + "\r\n" + mouse_log.Text;
|
||||
}
|
||||
|
||||
private void Mouse_log_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (mouse_log.Lines.Length > 10)
|
||||
{
|
||||
var tmp = mouse_log.Lines.ToList();
|
||||
tmp.RemoveRange(9, mouse_log.Lines.Length - 9);
|
||||
mouse_log.Lines = tmp.ToArray();
|
||||
tmp = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void Keyboard_enabled_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (keyboard_enabled.Checked)
|
||||
{
|
||||
kHook.OnKeyPress += KHook_OnKeyPress;
|
||||
}
|
||||
else
|
||||
{
|
||||
kHook.OnKeyPress -= KHook_OnKeyPress;
|
||||
}
|
||||
}
|
||||
|
||||
private void KHook_OnKeyPress(KeyboardHookEventArgs _args)
|
||||
{
|
||||
keyboard_log.Text = _args.Key.ToString() + "\r\n" + keyboard_log.Text;
|
||||
}
|
||||
|
||||
private void Keyboard_log_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (keyboard_log.Lines.Length > 10)
|
||||
{
|
||||
var tmp = keyboard_log.Lines.ToList();
|
||||
tmp.RemoveRange(9, keyboard_log.Lines.Length - 9);
|
||||
keyboard_log.Lines = tmp.ToArray();
|
||||
tmp = null;
|
||||
}
|
||||
}
|
||||
|
||||
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, wnd_action_pos_w_bar.Value, wnd_action_pos_h_bar.Value);
|
||||
}
|
||||
|
||||
private void Exit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if ((DateTime.Now - mST).TotalSeconds < 0.15f)
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
bool moving;
|
||||
Point locDelB;
|
||||
DateTime mST;
|
||||
private void Exit_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (moving && (DateTime.Now - mST).TotalSeconds >= 0.1f)
|
||||
Location = new Point(locDelB.X + Cursor.Position.X, locDelB.Y + Cursor.Position.Y);
|
||||
}
|
||||
|
||||
private void Exit_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
mST = DateTime.Now;
|
||||
locDelB = new Point(Location.X - Cursor.Position.X, Location.Y - Cursor.Position.Y);
|
||||
moving = true;
|
||||
}
|
||||
|
||||
private void Exit_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
moving = false;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -0,0 +1,22 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CC_Functions.W32.Test
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,63 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
<?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>
|
|
@ -0,0 +1,26 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <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.2.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
<?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>
|
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{6121A6D3-7C73-4EDE-A5A9-09DC52150824}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<RootNamespace>CC_Functions.W32.Test</RootNamespace>
|
||||
<AssemblyName>CC_Functions.W32.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Form1.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Form1.Designer.cs">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Form1.resx">
|
||||
<DependentUpon>Form1.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\W32\W32.csproj">
|
||||
<Project>{23de4ae0-5075-4ccc-8440-4d131ca0fbba}</Project>
|
||||
<Name>W32</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,187 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Drawing;
|
||||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public class KeyboardHookEventArgs : EventArgs
|
||||
{
|
||||
public KeyboardHookEventArgs(Keys key)
|
||||
{
|
||||
Key = key;
|
||||
}
|
||||
|
||||
public Keys Key { get; }
|
||||
public override string ToString() => Key.ToString();
|
||||
}
|
||||
|
||||
public class KeyboardHook : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
instances.Remove(this);
|
||||
if (instances.Count == 0)
|
||||
UnhookWindowsHookEx(_hookID);
|
||||
}
|
||||
|
||||
private static List<KeyboardHook> instances = new List<KeyboardHook>();
|
||||
private const int WH_KEYBOARD_LL = 13;
|
||||
private const int WM_KEYDOWN = 0x0100;
|
||||
private static LowLevelKeyboardProc _proc = HookCallback;
|
||||
private static IntPtr _hookID = IntPtr.Zero;
|
||||
public delegate void keyPress(KeyboardHookEventArgs _args);
|
||||
public event keyPress OnKeyPress;
|
||||
|
||||
public KeyboardHook()
|
||||
{
|
||||
if (instances.Count == 0)
|
||||
_hookID = SetHook(_proc);
|
||||
instances.Add(this);
|
||||
}
|
||||
|
||||
private IntPtr SetHook(LowLevelKeyboardProc proc)
|
||||
{
|
||||
using (Process curProcess = Process.GetCurrentProcess())
|
||||
using (ProcessModule curModule = curProcess.MainModule)
|
||||
{
|
||||
return SetWindowsHookEx(WH_KEYBOARD_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
|
||||
{
|
||||
int vkCode = Marshal.ReadInt32(lParam);
|
||||
for (int i = 0; i < instances.Count; i++)
|
||||
{
|
||||
instances[i].OnKeyPress?.Invoke(new KeyboardHookEventArgs((Keys)vkCode));
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(_hookID, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
}
|
||||
|
||||
public class MouseHookEventArgs : EventArgs {
|
||||
public MouseHookEventArgs(Point point, MouseHook.MouseMessages message)
|
||||
{
|
||||
Point = point;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public Point Point { get; }
|
||||
public MouseHook.MouseMessages Message { get; }
|
||||
public override string ToString()
|
||||
{
|
||||
return Message.ToString() + "; " + Point.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class MouseHook : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
instances.Remove(this);
|
||||
if (instances.Count == 0)
|
||||
UnhookWindowsHookEx(_hookID);
|
||||
}
|
||||
|
||||
private static List<MouseHook> instances = new List<MouseHook>();
|
||||
private static LowLevelMouseProc _proc = HookCallback;
|
||||
private static IntPtr _hookID = IntPtr.Zero;
|
||||
public delegate void mouseEvent(MouseHookEventArgs _args);
|
||||
public event mouseEvent OnMouse;
|
||||
|
||||
public MouseHook()
|
||||
{
|
||||
if (instances.Count == 0)
|
||||
_hookID = SetHook(_proc);
|
||||
instances.Add(this);
|
||||
}
|
||||
|
||||
private static IntPtr SetHook(LowLevelMouseProc proc)
|
||||
{
|
||||
using (Process curProcess = Process.GetCurrentProcess())
|
||||
using (ProcessModule curModule = curProcess.MainModule)
|
||||
{
|
||||
return SetWindowsHookEx(WH_MOUSE_LL, proc, GetModuleHandle(curModule.ModuleName), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
|
||||
{
|
||||
if (nCode >= 0)
|
||||
{
|
||||
MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
|
||||
for (int i = 0; i < instances.Count; i++)
|
||||
{
|
||||
instances[i].OnMouse?.Invoke(new MouseHookEventArgs(new Point(hookStruct.pt.x, hookStruct.pt.y), (MouseMessages)wParam));
|
||||
}
|
||||
}
|
||||
return CallNextHookEx(_hookID, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
private const int WH_MOUSE_LL = 14;
|
||||
public enum MouseMessages
|
||||
{
|
||||
WM_LBUTTONDOWN = 0x0201,
|
||||
WM_LBUTTONUP = 0x0202,
|
||||
WM_MOUSEMOVE = 0x0200,
|
||||
WM_MOUSEWHEEL = 0x020A,
|
||||
WM_RBUTTONDOWN = 0x0204,
|
||||
WM_RBUTTONUP = 0x0205
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct POINT
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct MSLLHOOKSTRUCT
|
||||
{
|
||||
public POINT pt;
|
||||
public uint mouseData;
|
||||
public uint flags;
|
||||
public uint time;
|
||||
public IntPtr dwExtraInfo;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr SetWindowsHookEx(int idHook, LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool UnhookWindowsHookEx(IntPtr hhk);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
private static extern IntPtr GetModuleHandle(string lpModuleName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public static class Power
|
||||
{
|
||||
[DllImport("ntdll.dll", SetLastError = true)]
|
||||
public static extern IntPtr RtlAdjustPrivilege(int Privilege, bool bEnablePrivilege, bool IsThreadPrivilege, out bool PreviousValue);
|
||||
[DllImport("ntdll.dll")]
|
||||
private static extern uint NtRaiseHardError(
|
||||
uint ErrorStatus,
|
||||
uint NumberOfParameters,
|
||||
uint UnicodeStringParameterMask,
|
||||
IntPtr Parameters,
|
||||
uint ValidResponseOption,
|
||||
out uint Response
|
||||
);
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool ExitWindowsEx(ExitWindows uFlags, ShutdownReason dwReason);
|
||||
[Flags]
|
||||
public enum ShutdownReason : uint
|
||||
{
|
||||
MajorApplication = 0x00040000,
|
||||
MajorHardware = 0x00010000,
|
||||
MajorLegacyApi = 0x00070000,
|
||||
MajorOperatingSystem = 0x00020000,
|
||||
MajorOther = 0x00000000,
|
||||
MajorPower = 0x00060000,
|
||||
MajorSoftware = 0x00030000,
|
||||
MajorSystem = 0x00050000,
|
||||
|
||||
MinorBlueScreen = 0x0000000F,
|
||||
MinorCordUnplugged = 0x0000000b,
|
||||
MinorDisk = 0x00000007,
|
||||
MinorEnvironment = 0x0000000c,
|
||||
MinorHardwareDriver = 0x0000000d,
|
||||
MinorHotfix = 0x00000011,
|
||||
MinorHung = 0x00000005,
|
||||
MinorInstallation = 0x00000002,
|
||||
MinorMaintenance = 0x00000001,
|
||||
MinorMMC = 0x00000019,
|
||||
MinorNetworkConnectivity = 0x00000014,
|
||||
MinorNetworkCard = 0x00000009,
|
||||
MinorOther = 0x00000000,
|
||||
MinorOtherDriver = 0x0000000e,
|
||||
MinorPowerSupply = 0x0000000a,
|
||||
MinorProcessor = 0x00000008,
|
||||
MinorReconfig = 0x00000004,
|
||||
MinorSecurity = 0x00000013,
|
||||
MinorSecurityFix = 0x00000012,
|
||||
MinorSecurityFixUninstall = 0x00000018,
|
||||
MinorServicePack = 0x00000010,
|
||||
MinorServicePackUninstall = 0x00000016,
|
||||
MinorTermSrv = 0x00000020,
|
||||
MinorUnstable = 0x00000006,
|
||||
MinorUpgrade = 0x00000003,
|
||||
MinorWMI = 0x00000015,
|
||||
|
||||
FlagUserDefined = 0x40000000,
|
||||
FlagPlanned = 0x80000000
|
||||
}
|
||||
[Flags]
|
||||
public enum ExitWindows : uint
|
||||
{
|
||||
// ONE of the following five:
|
||||
LogOff = 0x00,
|
||||
ShutDown = 0x01,
|
||||
Reboot = 0x02,
|
||||
PowerOff = 0x08,
|
||||
RestartApps = 0x40,
|
||||
// plus AT MOST ONE of the following two:
|
||||
Force = 0x04,
|
||||
ForceIfHung = 0x10,
|
||||
}
|
||||
[Flags]
|
||||
public enum ShutdownMode : uint
|
||||
{
|
||||
LogOff = 0x00,
|
||||
ShutDown = 0x01,
|
||||
Reboot = 0x02,
|
||||
PowerOff = 0x08,
|
||||
RestartApps = 0x40,
|
||||
BSoD = 0x29a
|
||||
}
|
||||
[Flags]
|
||||
public enum ShutdownMod : uint
|
||||
{
|
||||
None = 0x00,
|
||||
Force = 0x04,
|
||||
ForceIfHung = 0x10
|
||||
}
|
||||
public static unsafe void RaiseEvent(ShutdownMode mode, ShutdownReason reason = ShutdownReason.MinorOther, ShutdownMod mod = ShutdownMod.None)
|
||||
{
|
||||
if (mode == ShutdownMode.BSoD)
|
||||
{
|
||||
bool t1;
|
||||
uint t2;
|
||||
RtlAdjustPrivilege(19, true, false, out t1);
|
||||
NtRaiseHardError(0xc0000022, 0, 0, IntPtr.Zero, 6, out t2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Privileges.EnablePrivilege(SecurityEntity.SE_SHUTDOWN_NAME);
|
||||
ExitWindowsEx((ExitWindows)((uint)mode | (uint)mod), reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
class ugly_copy_paste_code
|
||||
{
|
||||
/*
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
internal struct TokPriv1Luid
|
||||
{
|
||||
public int Count;
|
||||
public long Luid;
|
||||
public int Attr;
|
||||
}
|
||||
|
||||
[DllImport("kernel32.dll", ExactSpelling = true)]
|
||||
internal static extern IntPtr GetCurrentProcess();
|
||||
|
||||
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
|
||||
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr
|
||||
phtok);
|
||||
|
||||
[DllImport("advapi32.dll", SetLastError = true)]
|
||||
internal static extern bool LookupPrivilegeValue(string host, string name,
|
||||
ref long pluid);
|
||||
|
||||
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
|
||||
internal static extern bool AdjustTokenPrivileges(IntPtr htok, bool disall,
|
||||
ref TokPriv1Luid newst, int len, IntPtr prev, IntPtr relen);
|
||||
|
||||
[DllImport("user32.dll", ExactSpelling = true, SetLastError = true)]
|
||||
internal static extern bool ExitWindowsEx(int flg, int rea);
|
||||
|
||||
[Flags()]
|
||||
public enum ExitWindowsValues
|
||||
{
|
||||
Logoff = 0x00000000,
|
||||
Shutdown = 0x00000001,
|
||||
Reboot = 0x00000002,
|
||||
Force = 0x00000004,
|
||||
Poweroff = 0x00000008,
|
||||
For
|
||||
}
|
||||
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
|
||||
internal const int TOKEN_QUERY = 0x00000008;
|
||||
internal const int TOKEN_ADJUST_PRIVILEGES = 0x00000020;
|
||||
internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege";
|
||||
internal const int EWX_LOGOFF = 0x00000000;
|
||||
internal const int EWX_SHUTDOWN = 0x00000001;
|
||||
internal const int EWX_REBOOT = 0x00000002;
|
||||
internal const int EWX_FORCE = 0x00000004;
|
||||
internal const int EWX_POWEROFF = 0x00000008;
|
||||
internal const int EWX_FORCEIFHUNG = 0x00000010;
|
||||
|
||||
private void DoExitWin(int flg)
|
||||
{
|
||||
TokPriv1Luid tp;
|
||||
IntPtr hproc = GetCurrentProcess();
|
||||
IntPtr htok = IntPtr.Zero;
|
||||
OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok);
|
||||
tp.Count = 1;
|
||||
tp.Luid = 0;
|
||||
tp.Attr = SE_PRIVILEGE_ENABLED;
|
||||
LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid);
|
||||
AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero);
|
||||
ExitWindowsEx(flg, 0);
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -0,0 +1,281 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public class Privileges
|
||||
{
|
||||
public static void EnablePrivilege(SecurityEntity securityEntity)
|
||||
{
|
||||
if (!Enum.IsDefined(typeof(SecurityEntity), securityEntity))
|
||||
throw new InvalidEnumArgumentException("securityEntity", (int)securityEntity, typeof(SecurityEntity));
|
||||
|
||||
var securityEntityValue = GetSecurityEntityValue(securityEntity);
|
||||
try
|
||||
{
|
||||
var locallyUniqueIdentifier = new NativeMethods.LUID();
|
||||
|
||||
if (NativeMethods.LookupPrivilegeValue(null, securityEntityValue, ref locallyUniqueIdentifier))
|
||||
{
|
||||
var TOKEN_PRIVILEGES = new NativeMethods.TOKEN_PRIVILEGES();
|
||||
TOKEN_PRIVILEGES.PrivilegeCount = 1;
|
||||
TOKEN_PRIVILEGES.Attributes = NativeMethods.SE_PRIVILEGE_ENABLED;
|
||||
TOKEN_PRIVILEGES.Luid = locallyUniqueIdentifier;
|
||||
|
||||
var tokenHandle = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
var currentProcess = NativeMethods.GetCurrentProcess();
|
||||
if (NativeMethods.OpenProcessToken(currentProcess, NativeMethods.TOKEN_ADJUST_PRIVILEGES | NativeMethods.TOKEN_QUERY, out tokenHandle))
|
||||
{
|
||||
if (NativeMethods.AdjustTokenPrivileges(tokenHandle, false,
|
||||
ref TOKEN_PRIVILEGES,
|
||||
1024, IntPtr.Zero, IntPtr.Zero))
|
||||
{
|
||||
var lastError = Marshal.GetLastWin32Error();
|
||||
if (lastError == NativeMethods.ERROR_NOT_ALL_ASSIGNED)
|
||||
{
|
||||
var win32Exception = new Win32Exception();
|
||||
throw new InvalidOperationException("AdjustTokenPrivileges failed.", win32Exception);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var win32Exception = new Win32Exception();
|
||||
throw new InvalidOperationException("AdjustTokenPrivileges failed.", win32Exception);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var win32Exception = new Win32Exception();
|
||||
|
||||
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
|
||||
"OpenProcessToken failed. CurrentProcess: {0}",
|
||||
currentProcess.ToInt32());
|
||||
|
||||
throw new InvalidOperationException(exceptionMessage, win32Exception);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (tokenHandle != IntPtr.Zero)
|
||||
NativeMethods.CloseHandle(tokenHandle);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var win32Exception = new Win32Exception();
|
||||
|
||||
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
|
||||
"LookupPrivilegeValue failed. SecurityEntityValue: {0}",
|
||||
securityEntityValue);
|
||||
|
||||
throw new InvalidOperationException(exceptionMessage, win32Exception);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
var exceptionMessage = string.Format(CultureInfo.InvariantCulture,
|
||||
"GrandPrivilege failed. SecurityEntity: {0}",
|
||||
securityEntityValue);
|
||||
|
||||
throw new InvalidOperationException(exceptionMessage, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the security entity value.
|
||||
/// </summary>
|
||||
/// <param name="securityEntity">The security entity.</param>
|
||||
private static string GetSecurityEntityValue(SecurityEntity securityEntity)
|
||||
{
|
||||
switch (securityEntity)
|
||||
{
|
||||
case SecurityEntity.SE_ASSIGNPRIMARYTOKEN_NAME:
|
||||
return "SeAssignPrimaryTokenPrivilege";
|
||||
case SecurityEntity.SE_AUDIT_NAME:
|
||||
return "SeAuditPrivilege";
|
||||
case SecurityEntity.SE_BACKUP_NAME:
|
||||
return "SeBackupPrivilege";
|
||||
case SecurityEntity.SE_CHANGE_NOTIFY_NAME:
|
||||
return "SeChangeNotifyPrivilege";
|
||||
case SecurityEntity.SE_CREATE_GLOBAL_NAME:
|
||||
return "SeCreateGlobalPrivilege";
|
||||
case SecurityEntity.SE_CREATE_PAGEFILE_NAME:
|
||||
return "SeCreatePagefilePrivilege";
|
||||
case SecurityEntity.SE_CREATE_PERMANENT_NAME:
|
||||
return "SeCreatePermanentPrivilege";
|
||||
case SecurityEntity.SE_CREATE_SYMBOLIC_LINK_NAME:
|
||||
return "SeCreateSymbolicLinkPrivilege";
|
||||
case SecurityEntity.SE_CREATE_TOKEN_NAME:
|
||||
return "SeCreateTokenPrivilege";
|
||||
case SecurityEntity.SE_DEBUG_NAME:
|
||||
return "SeDebugPrivilege";
|
||||
case SecurityEntity.SE_ENABLE_DELEGATION_NAME:
|
||||
return "SeEnableDelegationPrivilege";
|
||||
case SecurityEntity.SE_IMPERSONATE_NAME:
|
||||
return "SeImpersonatePrivilege";
|
||||
case SecurityEntity.SE_INC_BASE_PRIORITY_NAME:
|
||||
return "SeIncreaseBasePriorityPrivilege";
|
||||
case SecurityEntity.SE_INCREASE_QUOTA_NAME:
|
||||
return "SeIncreaseQuotaPrivilege";
|
||||
case SecurityEntity.SE_INC_WORKING_SET_NAME:
|
||||
return "SeIncreaseWorkingSetPrivilege";
|
||||
case SecurityEntity.SE_LOAD_DRIVER_NAME:
|
||||
return "SeLoadDriverPrivilege";
|
||||
case SecurityEntity.SE_LOCK_MEMORY_NAME:
|
||||
return "SeLockMemoryPrivilege";
|
||||
case SecurityEntity.SE_MACHINE_ACCOUNT_NAME:
|
||||
return "SeMachineAccountPrivilege";
|
||||
case SecurityEntity.SE_MANAGE_VOLUME_NAME:
|
||||
return "SeManageVolumePrivilege";
|
||||
case SecurityEntity.SE_PROF_SINGLE_PROCESS_NAME:
|
||||
return "SeProfileSingleProcessPrivilege";
|
||||
case SecurityEntity.SE_RELABEL_NAME:
|
||||
return "SeRelabelPrivilege";
|
||||
case SecurityEntity.SE_REMOTE_SHUTDOWN_NAME:
|
||||
return "SeRemoteShutdownPrivilege";
|
||||
case SecurityEntity.SE_RESTORE_NAME:
|
||||
return "SeRestorePrivilege";
|
||||
case SecurityEntity.SE_SECURITY_NAME:
|
||||
return "SeSecurityPrivilege";
|
||||
case SecurityEntity.SE_SHUTDOWN_NAME:
|
||||
return "SeShutdownPrivilege";
|
||||
case SecurityEntity.SE_SYNC_AGENT_NAME:
|
||||
return "SeSyncAgentPrivilege";
|
||||
case SecurityEntity.SE_SYSTEM_ENVIRONMENT_NAME:
|
||||
return "SeSystemEnvironmentPrivilege";
|
||||
case SecurityEntity.SE_SYSTEM_PROFILE_NAME:
|
||||
return "SeSystemProfilePrivilege";
|
||||
case SecurityEntity.SE_SYSTEMTIME_NAME:
|
||||
return "SeSystemtimePrivilege";
|
||||
case SecurityEntity.SE_TAKE_OWNERSHIP_NAME:
|
||||
return "SeTakeOwnershipPrivilege";
|
||||
case SecurityEntity.SE_TCB_NAME:
|
||||
return "SeTcbPrivilege";
|
||||
case SecurityEntity.SE_TIME_ZONE_NAME:
|
||||
return "SeTimeZonePrivilege";
|
||||
case SecurityEntity.SE_TRUSTED_CREDMAN_ACCESS_NAME:
|
||||
return "SeTrustedCredManAccessPrivilege";
|
||||
case SecurityEntity.SE_UNDOCK_NAME:
|
||||
return "SeUndockPrivilege";
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(typeof(SecurityEntity).Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum SecurityEntity
|
||||
{
|
||||
SE_CREATE_TOKEN_NAME,
|
||||
SE_ASSIGNPRIMARYTOKEN_NAME,
|
||||
SE_LOCK_MEMORY_NAME,
|
||||
SE_INCREASE_QUOTA_NAME,
|
||||
SE_UNSOLICITED_INPUT_NAME,
|
||||
SE_MACHINE_ACCOUNT_NAME,
|
||||
SE_TCB_NAME,
|
||||
SE_SECURITY_NAME,
|
||||
SE_TAKE_OWNERSHIP_NAME,
|
||||
SE_LOAD_DRIVER_NAME,
|
||||
SE_SYSTEM_PROFILE_NAME,
|
||||
SE_SYSTEMTIME_NAME,
|
||||
SE_PROF_SINGLE_PROCESS_NAME,
|
||||
SE_INC_BASE_PRIORITY_NAME,
|
||||
SE_CREATE_PAGEFILE_NAME,
|
||||
SE_CREATE_PERMANENT_NAME,
|
||||
SE_BACKUP_NAME,
|
||||
SE_RESTORE_NAME,
|
||||
SE_SHUTDOWN_NAME,
|
||||
SE_DEBUG_NAME,
|
||||
SE_AUDIT_NAME,
|
||||
SE_SYSTEM_ENVIRONMENT_NAME,
|
||||
SE_CHANGE_NOTIFY_NAME,
|
||||
SE_REMOTE_SHUTDOWN_NAME,
|
||||
SE_UNDOCK_NAME,
|
||||
SE_SYNC_AGENT_NAME,
|
||||
SE_ENABLE_DELEGATION_NAME,
|
||||
SE_MANAGE_VOLUME_NAME,
|
||||
SE_IMPERSONATE_NAME,
|
||||
SE_CREATE_GLOBAL_NAME,
|
||||
SE_CREATE_SYMBOLIC_LINK_NAME,
|
||||
SE_INC_WORKING_SET_NAME,
|
||||
SE_RELABEL_NAME,
|
||||
SE_TIME_ZONE_NAME,
|
||||
SE_TRUSTED_CREDMAN_ACCESS_NAME
|
||||
}
|
||||
|
||||
internal static class NativeMethods
|
||||
{
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool LookupPrivilegeValue(string lpsystemname, string lpname, [MarshalAs(UnmanagedType.Struct)] ref LUID lpLuid);
|
||||
|
||||
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool AdjustTokenPrivileges(IntPtr tokenhandle,
|
||||
[MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges,
|
||||
[MarshalAs(UnmanagedType.Struct)]ref TOKEN_PRIVILEGES newstate,
|
||||
uint bufferlength, IntPtr previousState, IntPtr returnlength);
|
||||
|
||||
internal const int SE_PRIVILEGE_ENABLED = 0x00000002;
|
||||
|
||||
internal const int ERROR_NOT_ALL_ASSIGNED = 1300;
|
||||
|
||||
internal const UInt32 STANDARD_RIGHTS_REQUIRED = 0x000F0000;
|
||||
internal const UInt32 STANDARD_RIGHTS_READ = 0x00020000;
|
||||
internal const UInt32 TOKEN_ASSIGN_PRIMARY = 0x0001;
|
||||
internal const UInt32 TOKEN_DUPLICATE = 0x0002;
|
||||
internal const UInt32 TOKEN_IMPERSONATE = 0x0004;
|
||||
internal const UInt32 TOKEN_QUERY = 0x0008;
|
||||
internal const UInt32 TOKEN_QUERY_SOURCE = 0x0010;
|
||||
internal const UInt32 TOKEN_ADJUST_PRIVILEGES = 0x0020;
|
||||
internal const UInt32 TOKEN_ADJUST_GROUPS = 0x0040;
|
||||
internal const UInt32 TOKEN_ADJUST_DEFAULT = 0x0080;
|
||||
internal const UInt32 TOKEN_ADJUST_SESSIONID = 0x0100;
|
||||
internal const UInt32 TOKEN_READ = (STANDARD_RIGHTS_READ | TOKEN_QUERY);
|
||||
internal const UInt32 TOKEN_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED |
|
||||
TOKEN_ASSIGN_PRIMARY |
|
||||
TOKEN_DUPLICATE |
|
||||
TOKEN_IMPERSONATE |
|
||||
TOKEN_QUERY |
|
||||
TOKEN_QUERY_SOURCE |
|
||||
TOKEN_ADJUST_PRIVILEGES |
|
||||
TOKEN_ADJUST_GROUPS |
|
||||
TOKEN_ADJUST_DEFAULT |
|
||||
TOKEN_ADJUST_SESSIONID);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
internal static extern IntPtr GetCurrentProcess();
|
||||
|
||||
[DllImport("Advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern bool OpenProcessToken(IntPtr processHandle,
|
||||
uint desiredAccesss,
|
||||
out IntPtr tokenHandle);
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static extern Boolean CloseHandle(IntPtr hObject);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct LUID
|
||||
{
|
||||
internal Int32 LowPart;
|
||||
internal UInt32 HighPart;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal struct TOKEN_PRIVILEGES
|
||||
{
|
||||
internal Int32 PrivilegeCount;
|
||||
internal LUID Luid;
|
||||
internal Int32 Attributes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
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("CC-Functions.W32")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CC-Functions.W32")]
|
||||
[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("23de4ae0-5075-4ccc-8440-4d131ca0fbba")]
|
||||
|
||||
// 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.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CC_Functions.W32</RootNamespace>
|
||||
<AssemblyName>CC-Functions.W32</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Hooks.cs" />
|
||||
<Compile Include="Power.cs" />
|
||||
<Compile Include="Privileges.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Wnd32.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,136 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public class Wnd32 : IEquatable<Wnd32>
|
||||
{
|
||||
#region Exposed
|
||||
#region CreateInstance
|
||||
Wnd32(IntPtr wndref) => hWnd = wndref;
|
||||
public static Wnd32 fromHandle(IntPtr handle) => new Wnd32(handle);
|
||||
public static Wnd32 fromMetadata(string lpClassName = null, string lpWindowName = null) => fromHandle(FindWindow(lpClassName, lpWindowName));
|
||||
public static Wnd32 fromPoint(Point point) => fromHandle(WindowFromPoint(point.X, point.Y));
|
||||
public static Wnd32 fromForm(Form form) => fromHandle(form.Handle);
|
||||
public static Wnd32 foreground() => fromHandle(GetForegroundWindow());
|
||||
#endregion
|
||||
#region InstanceActions
|
||||
public string title { get {
|
||||
int length = GetWindowTextLength(hWnd);
|
||||
StringBuilder sb = new StringBuilder(length + 1);
|
||||
GetWindowText(hWnd, sb, sb.Capacity);
|
||||
return sb.ToString();
|
||||
} set {
|
||||
SetWindowText(hWnd, value);
|
||||
} }
|
||||
public Rectangle position { get {
|
||||
RECT Rect = new RECT();
|
||||
GetWindowRect(hWnd, ref Rect);
|
||||
return new Rectangle(new Point(Rect.left, Rect.top), new Size(Rect.right - Rect.left, Rect.bottom - Rect.top));
|
||||
} set {
|
||||
RECT Rect = new RECT();
|
||||
GetWindowRect(hWnd, ref Rect);
|
||||
MoveWindow(hWnd, value.X, value.Y, value.Width, value.Height, true);
|
||||
} }
|
||||
public bool isForeground { get {
|
||||
return GetForegroundWindow() == hWnd;
|
||||
} set {
|
||||
if (value)
|
||||
SetForegroundWindow(hWnd);
|
||||
else
|
||||
throw new InvalidOperationException("You can't set a Window not to be in the foreground. Move another one over it!");
|
||||
}
|
||||
}
|
||||
public bool enabled { get {
|
||||
return IsWindowEnabled(hWnd);
|
||||
} set {
|
||||
EnableWindow(hWnd, value);
|
||||
}
|
||||
}
|
||||
public void MakeOverlay() => _ = SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS);
|
||||
public bool Destroy()
|
||||
{
|
||||
if (DestroyWindow(hWnd))
|
||||
return true;
|
||||
else
|
||||
throw new Exception("Failed.");
|
||||
}
|
||||
|
||||
public bool stillExists => IsWindow(hWnd);
|
||||
public override string ToString() => hWnd.ToString() + "; " + title + "; " + position.ToString();
|
||||
public override bool Equals(object obj) => Equals(obj as Wnd32);
|
||||
public bool Equals(Wnd32 other) => other != null && EqualityComparer<IntPtr>.Default.Equals(hWnd, other.hWnd);
|
||||
public override int GetHashCode() => -75345830 + EqualityComparer<IntPtr>.Default.GetHashCode(hWnd);
|
||||
public static bool operator ==(Wnd32 left, Wnd32 right) => EqualityComparer<Wnd32>.Default.Equals(left, right);
|
||||
public static bool operator !=(Wnd32 left, Wnd32 right) => !(left == right);
|
||||
#endregion
|
||||
#endregion
|
||||
#region W32
|
||||
public IntPtr hWnd;
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr GetForegroundWindow();
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern IntPtr WindowFromPoint(int xPoint, int yPoint);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
static extern bool SetWindowText(IntPtr hWnd, string lpString);
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true)]
|
||||
static extern bool MoveWindow(IntPtr hWnd, int X, int Y, int nWidth, int nHeight, bool bRepaint);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool SetForegroundWindow(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool EnableWindow(IntPtr hWnd, bool bEnable);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool IsWindowEnabled(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool DestroyWindow(IntPtr hwnd);
|
||||
|
||||
static readonly IntPtr HWND_TOPMOST = new IntPtr(-1);
|
||||
const UInt32 SWP_NOSIZE = 0x0001;
|
||||
const UInt32 SWP_NOMOVE = 0x0002;
|
||||
const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE;
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, ExactSpelling = true, SetLastError = true)]
|
||||
static extern bool GetWindowRect(IntPtr hWnd, ref RECT rect);
|
||||
|
||||
struct RECT
|
||||
{
|
||||
public int left;
|
||||
public int top;
|
||||
public int right;
|
||||
public int bottom;
|
||||
}
|
||||
|
||||
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
static extern int GetWindowTextLength(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
static extern bool IsWindow(IntPtr hWnd);
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue