commit e28311ceb8333fa31b40b5fe18a39016667c9d30 Author: flashwave Date: Fri Aug 26 01:53:17 2022 +0200 v1.0.0 - 2020-01-05 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1ff0c42 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4ce6fdd --- /dev/null +++ b/.gitignore @@ -0,0 +1,340 @@ +## 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 + +# 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 + +# 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 +# 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 + +# 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 +*- Backup*.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/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# 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 \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6273e3d --- /dev/null +++ b/LICENSE @@ -0,0 +1,12 @@ +Copyright (c) 2020 flashwave + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..122171e --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +# TopMostFriend + +utility that lets you quickly force any program to be always on top + +should work on any version of windows that supports .net framework 4.0 diff --git a/TopMostFriend.sln b/TopMostFriend.sln new file mode 100644 index 0000000..3ce1ee7 --- /dev/null +++ b/TopMostFriend.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29613.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TopMostFriend", "TopMostFriend\TopMostFriend.csproj", "{C521C5A4-65EC-4154-B8C4-55DD1A6E88E3}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C521C5A4-65EC-4154-B8C4-55DD1A6E88E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C521C5A4-65EC-4154-B8C4-55DD1A6E88E3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C521C5A4-65EC-4154-B8C4-55DD1A6E88E3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C521C5A4-65EC-4154-B8C4-55DD1A6E88E3}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B5C9903C-885C-47EE-AC58-9158C4C00A16} + EndGlobalSection +EndGlobal diff --git a/TopMostFriend/AboutWindow.cs b/TopMostFriend/AboutWindow.cs new file mode 100644 index 0000000..f22c34b --- /dev/null +++ b/TopMostFriend/AboutWindow.cs @@ -0,0 +1,100 @@ +using System.Diagnostics; +using System.Drawing; +using System.Windows.Forms; + +namespace TopMostFriend { + public sealed class AboutWindow : Form { + private const int BUTTON_SPACING = 6; + private const int GENERAL_PADDING = 12; + private const int BUTTON_HEIGHT = 23; + private const int BUTTON_WIDTH = 70; + + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HT_CAPTION = 0x02; + + public static void Display() { + using (AboutWindow about = new AboutWindow()) + about.ShowDialog(); + } + + public AboutWindow() { + Text = $@"About Top Most Friend"; + Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); + BackgroundImage = Properties.Resources.about; + StartPosition = FormStartPosition.CenterScreen; + FormBorderStyle = FormBorderStyle.None; + AutoScaleMode = AutoScaleMode.Dpi; + ClientSize = Properties.Resources.about.Size; + MaximizeBox = MinimizeBox = false; + MaximumSize = MinimumSize = Size; + + int tabIndex = 0; + + Button closeButton = new Button { + Text = @"Close", + Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT), + TabIndex = ++tabIndex, + }; + closeButton.Location = new Point(ClientSize.Width - closeButton.Size.Width - GENERAL_PADDING, ClientSize.Height - closeButton.Size.Height - GENERAL_PADDING); + closeButton.Click += (s, e) => Close(); + Controls.Add(closeButton); + + Button websiteButton = new Button { + Text = @"Website", + Size = new Size(BUTTON_WIDTH, BUTTON_HEIGHT), + TabIndex = ++tabIndex, + }; + websiteButton.Location = new Point(closeButton.Left - websiteButton.Width - BUTTON_SPACING, closeButton.Top); + websiteButton.Click += (s, e) => Process.Start(@"https://flash.moe/topmostfriend"); + Controls.Add(websiteButton); + + Button creditButton = new Button { + Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, + Text = string.Empty, + Size = new Size(300, 15), + TabIndex = ++tabIndex, + Cursor = Cursors.Hand, + FlatStyle = FlatStyle.Flat, + BackColor = Color.Transparent, + }; + creditButton.FlatAppearance.BorderSize = 0; + creditButton.FlatAppearance.MouseOverBackColor = Color.Transparent; + creditButton.FlatAppearance.MouseDownBackColor = Color.Transparent; + creditButton.Location = new Point(ClientSize.Width - creditButton.Size.Width - GENERAL_PADDING, 46); + creditButton.Click += (s, e) => Process.Start(@"https://flash.moe"); + + Button creditButtonfff = new Button { + Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, + Text = string.Empty, + Size = new Size(300, 15), + TabIndex = ++tabIndex, + Cursor = Cursors.Hand, + FlatStyle = FlatStyle.Flat, + BackColor = Color.Transparent, + }; + creditButtonfff.FlatAppearance.BorderSize = 0; + creditButtonfff.FlatAppearance.MouseOverBackColor = Color.Transparent; + creditButtonfff.FlatAppearance.MouseDownBackColor = Color.Transparent; + creditButtonfff.Location = new Point(ClientSize.Width - creditButtonfff.Size.Width - GENERAL_PADDING, 64); + creditButtonfff.Click += (s, e) => Process.Start(@"http://www.famfamfam.com/lab/icons/silk/"); + + Controls.Add(creditButtonfff); + + Controls.Add(new Label { + Text = Application.ProductVersion, + TextAlign = ContentAlignment.MiddleLeft, + AutoSize = true, + Location = new Point(127, 97), + BackColor = Color.Transparent, + ForeColor = Color.White, + }); + } + + protected override void OnMouseDown(MouseEventArgs e) { + base.OnMouseDown(e); + + Program.ReleaseCapture(); + Program.SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0); + } + } +} diff --git a/TopMostFriend/Program.cs b/TopMostFriend/Program.cs new file mode 100644 index 0000000..bf4b8b9 --- /dev/null +++ b/TopMostFriend/Program.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing; +using System.Runtime.InteropServices; +using System.Text; +using System.Windows.Forms; + +namespace TopMostFriend { + public static class Program { + private static NotifyIcon SysIcon; + private static readonly Process OwnProcess = Process.GetCurrentProcess(); + private static int InitialItems = 0; + + [STAThread] + public static void Main() { + if (Environment.OSVersion.Version.Major >= 6) + SetProcessDPIAware(); + + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + + SysIcon = new NotifyIcon { + Visible = true, + Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath), + Text = @"Top Most Application Manager", + }; + SysIcon.MouseDown += SysIcon_MouseDown; + SysIcon.ContextMenuStrip = new ContextMenuStrip(); + SysIcon.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { + new ToolStripSeparator(), + new ToolStripMenuItem(@"&About", Properties.Resources.help, new EventHandler((s, e) => AboutWindow.Display())), + new ToolStripMenuItem(@"&Quit", Properties.Resources.door_in, new EventHandler((s, e) => Application.Exit())), + }); + InitialItems = SysIcon.ContextMenuStrip.Items.Count; + + Application.Run(); + + SysIcon.Dispose(); + } + + private static void RefreshWindowList() { + while (SysIcon.ContextMenuStrip.Items.Count > InitialItems) + SysIcon.ContextMenuStrip.Items.RemoveAt(0); + + IEnumerable windows = GetWindowList(); + + foreach(WindowEntry window in windows) { + string title = GetWindowTextLazy(window.Window); + + // i think it's a fair assumption that any visible window worth a damn has a window title + if (string.IsNullOrEmpty(title)) + continue; + + // skip explorer things with specific titles, there's probably a much better way of doing this check + // and this will also probably only work properly on english windows but Fuck It what do you want from me + if (window.Process.ProcessName == @"explorer" && (title == @"Program Manager" || title == @"Start")) + continue; + + IntPtr flags = GetWindowLongPtr(window.Window, GWL_EXSTYLE); + bool isTopMost = (flags.ToInt32() & WS_EX_TOPMOST) > 0; + + Image icon = GetWindowIcon(window.Window).ToBitmap(); + + SysIcon.ContextMenuStrip.Items.Insert(0, new ToolStripMenuItem( + title, icon, new EventHandler((s, e) => { + SetWindowPos( + window.Window, new IntPtr(isTopMost ? HWND_NOTOPMOST : HWND_TOPMOST), + 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW + ); + + if (!isTopMost) + SwitchToThisWindow(window.Window, false); + })) { + CheckOnClick = true, + Checked = isTopMost, + }); + } + } + + private static Icon GetWindowIcon(IntPtr hWnd) { + IntPtr hIcon = SendMessage(hWnd, WM_GETICON, ICON_SMALL2, 0); + + if(hIcon == IntPtr.Zero) { + hIcon = SendMessage(hWnd, WM_GETICON, ICON_SMALL, 0); + + if(hIcon == IntPtr.Zero) { + hIcon = SendMessage(hWnd, WM_GETICON, ICON_BIG, 0); + + if(hIcon == IntPtr.Zero) { + hIcon = GetClassLongPtr(hWnd, GCL_HICON); + + if (hIcon == IntPtr.Zero) + hIcon = GetClassLongPtr(hWnd, GCL_HICONSM); + } + } + } + + return hIcon == IntPtr.Zero ? null : Icon.FromHandle(hIcon); + } + + private static IEnumerable GetWindowList() { + Process[] procs = Process.GetProcesses(); + + foreach (Process proc in procs) { + if (proc.Id == OwnProcess.Id) + continue; + + IEnumerable hwnds = proc.GetWindowHandles(); + + foreach (IntPtr ptr in hwnds) { + if (!IsWindowVisible(ptr)) + continue; + + yield return new WindowEntry(proc, ptr); + } + } + } + + private class WindowEntry { + public Process Process; + public IntPtr Window; + + public WindowEntry(Process proc, IntPtr win) { + Process = proc; + Window = win; + } + } + + private static void SysIcon_MouseDown(object sender, MouseEventArgs e) { + if (e.Button != MouseButtons.Right) + return; + + RefreshWindowList(); + } + + public static IEnumerable GetWindowHandles(this Process proc) { + IntPtr hwndCurr = IntPtr.Zero; + + do { + hwndCurr = FindWindowEx(IntPtr.Zero, hwndCurr, null, null); + GetWindowThreadProcessId(hwndCurr, out uint procId); + + if(proc.Id == procId) + yield return hwndCurr; + } while (hwndCurr != IntPtr.Zero); + } + + private const int HWND_TOPMOST = -1; + private const int HWND_NOTOPMOST = -2; + private const int SWP_NOSIZE = 0x0001; + private const int SWP_NOMOVE = 0x0002; + private const int SWP_SHOWWINDOW = 0x0040; + private const int GWL_EXSTYLE = -20; + private const int GCL_HICON = -14; + private const int GCL_HICONSM = -34; + private const int WS_EX_TOPMOST = 0x08; + private const int WM_GETICON = 0x7F; + private const int ICON_SMALL = 0; + private const int ICON_BIG = 1; + private const int ICON_SMALL2 = 2; + + [DllImport(@"user32")] + private static extern bool SetProcessDPIAware(); + + [DllImport(@"user32", SetLastError = true)] + private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); + + [DllImport(@"user32", SetLastError = true)] + private static extern uint GetWindowThreadProcessId(IntPtr hWnd, out uint lpdwProcessId); + + private static IntPtr GetWindowLongPtr(IntPtr hWnd, int nIndex) { + if (IntPtr.Size == 8) + return GetWindowLongPtr64(hWnd, nIndex); + return new IntPtr(GetWindowLong32(hWnd, nIndex)); + } + + [DllImport(@"user32", EntryPoint = "GetWindowLong")] + private static extern int GetWindowLong32(IntPtr hWnd, int nIndex); + + [DllImport(@"user32", EntryPoint = "GetWindowLongPtr")] + private static extern IntPtr GetWindowLongPtr64(IntPtr hWnd, int nIndex); + + [DllImport(@"user32")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool IsWindowVisible(IntPtr hWnd); + + [DllImport(@"user32", CharSet = CharSet.Auto, SetLastError = true)] + private static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport(@"user32", SetLastError = true, CharSet = CharSet.Auto)] + private static extern int GetWindowTextLength(IntPtr hWnd); + + private static string GetWindowTextLazy(IntPtr hwnd) { + int length = GetWindowTextLength(hwnd) + 1; + StringBuilder sb = new StringBuilder(length); + GetWindowText(hwnd, sb, length); + return sb.ToString(); + } + + private static IntPtr GetClassLongPtr(IntPtr hWnd, int nIndex) { + if (IntPtr.Size > 4) + return GetClassLongPtr64(hWnd, nIndex); + return new IntPtr(GetClassLongPtr32(hWnd, nIndex)); + } + + [DllImport(@"user32", EntryPoint = "GetClassLong")] + private static extern uint GetClassLongPtr32(IntPtr hWnd, int nIndex); + + [DllImport(@"user32", EntryPoint = "GetClassLongPtr")] + private static extern IntPtr GetClassLongPtr64(IntPtr hWnd, int nIndex); + + [DllImport(@"user32", SetLastError = true)] + private static extern void SwitchToThisWindow(IntPtr hWnd, bool fAltTab); + + [DllImport(@"user32", SetLastError = true)] + private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, int uFlags); + + [DllImport(@"user32", CharSet = CharSet.Auto, SetLastError = false)] + public static extern IntPtr SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport(@"user32")] + public static extern bool ReleaseCapture(); + } +} diff --git a/TopMostFriend/Properties/AssemblyInfo.cs b/TopMostFriend/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f3bf902 --- /dev/null +++ b/TopMostFriend/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +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("TopMostFriend")] +[assembly: AssemblyDescription("Provides a dingus that lets you make anything topmost.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("flashwave")] +[assembly: AssemblyProduct("TopMostFriend.Properties")] +[assembly: AssemblyCopyright("flashwave 2020")] +[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("917fe0c6-3919-4f86-8517-edf4981936b0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/TopMostFriend/Properties/Resources.Designer.cs b/TopMostFriend/Properties/Resources.Designer.cs new file mode 100644 index 0000000..fdf5b9c --- /dev/null +++ b/TopMostFriend/Properties/Resources.Designer.cs @@ -0,0 +1,93 @@ +//------------------------------------------------------------------------------ +// +// 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. +// +//------------------------------------------------------------------------------ + +namespace TopMostFriend.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // 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() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [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("TopMostFriend.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap about { + get { + object obj = ResourceManager.GetObject("about", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap door_in { + get { + object obj = ResourceManager.GetObject("door_in", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap help { + get { + object obj = ResourceManager.GetObject("help", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/TopMostFriend/Properties/Resources.resx b/TopMostFriend/Properties/Resources.resx new file mode 100644 index 0000000..f751c55 --- /dev/null +++ b/TopMostFriend/Properties/Resources.resx @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\about.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\door_in.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\help.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/TopMostFriend/Properties/app.manifest b/TopMostFriend/Properties/app.manifest new file mode 100644 index 0000000..bb4d404 --- /dev/null +++ b/TopMostFriend/Properties/app.manifest @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TopMostFriend/Resources/about.png b/TopMostFriend/Resources/about.png new file mode 100644 index 0000000..3361332 Binary files /dev/null and b/TopMostFriend/Resources/about.png differ diff --git a/TopMostFriend/Resources/door_in.png b/TopMostFriend/Resources/door_in.png new file mode 100644 index 0000000..41676a0 Binary files /dev/null and b/TopMostFriend/Resources/door_in.png differ diff --git a/TopMostFriend/Resources/help.png b/TopMostFriend/Resources/help.png new file mode 100644 index 0000000..5c87017 Binary files /dev/null and b/TopMostFriend/Resources/help.png differ diff --git a/TopMostFriend/TopMostFriend.csproj b/TopMostFriend/TopMostFriend.csproj new file mode 100644 index 0000000..877af07 --- /dev/null +++ b/TopMostFriend/TopMostFriend.csproj @@ -0,0 +1,78 @@ + + + + + Debug + AnyCPU + {C521C5A4-65EC-4154-B8C4-55DD1A6E88E3} + WinExe + TopMostFriend + TopMostFriend + v4.0 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + Properties\app.manifest + + + TopMostFriend.ico + + + + Form + + + + + True + True + Resources.resx + + + + + + + + + + + + + + + + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/TopMostFriend/TopMostFriend.ico b/TopMostFriend/TopMostFriend.ico new file mode 100644 index 0000000..476a32e Binary files /dev/null and b/TopMostFriend/TopMostFriend.ico differ diff --git a/about.psd b/about.psd new file mode 100644 index 0000000..a38db84 Binary files /dev/null and b/about.psd differ