0

I've been messing with task scheduler on a tablet recently (completely new to this), mostly for visual things atm. There is a program I run that I need to restart every time the device changes orientation (portrait to landscape and vice-versa). Is there an event that I could use to do this, and how would I go about doing it?

0

Without getting into proper coding, this can be done with limitations.

You can run the script with task scheduler (but limited to running it once per minute, which would mean if you flipped the machine into tablet mode, then you may have to wait up to a minute for the script to run) OR you can run in a loop in a powershell window in the background.

  1. Run once per minute with powershell. Copy the below script into notepad and save it with a .ps1 file extension. Set task scheduler to run it once per minute.

    $value =(Get-Itemproperty 
    hkcu:SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell).TabletMode
    
    If ($value -ne 0){
    Start-Process -FilePath "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" 
    }
    

**Note in this particular example, I am checking the registry to see if tabletMode value does not equal 1, (Which would mean that it is enabled) and then running chrome.exe if the machine is in tablet mode.

  1. This code includes a sleep timer with a loop that will continue to be run every 5 seconds for more instant gratification on the tablet mode switch. You would still save it as a .ps1 and then just run it from wherever you saved it.

    Do {
    $value =(Get-Itemproperty 
    hkcu:SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell).TabletMode
    If ($value -ne 0){
    Start-Process -FilePath "C:\Program Files 
    (x86)\Google\Chrome\Application\chrome.exe" 
    }
    sleep 5    
    }    
    while ($true)
    

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.