예제 #1
0
 public void Release(GuildWarsControls key)
 {
     if (HardwareInput || !GameService.GameIntegration.Gw2IsRunning)
     {
         var nInputs = new[]
         {
             new Input
             {
                 type = InputType.KEYBOARD,
                 U    = new InputUnion
                 {
                     ki = new KeybdInput
                     {
                         wScan   = ScanCodeShorts[key],
                         wVk     = VirtualKeyShorts[key],
                         dwFlags = KeyEventF.KEYUP
                     }
                 }
             }
         };
         PInvoke.SendInput((uint)nInputs.Length, nInputs, Input.Size);
     }
     else
     {
         uint         vkCode = (uint)VirtualKeyShorts[key];
         ExtraKeyInfo lParam = new ExtraKeyInfo
         {
             scanCode        = (char)PInvoke.MapVirtualKey(vkCode, MAPVK_VK_TO_VSC),
             repeatCount     = 1,
             prevKeyState    = 1,
             transitionState = 1
         };
         PInvoke.PostMessage(Gw2WndHandle, WM_KEYUP, vkCode, lParam.GetInt());
     }
 }
예제 #2
0
 public void Press(GuildWarsControls key)
 {
     if (HardwareInput || !GameService.GameIntegration.Gw2IsRunning)
     {
         var nInputs = new[]
         {
             new Input
             {
                 type = InputType.KEYBOARD,
                 U    = new InputUnion
                 {
                     ki = new KeybdInput
                     {
                         wScan = ScanCodeShorts[key],
                         wVk   = VirtualKeyShorts[key]
                     }
                 }
             }
         };
         PInvoke.SendInput((uint)nInputs.Length, nInputs, Input.Size);
     }
     else
     {
         uint         vkCode = (uint)VirtualKeyShorts[key];
         ExtraKeyInfo lParam = new ExtraKeyInfo()
         {
             scanCode = (char)PInvoke.MapVirtualKey(vkCode, MAPVK_VK_TO_VSC)
         };
         PInvoke.PostMessage(Gw2WndHandle, WM_KEYDOWN, vkCode, lParam.GetInt());
     }
 }
예제 #3
0
 /// <summary>
 /// Releases a key.
 /// </summary>
 /// <param name="key">Virtual Key Short</param>
 /// <param name="sendToSystem">Set if key message (or a combination of such) cannot be correctly interpreted by the game client.</param>
 public static void Release(VirtualKeyShort key, bool sendToSystem = false)
 {
     if (!GameService.GameIntegration.Gw2IsRunning || sendToSystem)
     {
         var nInputs = new[]
         {
             new Extern.Input
             {
                 type = InputType.KEYBOARD,
                 U    = new InputUnion
                 {
                     ki = new KeybdInput
                     {
                         wScan   = (ScanCodeShort)PInvoke.MapVirtualKey((uint)key, MAPVK_VK_TO_VSC),
                         wVk     = key,
                         dwFlags = KeyEventF.KEYUP
                     }
                 }
             }
         };
         PInvoke.SendInput((uint)nInputs.Length, nInputs, Extern.Input.Size);
     }
     else
     {
         uint         vkCode = (uint)key;
         ExtraKeyInfo lParam = new ExtraKeyInfo
         {
             scanCode        = (char)PInvoke.MapVirtualKey(vkCode, MAPVK_VK_TO_VSC),
             repeatCount     = 1,
             prevKeyState    = 1,
             transitionState = 1
         };
         PInvoke.PostMessage(GameService.GameIntegration.Gw2WindowHandle, WM_KEYUP, vkCode, lParam.GetInt());
     }
 }
예제 #4
0
 /// <summary>
 /// Presses a key.
 /// </summary>
 /// <param name="key">Virtual Key Short</param>
 /// <param name="sendToSystem">Set if key message (or a combination of such) cannot be correctly interpreted by the game client.</param>
 public static void Press(VirtualKeyShort key, bool sendToSystem = false)
 {
     if (!GameService.GameIntegration.Gw2IsRunning || sendToSystem)
     {
         var nInputs = new[]
         {
             new Extern.Input
             {
                 type = InputType.KEYBOARD,
                 U    = new InputUnion
                 {
                     ki = new KeybdInput
                     {
                         wScan = (ScanCodeShort)PInvoke.MapVirtualKey((uint)key, MAPVK_VK_TO_VSC),
                         wVk   = key
                     }
                 }
             }
         };
         PInvoke.SendInput((uint)nInputs.Length, nInputs, Extern.Input.Size);
     }
     else
     {
         uint         vkCode = (uint)key;
         ExtraKeyInfo lParam = new ExtraKeyInfo()
         {
             scanCode = (char)PInvoke.MapVirtualKey(vkCode, MAPVK_VK_TO_VSC)
         };
         PInvoke.PostMessage(GameService.GameIntegration.Gw2WindowHandle, WM_KEYDOWN, vkCode, lParam.GetInt());
     }
 }