[MWB]Simulate input to gain focus when hiding mouse (#26524)

* [MWB]Simulate input to gain focus when hiding mouse

* Little tooltip fix
This commit is contained in:
Jaime Bernardo
2023-05-31 16:59:15 +01:00
committed by GitHub
parent 0f04180912
commit 88656a9fe0
3 changed files with 8 additions and 3 deletions

View File

@@ -433,6 +433,11 @@ namespace MouseWithoutBorders
Program.DotForm.TopMost = true; Program.DotForm.TopMost = true;
Program.DotForm.Show(); Program.DotForm.Show();
Application.DoEvents(); Application.DoEvents();
// Simulate input to help bring to the foreground, as it doesn't seem to work in every case otherwise.
NativeMethods.INPUT input = new NativeMethods.INPUT { type = (int)NativeMethods.InputType.INPUT_MOUSE, mi = { } };
NativeMethods.INPUT[] inputs = new NativeMethods.INPUT[] { input };
_ = NativeMethods.SendInput(1, inputs, Marshal.SizeOf(typeof(NativeMethods.INPUT)));
m.Result = SetForeGround() ? new IntPtr(1) : IntPtr.Zero; m.Result = SetForeGround() ? new IntPtr(1) : IntPtr.Zero;
break; break;

View File

@@ -405,7 +405,7 @@ namespace MouseWithoutBorders
CallingConvention = CallingConvention.StdCall)] CallingConvention = CallingConvention.StdCall)]
internal static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam); internal static extern int CallNextHookEx(int idHook, int nCode, int wParam, IntPtr lParam);
private enum InputType internal enum InputType
{ {
INPUT_MOUSE = 0, INPUT_MOUSE = 0,
INPUT_KEYBOARD = 1, INPUT_KEYBOARD = 1,

View File

@@ -92,7 +92,7 @@
Content="" Content=""
FontFamily="{StaticResource SymbolThemeFontFamily}"> FontFamily="{StaticResource SymbolThemeFontFamily}">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_CopyMachineName" /> <TextBlock x:Uid="MouseWithoutBorders_CopyMachineName" TextWrapping="Wrap" />
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
</Button> </Button>
</StackPanel> </StackPanel>
@@ -161,7 +161,7 @@
</ItemsControl> </ItemsControl>
<Button HorizontalAlignment="Right" Command="{x:Bind Mode=OneTime, Path=ReconnectCommand}"> <Button HorizontalAlignment="Right" Command="{x:Bind Mode=OneTime, Path=ReconnectCommand}">
<ToolTipService.ToolTip> <ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_ReconnectTooltip" /> <TextBlock x:Uid="MouseWithoutBorders_ReconnectTooltip" TextWrapping="Wrap"/>
</ToolTipService.ToolTip> </ToolTipService.ToolTip>
<TextBlock x:Uid="MouseWithoutBorders_ReconnectButton" /> <TextBlock x:Uid="MouseWithoutBorders_ReconnectButton" />
</Button> </Button>