Giter Site home page Giter Site logo

Comments (3)

digimezzo avatar digimezzo commented on July 29, 2024

More info about detecting tablet mode: http://stackoverflow.com/questions/33041370/know-when-windows-10-are-tablet-mode-windows-10-windows-10-mobile
This info was for UWP apps

This doesn't seem so easy to detect in a WPF project. Moved back to v1.3.

from dopamine-windows.

Riajyuu avatar Riajyuu commented on July 29, 2024
Hey, have you tried to check Registry value:

using System;
using System.Management;
using System.Security.Principal;
using System.Windows.Forms;
using Microsoft.Win32;

public partial class MainForm : Form
{
public MainForm()
{
this.InitializeComponent();
this.UpdateModeFromRegistry();

    var currentUser = WindowsIdentity.GetCurrent();
    if (currentUser != null && currentUser.User != null)
    {
        var wqlEventQuery = new EventQuery(string.Format(@"SELECT * FROM RegistryValueChangeEvent WHERE Hive='HKEY_USERS' AND KeyPath='{0}\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ImmersiveShell' AND ValueName='TabletMode'", currentUser.User.Value));
        var managementEventWatcher = new ManagementEventWatcher(wqlEventQuery);
        managementEventWatcher.EventArrived += this.ManagementEventWatcher_EventArrived;
        managementEventWatcher.Start();
    }
}

private void ManagementEventWatcher_EventArrived(object sender, EventArrivedEventArgs e)
{
    this.UpdateModeFromRegistry();
}

private void UpdateModeFromRegistry()
{
    var tabletMode = (int)Registry.GetValue("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ImmersiveShell", "TabletMode", 0);
    if (tabletMode == 1)
    {
        Console.Write(@"Tablet mode is enabled");
    }
    else
    {
        Console.Write(@"Tablet mode is disabled");
    }
}

}

Oops, still for UWPs........

from dopamine-windows.

digimezzo avatar digimezzo commented on July 29, 2024

The value HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell\TabletMode does change between 0 and 1 whether or not Tablet mode is enabled. So even from a WPF application I should be able o check it.

from dopamine-windows.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.