Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/AlwaysOnTopper.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2019-03-29 22:33:27 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2019-03-29 22:33:27 +0300
commit1a231cdcb1dd54d50ce482aaf9df74f9c3a535d3 (patch)
tree9843b6de0a7bc9209e6426a359a8231fc49ad161
parent637c426c00e9397eeb4699e4a750450e5d2041bf (diff)
Critical fix for non-Russian windows versions, optimizationv1.2
-rw-r--r--AlwaysOnTopper.csproj27
-rw-r--r--Program.cs45
-rw-r--r--Properties/AssemblyInfo.cs4
-rw-r--r--screenshot.pngbin12846 -> 17116 bytes
4 files changed, 56 insertions, 20 deletions
diff --git a/AlwaysOnTopper.csproj b/AlwaysOnTopper.csproj
index 7da0cac..76438d9 100644
--- a/AlwaysOnTopper.csproj
+++ b/AlwaysOnTopper.csproj
@@ -13,6 +13,21 @@
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
+ <PublishUrl>publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Disk</InstallFrom>
+ <UpdateEnabled>false</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>true</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -56,5 +71,17 @@
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
+ <Visible>False</Visible>
+ <ProductName>Microsoft .NET Framework 4.5.2 %28x86 и x64%29</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5 SP1</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> \ No newline at end of file
diff --git a/Program.cs b/Program.cs
index 42d65da..08736d1 100644
--- a/Program.cs
+++ b/Program.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -12,10 +13,11 @@ namespace AlwaysOnTopper
static class Program
{
const Int32 MenuId = 31337;
- static string MenuItemName = "Always on top";
+ const string DefaultMenuItemName = "Always on top";
const int Interval = 500;
const int OffsetFromBottom = 1;
+ static string MenuItemName;
static Dictionary<string, string> Languages = new Dictionary<string, string>()
{
{"ru", "Поверх всех окон" }
@@ -187,6 +189,7 @@ namespace AlwaysOnTopper
}
const uint EVENT_OBJECT_INVOKED = 0x8013;
+ const uint EVENT_OBJECT_FOCUS = 0x8005;
const uint WINEVENT_OUTOFCONTEXT = 0;
const UInt32 MFT_STRING = 0x00000000;
const UInt32 MFS_CHECKED = 0x00000008;
@@ -272,14 +275,14 @@ namespace AlwaysOnTopper
else if (!windowHandles.ContainsValue(windowHwnd))
{
var hhook = SetWinEventHook(EVENT_OBJECT_INVOKED, EVENT_OBJECT_INVOKED, windowHwnd,
- WinEventProc, 0, 0, WINEVENT_OUTOFCONTEXT);
+ WinEventObjectInvoked, 0, 0, WINEVENT_OUTOFCONTEXT);
if (hhook != IntPtr.Zero)
windowHandles[hhook] = windowHwnd;
}
}
- static void WinEventProc(IntPtr hWinEventHook, uint eventType,
- IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
+ static void WinEventObjectInvoked(IntPtr hWinEventHook, uint eventType,
+ IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
{
if (idChild != MenuId)
return;
@@ -293,6 +296,12 @@ namespace AlwaysOnTopper
UpdateAlwaysOnTopToMenu(windowHwnd); // Update menu
}
+ static void WinEventObjectFocus(IntPtr hWinEventHook, uint eventType,
+ IntPtr hwnd, int idObject, int idChild, uint dwEventThread, uint dwmsEventTime)
+ {
+ UpdateAlwaysOnTopToMenu(GetForegroundWindow());
+ }
+
[STAThread]
static void Main()
{
@@ -303,8 +312,12 @@ namespace AlwaysOnTopper
try
{
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
- Languages.TryGetValue(currentCulture.TwoLetterISOLanguageName, out MenuItemName);
+ if (!Languages.TryGetValue(currentCulture.TwoLetterISOLanguageName, out MenuItemName))
+ MenuItemName = DefaultMenuItemName;
+ SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_FOCUS, IntPtr.Zero,
+ WinEventObjectFocus, 0, 0, WINEVENT_OUTOFCONTEXT);
+
// Dumb form for message queue
var form = new Form();
form.Load += new EventHandler((object o, EventArgs e) =>
@@ -313,21 +326,17 @@ namespace AlwaysOnTopper
form.ShowInTaskbar = false;
});
- var timer = new System.Threading.Timer(new TimerCallback(
- (object state) =>
- {
- try
- {
- form.Invoke(new Action(() =>
- {
- UpdateAlwaysOnTopToMenu(GetForegroundWindow());
- }));
- }
- catch { }
- }),
- null, Interval, Interval);
Application.Run(form);
}
+ catch (Exception ex)
+ {
+ try
+ {
+ MessageBox.Show($"{ex.GetType()}: {ex.Message}{ex.StackTrace}", "AlwaysOnTopper error", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ File.WriteAllText("exception.txt", $"{ex.GetType()}: {ex.Message}{ex.StackTrace}");
+ }
+ catch { }
+ }
finally
{
mutex.ReleaseMutex();
diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs
index 0bd3cad..f4cd083 100644
--- a/Properties/AssemblyInfo.cs
+++ b/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Можно задать все значения или принять номер сборки и номер редакции по умолчанию.
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.0.2.0")]
+[assembly: AssemblyFileVersion("1.0.2.0")]
diff --git a/screenshot.png b/screenshot.png
index d05368d..cd27693 100644
--- a/screenshot.png
+++ b/screenshot.png
Binary files differ