Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Win+Shift+Left #418

Open
urtaevS opened this issue Jul 3, 2024 · 1 comment
Open

Win+Shift+Left #418

urtaevS opened this issue Jul 3, 2024 · 1 comment

Comments

@urtaevS
Copy link

urtaevS commented Jul 3, 2024

How I can send MultipleKeysCommand
Win+Shift+Left?

@BitWuehler
Copy link

BitWuehler commented Jul 3, 2024

I had the same Problem. The problem is the sendkeys funktion from Windows, that doesn't supports holding the WIN-key. I found a solution in this powershell-script. You just can add this as a powershell ps1 file in hass.agent and it works.

Add-Type @"
using System;
using System.Runtime.InteropServices;

public class Keyboard {
    [DllImport("user32.dll", SetLastError = true)]
    public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);

    public const int KEYEVENTF_EXTENDEDKEY = 0x0001;
    public const int KEYEVENTF_KEYUP = 0x0002;
    public const byte VK_SHIFT = 0x10;
    public const byte VK_LEFT = 0x25;
    public const byte VK_LWIN = 0x5B;

    public static void KeyDown(byte keyCode) {
        keybd_event(keyCode, 0, KEYEVENTF_EXTENDEDKEY, UIntPtr.Zero);
    }

    public static void KeyUp(byte keyCode) {
        keybd_event(keyCode, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, UIntPtr.Zero);
    }
}
"@

[Keyboard]::KeyDown([Keyboard]::VK_LWIN)
[Keyboard]::KeyDown([Keyboard]::VK_SHIFT)
[Keyboard]::KeyDown([Keyboard]::VK_LEFT)
[Keyboard]::KeyUp([Keyboard]::VK_LEFT)
[Keyboard]::KeyUp([Keyboard]::VK_SHIFT)
[Keyboard]::KeyUp([Keyboard]::VK_LWIN)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants