2023-05-15 23:32:26 +01:00
|
|
|
|
// Copyright (c) Microsoft Corporation
|
|
|
|
|
|
// The Microsoft Corporation licenses this file to you under the MIT license.
|
|
|
|
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
|
|
|
|
|
|
|
|
// <summary>
|
|
|
|
|
|
// Application entry and pre-process/initialization.
|
|
|
|
|
|
// </summary>
|
|
|
|
|
|
// <history>
|
|
|
|
|
|
// 2008 created by Truong Do (ductdo).
|
|
|
|
|
|
// 2009-... modified by Truong Do (TruongDo).
|
|
|
|
|
|
// 2023- Included in PowerToys.
|
|
|
|
|
|
// </history>
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
|
|
using System.Drawing.Printing;
|
|
|
|
|
|
using System.Globalization;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.IO.Pipes;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Security.Authentication.ExtendedProtection;
|
|
|
|
|
|
using System.Security.Principal;
|
|
|
|
|
|
using System.ServiceModel.Channels;
|
|
|
|
|
|
using System.ServiceProcess;
|
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
using System.Xml.Linq;
|
2024-09-16 16:09:43 -04:00
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
using ManagedCommon;
|
|
|
|
|
|
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
|
|
|
|
|
|
using Microsoft.PowerToys.Telemetry;
|
2025-02-21 08:31:44 +00:00
|
|
|
|
using MouseWithoutBorders.Core;
|
2023-05-15 23:32:26 +01:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
using StreamJsonRpc;
|
|
|
|
|
|
|
2024-10-18 17:32:08 +01:00
|
|
|
|
using Logger = MouseWithoutBorders.Core.Logger;
|
2025-03-17 22:05:36 +00:00
|
|
|
|
using SettingsHelper = Microsoft.PowerToys.Settings.UI.Library.Utilities.Helper;
|
2025-01-17 15:41:39 +00:00
|
|
|
|
using Thread = MouseWithoutBorders.Core.Thread;
|
2024-10-18 17:32:08 +01:00
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
[module: SuppressMessage("Microsoft.MSInternal", "CA904:DeclareTypesInMicrosoftOrSystemNamespace", Scope = "namespace", Target = "MouseWithoutBorders", Justification = "Dotnet port with style preservation")]
|
|
|
|
|
|
[module: SuppressMessage("Microsoft.Design", "CA1014:MarkAssembliesWithClsCompliant", Justification = "Dotnet port with style preservation")]
|
|
|
|
|
|
[module: SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", Scope = "member", Target = "MouseWithoutBorders.Program.#Main()", MessageId = "System.String.ToLower", Justification = "Dotnet port with style preservation")]
|
|
|
|
|
|
[module: SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions", Scope = "member", Target = "MouseWithoutBorders.Program.#Main()", Justification = "Dotnet port with style preservation")]
|
|
|
|
|
|
|
|
|
|
|
|
namespace MouseWithoutBorders.Class
|
|
|
|
|
|
{
|
|
|
|
|
|
internal static class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
private static readonly string ServiceName = "PowerToys.MWB.Service";
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly string ServiceModeArg = "UseService";
|
|
|
|
|
|
|
2023-07-11 21:14:47 +01:00
|
|
|
|
public static bool ShowServiceModeErrorTooltip;
|
|
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
[STAThread]
|
|
|
|
|
|
private static void Main()
|
|
|
|
|
|
{
|
|
|
|
|
|
ManagedCommon.Logger.InitializeLogger("\\MouseWithoutBorders\\Logs");
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(Application.ProductName + " Started!");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
2024-10-24 22:04:32 +02:00
|
|
|
|
ETWTrace etwTrace = new ETWTrace();
|
|
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMouseWithoutBordersEnabledValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("Tried to start with a GPO policy setting the utility to always be disabled. Please contact your systems administrator.");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Thread.CurrentThread.Name = Application.ProductName + " main thread";
|
|
|
|
|
|
Common.BinaryName = Path.GetFileNameWithoutExtension(Application.ExecutablePath);
|
|
|
|
|
|
|
|
|
|
|
|
WindowsIdentity currentUser = WindowsIdentity.GetCurrent();
|
|
|
|
|
|
SecurityIdentifier currentUserSID = currentUser.User;
|
|
|
|
|
|
SecurityIdentifier localSystemSID = new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null);
|
|
|
|
|
|
|
|
|
|
|
|
bool runningAsSystem = currentUserSID.Equals(localSystemSID);
|
|
|
|
|
|
Common.RunWithNoAdminRight = !runningAsSystem;
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string[] args = Environment.GetCommandLineArgs();
|
|
|
|
|
|
|
|
|
|
|
|
string firstArg = string.Empty;
|
|
|
|
|
|
if (args.Length > 1 && args[1] != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
firstArg = args[1].Trim();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
User = WindowsIdentity.GetCurrent().Name;
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.LogDebug("*** Started as " + User);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(Environment.CommandLine);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
bool serviceMode = firstArg == ServiceModeArg;
|
|
|
|
|
|
|
2025-02-12 18:49:26 +00:00
|
|
|
|
if (PowerToys.GPOWrapper.GPOWrapper.GetConfiguredMwbAllowServiceModeValue() == PowerToys.GPOWrapper.GpoRuleConfigured.Disabled)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (runningAsSystem)
|
|
|
|
|
|
{
|
|
|
|
|
|
Logger.Log("Can't run as a service. It's not allowed according to GPO policy. Please contact your systems administrator.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
serviceMode = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
// If we're started from the .dll module or from the service process, we should
|
|
|
|
|
|
// assume the service mode.
|
2023-05-31 15:50:48 +01:00
|
|
|
|
if (serviceMode && !runningAsSystem)
|
2023-05-15 23:32:26 +01:00
|
|
|
|
{
|
2023-05-31 15:50:48 +01:00
|
|
|
|
try
|
2023-05-15 23:32:26 +01:00
|
|
|
|
{
|
|
|
|
|
|
var sc = new ServiceController(ServiceName);
|
|
|
|
|
|
sc.Start();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-05-31 15:50:48 +01:00
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("Couldn't start the service. Will try to continue as not a service.");
|
|
|
|
|
|
Logger.Log(ex);
|
2023-07-11 21:14:47 +01:00
|
|
|
|
ShowServiceModeErrorTooltip = true;
|
2023-05-31 15:50:48 +01:00
|
|
|
|
serviceMode = false;
|
|
|
|
|
|
Setting.Values.UseService = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
2023-05-31 15:50:48 +01:00
|
|
|
|
if (serviceMode || runningAsSystem)
|
|
|
|
|
|
{
|
2023-05-15 23:32:26 +01:00
|
|
|
|
if (args.Length > 2)
|
|
|
|
|
|
{
|
2025-03-17 22:05:36 +00:00
|
|
|
|
SettingsHelper.UserLocalAppDataPath = args[2].Trim();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-24 22:04:32 +02:00
|
|
|
|
ShutdownWithPowerToys.WaitForPowerToysRunner(etwTrace);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
if (firstArg != string.Empty)
|
|
|
|
|
|
{
|
2025-02-21 08:31:44 +00:00
|
|
|
|
if (MachineStuff.CheckSecondInstance(Common.RunWithNoAdminRight))
|
2023-05-15 23:32:26 +01:00
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("*** Second instance, exiting...");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
Ready for Review - [Mouse Without Borders] - refactoring "Common" classes (Part 6 of 7) (#43208)
## Summary of the Pull Request
**Part 6** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Encryption.cs```-> ```Core/Encryption.cs```
* ```Common.Package.cs``` -> ```Core/<multiple files>.cs```
* ```Common.ShutdownWithPowerToys.cs``` ->
```Core/ShutdownWithPowerToys.cs```
* ```Common.VK.cs``` -> ```Core/VK.cs```, ```Core/WM.cs```
* ```Common.WinAPI.cs``` -> ```Core/WinAPI.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders - mc" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [ ] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-12-02 02:43:08 +00:00
|
|
|
|
string myDesktop = WinAPI.GetMyDesktop();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
if (firstArg.Equals("winlogon", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
// Executed by service, running on logon desktop
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("*** Running on " + firstArg + " desktop");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
Common.RunOnLogonDesktop = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (args[1].Trim().Equals("default", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("*** Running on " + firstArg + " desktop");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
else if (args[1].Equals(myDesktop, StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("*** Running on " + myDesktop);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
if (myDesktop.Equals("Screen-saver", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
|
{
|
|
|
|
|
|
Common.RunOnScrSaverDesktop = true;
|
|
|
|
|
|
Setting.Values.LastX = Common.JUST_GOT_BACK_FROM_SCREEN_SAVER;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2025-02-21 08:31:44 +00:00
|
|
|
|
if (MachineStuff.CheckSecondInstance(true))
|
2023-05-15 23:32:26 +01:00
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("*** Second instance, exiting...");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PowerToysTelemetry.Log.WriteEvent(new MouseWithoutBorders.Telemetry.MouseWithoutBordersStartedEvent());
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
Common.CurrentProcess = Process.GetCurrentProcess();
|
|
|
|
|
|
Common.CurrentProcess.PriorityClass = ProcessPriorityClass.RealTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(e);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(Environment.OSVersion.ToString());
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
// Environment.OSVersion is unreliable from 6.2 and up, so just forcefully call the APIs and log the exception unsupported by Windows:
|
|
|
|
|
|
int setProcessDpiAwarenessResult = -1;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
setProcessDpiAwarenessResult = NativeMethods.SetProcessDpiAwareness(2);
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(string.Format(CultureInfo.InvariantCulture, "SetProcessDpiAwareness: {0}.", setProcessDpiAwarenessResult));
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
catch (DllNotFoundException)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("SetProcessDpiAwareness is unsupported in Windows 7 and lower.");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
catch (EntryPointNotFoundException)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log("SetProcessDpiAwareness is unsupported in Windows 7 and lower.");
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(e);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
if (setProcessDpiAwarenessResult != 0)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(string.Format(CultureInfo.InvariantCulture, "SetProcessDPIAware: {0}.", NativeMethods.SetProcessDPIAware()));
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(e);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
System.Threading.Thread mainUIThread = Thread.CurrentThread;
|
|
|
|
|
|
Common.UIThreadID = mainUIThread.ManagedThreadId;
|
|
|
|
|
|
Thread.UpdateThreads(mainUIThread);
|
|
|
|
|
|
|
|
|
|
|
|
StartInputCallbackThread();
|
|
|
|
|
|
if (!Common.RunOnLogonDesktop)
|
|
|
|
|
|
{
|
|
|
|
|
|
StartSettingSyncThread();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Application.EnableVisualStyles();
|
|
|
|
|
|
_ = Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
|
|
|
|
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
|
|
|
|
|
[Mouse Without Borders] - refactoring "Common" classes (Part 5 of 7) (#38500)
## Summary of the Pull Request
**Part 5** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Clipboard.cs``` -> ```Clipboard.cs```
* ```Common.InitAndCleanup.cs``` -> ```InitAndCleanup.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp"```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [x] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-09-24 07:55:57 +01:00
|
|
|
|
InitAndCleanup.Init();
|
2025-03-17 22:05:36 +00:00
|
|
|
|
Core.Helper.WndProcCounter++;
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
var formScreen = new FrmScreen();
|
|
|
|
|
|
|
|
|
|
|
|
Application.Run(formScreen);
|
2024-10-24 22:04:32 +02:00
|
|
|
|
|
|
|
|
|
|
etwTrace?.Dispose();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(e);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private interface ISettingsSyncHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
[JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public struct MachineSocketState
|
|
|
|
|
|
{
|
|
|
|
|
|
// Disable false-positive warning due to IPC
|
|
|
|
|
|
#pragma warning disable CS0649
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
|
public string Name;
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty]
|
|
|
|
|
|
public SocketStatus Status;
|
|
|
|
|
|
#pragma warning restore CS0649
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
|
|
|
|
void Reconnect();
|
|
|
|
|
|
|
|
|
|
|
|
void GenerateNewKey();
|
|
|
|
|
|
|
|
|
|
|
|
void ConnectToMachine(string machineName, string securityKey);
|
|
|
|
|
|
|
|
|
|
|
|
Task<MachineSocketState[]> RequestMachineSocketStateAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private sealed class SettingsSyncHelper : ISettingsSyncHelper
|
|
|
|
|
|
{
|
|
|
|
|
|
public Task<ISettingsSyncHelper.MachineSocketState[]> RequestMachineSocketStateAsync()
|
|
|
|
|
|
{
|
|
|
|
|
|
var machineStates = new Dictionary<string, SocketStatus>();
|
|
|
|
|
|
if (Common.Sk == null || Common.Sk.TcpSockets == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Task.FromResult(Array.Empty<ISettingsSyncHelper.MachineSocketState>());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var client in Common.Sk.TcpSockets
|
|
|
|
|
|
.Where(t => t != null && t.IsClient && !string.IsNullOrEmpty(t.MachineName)))
|
|
|
|
|
|
{
|
|
|
|
|
|
var exists = machineStates.TryGetValue(client.MachineName, out var existingStatus);
|
|
|
|
|
|
if (!exists || existingStatus == SocketStatus.NA)
|
|
|
|
|
|
{
|
|
|
|
|
|
machineStates[client.MachineName] = client.Status;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Task.FromResult(machineStates.Select((state) => new ISettingsSyncHelper.MachineSocketState { Name = state.Key, Status = state.Value }).ToArray());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ConnectToMachine(string pcName, string securityKey)
|
|
|
|
|
|
{
|
|
|
|
|
|
Setting.Values.PauseInstantSaving = true;
|
|
|
|
|
|
|
2025-02-21 08:31:44 +00:00
|
|
|
|
MachineStuff.ClearComputerMatrix();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
Setting.Values.MyKey = securityKey;
|
Ready for Review - [Mouse Without Borders] - refactoring "Common" classes (Part 6 of 7) (#43208)
## Summary of the Pull Request
**Part 6** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Encryption.cs```-> ```Core/Encryption.cs```
* ```Common.Package.cs``` -> ```Core/<multiple files>.cs```
* ```Common.ShutdownWithPowerToys.cs``` ->
```Core/ShutdownWithPowerToys.cs```
* ```Common.VK.cs``` -> ```Core/VK.cs```, ```Core/WM.cs```
* ```Common.WinAPI.cs``` -> ```Core/WinAPI.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders - mc" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [ ] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-12-02 02:43:08 +00:00
|
|
|
|
Encryption.MyKey = securityKey;
|
|
|
|
|
|
Encryption.MagicNumber = Encryption.Get24BitHash(Encryption.MyKey);
|
2025-02-21 08:31:44 +00:00
|
|
|
|
MachineStuff.MachineMatrix = new string[MachineStuff.MAX_MACHINE] { pcName.Trim().ToUpper(CultureInfo.CurrentCulture), Common.MachineName.Trim(), string.Empty, string.Empty };
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
2025-02-21 08:31:44 +00:00
|
|
|
|
string[] machines = MachineStuff.MachineMatrix;
|
|
|
|
|
|
MachineStuff.MachinePool.Initialize(machines);
|
|
|
|
|
|
MachineStuff.UpdateMachinePoolStringSetting();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
SocketStuff.InvalidKeyFound = false;
|
[Mouse Without Borders] - refactoring "Common" classes (Part 5 of 7) (#38500)
## Summary of the Pull Request
**Part 5** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Clipboard.cs``` -> ```Clipboard.cs```
* ```Common.InitAndCleanup.cs``` -> ```InitAndCleanup.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp"```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [x] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-09-24 07:55:57 +01:00
|
|
|
|
InitAndCleanup.ReopenSocketDueToReadError = true;
|
2023-05-15 23:32:26 +01:00
|
|
|
|
Common.ReopenSockets(true);
|
2025-02-21 08:31:44 +00:00
|
|
|
|
MachineStuff.SendMachineMatrix();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
Setting.Values.PauseInstantSaving = false;
|
|
|
|
|
|
Setting.Values.SaveSettings();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void GenerateNewKey()
|
|
|
|
|
|
{
|
|
|
|
|
|
Setting.Values.PauseInstantSaving = true;
|
|
|
|
|
|
|
|
|
|
|
|
Setting.Values.EasyMouse = (int)EasyMouseOption.Enable;
|
2025-02-21 08:31:44 +00:00
|
|
|
|
MachineStuff.ClearComputerMatrix();
|
Ready for Review - [Mouse Without Borders] - refactoring "Common" classes (Part 6 of 7) (#43208)
## Summary of the Pull Request
**Part 6** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Encryption.cs```-> ```Core/Encryption.cs```
* ```Common.Package.cs``` -> ```Core/<multiple files>.cs```
* ```Common.ShutdownWithPowerToys.cs``` ->
```Core/ShutdownWithPowerToys.cs```
* ```Common.VK.cs``` -> ```Core/VK.cs```, ```Core/WM.cs```
* ```Common.WinAPI.cs``` -> ```Core/WinAPI.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders - mc" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [ ] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-12-02 02:43:08 +00:00
|
|
|
|
Setting.Values.MyKey = Encryption.MyKey = Encryption.CreateRandomKey();
|
|
|
|
|
|
Encryption.GeneratedKey = true;
|
2023-05-15 23:32:26 +01:00
|
|
|
|
|
|
|
|
|
|
Setting.Values.PauseInstantSaving = false;
|
|
|
|
|
|
Setting.Values.SaveSettings();
|
|
|
|
|
|
|
|
|
|
|
|
Reconnect();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Reconnect()
|
|
|
|
|
|
{
|
|
|
|
|
|
SocketStuff.InvalidKeyFound = false;
|
[Mouse Without Borders] - refactoring "Common" classes (Part 5 of 7) (#38500)
## Summary of the Pull Request
**Part 5** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Clipboard.cs``` -> ```Clipboard.cs```
* ```Common.InitAndCleanup.cs``` -> ```InitAndCleanup.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp"```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [x] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-09-24 07:55:57 +01:00
|
|
|
|
InitAndCleanup.ReopenSocketDueToReadError = true;
|
2023-05-15 23:32:26 +01:00
|
|
|
|
Common.ReopenSockets(true);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Common.AtLeastOneSocketConnected())
|
|
|
|
|
|
{
|
|
|
|
|
|
Common.MMSleep(0.5);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Common.MMSleep(0.2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-21 08:31:44 +00:00
|
|
|
|
MachineStuff.SendMachineMatrix();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Shutdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
Process[] ps = Process.GetProcessesByName("PowerToys.MouseWithoutBorders");
|
|
|
|
|
|
Process me = Process.GetCurrentProcess();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (Process p in ps)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (p.Id != me.Id)
|
|
|
|
|
|
{
|
|
|
|
|
|
p.Kill();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Common.MainForm.Quit(true, false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static void StartSettingSyncThread()
|
|
|
|
|
|
{
|
|
|
|
|
|
var serverTaskCancellationSource = new CancellationTokenSource();
|
|
|
|
|
|
CancellationToken cancellationToken = serverTaskCancellationSource.Token;
|
|
|
|
|
|
|
|
|
|
|
|
IpcChannel<SettingsSyncHelper>.StartIpcServer("MouseWithoutBorders/SettingsSync", cancellationToken);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static void StartInputCallbackThread()
|
|
|
|
|
|
{
|
|
|
|
|
|
Thread inputCallback = new(new ThreadStart(InputCallbackThread), "InputCallback Thread");
|
|
|
|
|
|
inputCallback.SetApartmentState(ApartmentState.STA);
|
|
|
|
|
|
inputCallback.Priority = ThreadPriority.Highest;
|
|
|
|
|
|
inputCallback.Start();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void InputCallbackThread()
|
|
|
|
|
|
{
|
2025-01-23 03:14:49 +09:00
|
|
|
|
// SuppressFlow fixes an issue on service mode, where the helper process can't get enough permissions to be started again.
|
|
|
|
|
|
// More details can be found on: https://github.com/microsoft/PowerToys/pull/36892
|
|
|
|
|
|
using var asyncFlowControl = ExecutionContext.SuppressFlow();
|
|
|
|
|
|
|
2023-05-15 23:32:26 +01:00
|
|
|
|
Common.InputCallbackThreadID = Thread.CurrentThread.ManagedThreadId;
|
[Mouse Without Borders] - refactoring "Common" classes (Part 5 of 7) (#38500)
## Summary of the Pull Request
**Part 5** of a [slow-running 7-part
refactor](https://github.com/microsoft/PowerToys/issues/35155#issuecomment-2583334110)
of the giant "Common" class in Mouse Without Borders into individual
classes with tighter private scope.
In this PR:
* Extract the "Common" code from the following files:
* ```Common.Clipboard.cs``` -> ```Clipboard.cs```
* ```Common.InitAndCleanup.cs``` -> ```InitAndCleanup.cs```
* Update references to the types in the new locations
* Update unit test to verify functionality has only changed in an
expected way
<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist
- [x] Partially addresses #35155
- [x] **Communication:** I've discussed this with core contributors
already. If work hasn't been agreed, this work might be rejected
- [x] **Tests:** Added/updated and all pass
- [x] **Localization:** All end user facing strings can be localized
- no changes in this PR
- [x] **Dev docs:** Added/updated
- no changes in this PR
- [x] **New binaries:** Added on the required places
- no changes in this PR
- [ ] [JSON for
signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json)
for new binaries
- [ ] [WXS for
installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs)
for new binaries and localization folder
- [ ] [YML for CI
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml)
for new test projects
- [ ] [YML for signed
pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml)
- [x] **Documentation updated:** If checked, please file a pull request
on [our docs
repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys)
and link it here: #xxx
- no changes in this PR
<!-- Provide a more detailed description of the PR, other things fixed
or any additional comments/features here -->
## Detailed Description of the Pull Request / Additional comments
<!-- Describe how you validated the behavior. Add automated tests
wherever possible, but list manual validation steps taken as well -->
## Validation Steps Performed
### Run manual tests from [Test Checklist
Template](https://github.com/microsoft/PowerToys/blob/5bc7201ae2b75b53d3a4bc35119c867ecf71c5f6/doc/releases/tests-checklist-template.md#mouse-without-borders):
* Install PowerToys on two PCs in the same local network:
- [x] Verify that PowerToys is properly installed on both PCs.
- [x] Configure Windows Firewall Rules
- ```netsh advfirewall firewall add rule
name="PowerToys.MouseWithoutBorders" dir=in action=allow
program="C:\src\mc\PowerToys\x64\Debug\PowerToys.exe" enable=yes
remoteip=any profile=any protocol=tcp"```
* Setup Connection:
- [x] Open MWB's settings on the first PC and click the "New Key"
button. Verify that a new security key is generated.
- [x] Copy the generated security key and paste it in the corresponding
input field in the settings of MWB on the second PC. Also enter the name
of the first PC in the required field.
- [x] Press "Connect" and verify that the machine layout now includes
two PC tiles, each displaying their respective PC names.
* Verify Connection Status:
- [x] Ensure that the border of the remote PC turns green, indicating a
successful connection.
- [x] Enter an incorrect security key and verify that the border of the
remote PC turns red, indicating a failed connection.
* Test Remote Mouse/Keyboard Control:
- [x] With the PCs connected, test the mouse/keyboard control from one
PC to another. Verify that the mouse/keyboard inputs are correctly
registered on the other PC.
- [ ] Test remote mouse/keyboard control across all four PCs, if
available. Verify that inputs are correctly registered on each connected
PC when the mouse is active there.
- unable to test - only 2 machines available
* Test Remote Control with Elevated Apps:
- note - the main PowerToys.exe must be running as a **non**-admin for
these tests
- [x] Open an elevated app on one of the PCs. Verify that without "Use
Service" enabled, PowerToys does not control the elevated app.
- [x] Enable "Use Service" in MWB's settings (need to run PowerToys.exe
as admin to enable "Use Service", then restart PowerToys.exe as
non-admin). Verify that PowerToys can now control the elevated app
remotely. Verify that MWB processes are running as LocalSystem, while
the MWB helper process is running non-elevated.
- ```get-process -Name "PowerToys.MouseWithoutBorders*" -IncludeUserName
| format-table Id, ProcessName, UserName```
- [x] Process: ```PowerToys.MouseWithoutBorders.exe``` - running as
```SYSTEM```
- [x] Process: ```PowerToys.MouseWithoutBorders.Helper.exe``` - running
as current user
- ```get-service -Name "PowerToys.*" | ft Status, Name, UserName;
get-ciminstance -Class "Win32_Service" -Filter "Name like 'PowerToys%'"
| ft ProcessId, Name```
- [x] Service: ```PowerToys.MWB.Service``` - running as ```Local
System```
- [x] Toggle "Use Service" again, verify that each time you do that, the
MWB processes are restarted.
- [x] Run PowerToys elevated on one of the machines, verify that you can
control elevated apps remotely now on that machine.
* Test Module Enable Status:
- [x] For all combinations of "Use Service"/"Run PowerToys as admin",
try enabling/disabling MWB module and verify that it's indeed being
toggled using task manager.
* Test Disconnection/Reconnection:
- [x] Disconnect one of the PCs from network. Verify that the machine
layout updates to reflect the disconnection.
- [x] Do the same, but now by exiting PowerToys.
- [x] Start PowerToys again, verify that the PCs are reconnected.
* Test Various Local Network Conditions:
- [ ] Test MWB performance under various network conditions (e.g., low
bandwidth, high latency). Verify that the tool maintains a stable
connection and functions correctly.
* Clipboard Sharing:
- [x] Copy some text on one PC and verify that the same text can be
pasted on another PC.
- [x] Use the screenshot key and Win+Shift+S to take a screenshot on one
PC and verify that the screenshot can be pasted on another PC.
- [x] Copy a file in Windows Explorer and verify that the file can be
pasted on another PC. Make sure the file size is below 100MB.
- [x] Try to copy multiple files and directories and verify that it's
not possible (only the first selected file is being copied).
* Drag and Drop:
- [ ] Drag a file from Windows Explorer on one PC, cross the screen
border onto another PC, and release it there. Verify that the file is
copied to the other PC. Make sure the file size is below 100MB.
- [ ] While dragging the file, verify that a corresponding icon is
displayed under the mouse cursor.
- [ ] Without moving the mouse from one PC to the target PC, press
CTRL+ALT+F1/2/3/4 hotkey to switch to the target PC directly and verify
that file sharing/dropping is not working.
* Lock and Unlock with "Use Service" Enabled:
- [x] Enable "Use Service" in MWB's settings.
- [x] Lock a remote PC using Win+L, move the mouse to it remotely, and
try to unlock it. Verify that you can unlock the remote PC.
- [x] Disable "Use Service" in MWB's settings, lock the remote PC, move
the mouse to it remotely, and try to unlock it. Verify that you can't
unlock the remote PC.
* Test Settings:
- [ ] Change the rest of available settings on MWB page and verify that
each setting works as described.
### Group Policy Tests
See https://learn.microsoft.com/en-us/windows/powertoys/grouppolicy
- [ ] Install *.admx / *.adml and check settings behave as expected
- [ ] I'll expand the list of settings here when I get this far :-)
- [ ] HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys
- [x] ConfigureEnabledUtilityMouseWithoutBorders
- [x] ```[missing]``` - "Activation -> Enable Mouse Without Borders"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /f```
- [x] ```0``` - "Activation -> Enable Mouse Without Borders" set to
"off" and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Activation -> Enable Mouse Without Borders" set to "on"
and disabled, with GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
ConfigureEnabledUtilityMouseWithoutBorders /t REG_DWORD /d 1 /f```
- [ ] MwbClipboardSharingEnabled
- [ ] MwbFileTransferEnabled
- [ ] MwbUseOriginalUserInterface
- [ ] MwbDisallowBlockingScreensaver
- [ ] MwbSameSubnetOnly
- [ ] MwbValidateRemoteIp
- [x] MwbDisableUserDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /f```
- [x] ```0``` - "Advanced Settings -> IP address mapping" enabled, with
GPO warning hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 0 /f```
- [x] ```1``` - "Advanced Settings -> IP address mapping" disabled, with
GPO warning visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbDisableUserDefinedIpMappingRules /t REG_DWORD /d 1 /f```
- [x] MwbPolicyDefinedIpMappingRules
- [x] ```[missing]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning and GPO values hidden
- ```reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /f```
- [x] ```[empty value]``` - "Advanced Settings -> IP address mapping"
enabled, with GPO warning hidden and GPO values hidden
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "" /f```
- [x] ```[non-empty value]``` - "Advanced Settings -> IP address
mapping" enabled, with GPO warning visible and GPO values visible
- ```reg add HKEY_LOCAL_MACHINE\SOFTWARE\Policies\PowerToys /v
MwbPolicyDefinedIpMappingRules /t REG_MULTI_SZ /d "aaa 10.0.0.1\0bbb
10.0.0.2" /f```
2025-09-24 07:55:57 +01:00
|
|
|
|
while (!InitAndCleanup.InitDone)
|
2023-05-15 23:32:26 +01:00
|
|
|
|
{
|
|
|
|
|
|
Thread.Sleep(100);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Application.Run(new FrmInputCallback());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static void StartService()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Common.RunWithNoAdminRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Kill all but me
|
|
|
|
|
|
Process me = Process.GetCurrentProcess();
|
|
|
|
|
|
Process[] ps = Process.GetProcessesByName(Common.BinaryName);
|
|
|
|
|
|
foreach (Process pp in ps)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (pp.Id != me.Id)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(string.Format(CultureInfo.InvariantCulture, "Killing process {0}.", pp.Id));
|
2023-05-15 23:32:26 +01:00
|
|
|
|
pp.KillProcess();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
|
{
|
2024-10-18 17:32:08 +01:00
|
|
|
|
Logger.Log(e);
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-03-17 22:05:36 +00:00
|
|
|
|
Service.StartMouseWithoutBordersService();
|
2023-05-15 23:32:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal static string User { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|