Skip to content

Commit

Permalink
Correction en utilisant l'appui et la relâche de la touche
Browse files Browse the repository at this point in the history
  • Loading branch information
FLOBOY-France committed Jun 7, 2021
1 parent e6aaeb3 commit b842823
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 16 additions & 5 deletions GamePadToKeyboard/Classes/KeyboardSender.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace GamePadToKeyboard
{
Expand All @@ -14,14 +10,29 @@ public class KeyboardSender

private const int VK_Return = 0x0D; //Constante pour la touche Return

public const ushort WM_KEYDOWN = 0x0100;

public const ushort WM_KEYUP = 0x0101;

[DllImport("user32.dll")]
static extern IntPtr GetActiveWindow();


[DllImport("user32.dll")] //sends a windows message to the specified window
public static extern int SendMessage(IntPtr hWnd, int Msg, uint wParam, int lParam);


public static void SendReturn()
{
keybd_event(VK_Return, 0, 0, 0);
}

public static void SendKey(uint keyCode)
{
keybd_event(keyCode, 0, 0, 0); //Simuler autre touche, liste disponible ici : http://www.kbdedit.com/manual/low_level_vk_list.html
//keybd_event(keyCode, 0, 0, 0); //Simuler autre touche, liste disponible ici : http://www.kbdedit.com/manual/low_level_vk_list.html
SendMessage(GetActiveWindow(), WM_KEYUP, VK_Return, 0);
SendMessage(GetActiveWindow(), WM_KEYDOWN, VK_Return, 0);
SendMessage(GetActiveWindow(), WM_KEYUP, VK_Return, 0);
}

}
Expand Down
8 changes: 2 additions & 6 deletions GamePadToKeyboard/Program.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OpenTK.Input;
using System;
using System.Configuration;
using OpenTK.Input;

namespace GamePadToKeyboard
{
Expand Down

0 comments on commit b842823

Please sign in to comment.