diff --git a/Project-Aurora/Project-Aurora/Controls/Control_DeviceItem.xaml.cs b/Project-Aurora/Project-Aurora/Controls/Control_DeviceItem.xaml.cs index 574506adf..485313996 100644 --- a/Project-Aurora/Project-Aurora/Controls/Control_DeviceItem.xaml.cs +++ b/Project-Aurora/Project-Aurora/Controls/Control_DeviceItem.xaml.cs @@ -82,7 +82,8 @@ private void btnToggleEnableDisable_Click(object sender, RoutedEventArgs e) else { Global.Configuration.devices_disabled.Add(Device.Device.GetType()); - Device.Device.Shutdown(); + if(Device.Device.IsInitialized()) + Device.Device.Shutdown(); } UpdateControls(); diff --git a/Project-Aurora/Project-Aurora/Devices/Ducky/DuckyDevice.cs b/Project-Aurora/Project-Aurora/Devices/Ducky/DuckyDevice.cs index 503bf981a..fabd393ae 100644 --- a/Project-Aurora/Project-Aurora/Devices/Ducky/DuckyDevice.cs +++ b/Project-Aurora/Project-Aurora/Devices/Ducky/DuckyDevice.cs @@ -1,4 +1,4 @@ -using Aurora.Settings; +using Aurora.Settings; using System; using System.Collections.Generic; using System.ComponentModel; @@ -87,6 +87,9 @@ public bool Initialize() public void Shutdown() { + if (!isInitialized) + return; + //This one is a little smaller, 81 packets. This tells the keyboard to no longer allow USB HID control of the LEDs. //You can tell both the takeover and release work because the keyboard will flash the same as switching to profile 1. (The same lights when you push FN + 1) foreach (byte[] controlPacket in DuckyRGBMappings.DuckyRelease) @@ -100,8 +103,9 @@ public void Shutdown() break; } } - packetStream.Dispose(); - packetStream.Close(); + + packetStream?.Dispose(); + packetStream?.Close(); isInitialized = false; }