Skip to content

Commit

Permalink
Add setting for keydown duration
Browse files Browse the repository at this point in the history
  • Loading branch information
Stickymaddness committed Apr 21, 2018
1 parent 7e07330 commit db80d5e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Sextant.Host/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"NextUIPanelKey": "]",
"UISelectKey": " ",
"GalaxyMapOpenDelay": "2500",
"GalaxyMapUINavigateDelay": "100"
"GalaxyMapUINavigateDelay": "100",
"KeyDownDuration": 5
},
"Preferences": {
"CommunicateSkippableSystems": "true"
Expand Down
1 change: 1 addition & 0 deletions Sextant.Infrastructure/GalaxyMapInteractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class GalaxyMapInteractor : IGalaxyMap
public GalaxyMapInteractor(GalaxyMapInteractorSettings settings)
{
_settings = settings;
KeystrokeService.SetKeyPressDuration(settings.KeyDownDuration);
}

private void SendKey(string key, int delay)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ public class GalaxyMapInteractorSettings
public string UISelectKey { get; set; }
public int GalaxyMapOpenDelay { get; set; }
public int GalaxyMapUINavigateDelay { get; set; }
public int KeyDownDuration { get; set; }
}
}
10 changes: 7 additions & 3 deletions Sextant.Infrastructure/VirtualKeyboard/KeystrokeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ internal static class KeystrokeService

[DllImport("user32.dll")] static extern short VkKeyScan(char ch);

private static int KeyPressDuration = 5;

internal static void SetKeyPressDuration(int duration) => KeyPressDuration = duration;

internal static void SendKeystrokes(string keys)
{
_inputSimulator.Keyboard.TextEntry(keys);
_inputSimulator.Keyboard.Sleep(10);
_inputSimulator.Keyboard.Sleep(KeyPressDuration);
}

internal static void SendSingleKeyPress(string key)
Expand All @@ -25,14 +29,14 @@ internal static void SendSingleKeyPress(string key)
var keyCode = (VirtualKeyCode)scanCode;

_inputSimulator.Keyboard.KeyDown(keyCode);
_inputSimulator.Keyboard.Sleep(10);
_inputSimulator.Keyboard.Sleep(KeyPressDuration);
_inputSimulator.Keyboard.KeyUp(keyCode);
}

internal static void SendEnter()
{
_inputSimulator.Keyboard.KeyDown(VirtualKeyCode.RETURN);
_inputSimulator.Keyboard.Sleep(10);
_inputSimulator.Keyboard.Sleep(KeyPressDuration);
_inputSimulator.Keyboard.KeyUp(VirtualKeyCode.RETURN);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sextant.VoiceAttack/VoiceAttackPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class VoiceAttackPlugin

public static string VA_DisplayName()
{
return "Sextant v1.0.1";
return "Sextant v1.0.2";
}

public static string VA_DisplayInfo()
Expand Down

0 comments on commit db80d5e

Please sign in to comment.