2017-11-21 14 views
0

Windows 10 설정의 텍스트 크기 슬라이더 값을 100 % (또는 다른 매개 변수화 된 값)로 끌어 오는 프로그램이 필요합니다.다시 시작하지 않고 프로그래밍 방식으로 Windows 10 텍스트 크기 (DPI) 변경

Settings

, 즉 여기에 설명 된 몇 가지 방법이있다 : Change windows dpi setting C#. 그러나 레지스트리 변경을 적용하려면 다시 시작해야합니다. 다시 시작하지 않고 Windows 10 DPI를 변경하는 스크립트를 찾고 있습니다.

큰 링크 된 외부 라이브러리없이 C# 또는 PowerShell에서이를 수행 할 것으로 기대합니다. 그게 가능하니?

+0

는 당신이 왜 필요를? 우리는 다른 방법도 생각할 수 있습니다. – Sak

+0

@Sak 일부 원격 뷰어 프로그램은 100 % 이상의 DPI에서는 제대로 작동하지 않습니다. –

+1

질문에 대한 답변은 https://stackoverflow.com/questions/35233182/how-can-i-change-windows-10-display-scaling-programmatically-using-c-sharp – FCin

답변

0

나는 아주 기본적인 아니라 매우 우아한 솔루션을 선택했습니다,하지만 필요한 작업을 수행합니다 물어 수

using System.Threading; 
using System.Windows.Forms; 

... 

    static void Main(string[] args) 
    { 
     System.Diagnostics.Process.Start("ms-settings:display"); 
     Thread.Sleep(1000); 
     AppActivate("Nastavení"); 

     if (args.Length < 2) //After creators update the form is a bit different 
     { 
      SendKeys.SendWait("^(e)"); //Sets focus to search textbox 
      PressTab(5); //Tabs to DPI 
      SetCU(args); 
      PressTab(1); //When logoff is visible then one tab more 
      SetCU(args); 
     } 
     else //For PCs not having the creators update installed 
     { 
      PressTab(3);     
      SetNonCU(args); 
      PressTab(1); //When logoff link is visible then one tab more 
      SetNonCU(args); 
     } 
     Thread.Sleep(100); 
     SendKeys.SendWait("%{F4}");    
    } 

    private static void PressTab(int count) 
    { 
     for (int i = 0; i < count; i++) 
     { 
      SendKeys.SendWait("{TAB}"); 
      Console.WriteLine("TAB"); 
      Thread.Sleep(100); 
     } 
    } 

    private static void SetNonCU(string[] args) 
    { 
     Console.WriteLine("Set non CU"); 
     SendKeys.SendWait("{LEFT}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{LEFT}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{LEFT}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{LEFT}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{LEFT}"); 
     Thread.Sleep(100); 
     if (args[0].Equals("1")) 
     { 
      SendKeys.SendWait("{RIGHT}"); 
     } 
     else 
     if (args[0].Equals("2")) 
     { 
      SendKeys.SendWait("{RIGHT}"); 
      Thread.Sleep(100); 
      SendKeys.SendWait("{RIGHT}"); 
     } 
     Thread.Sleep(100); 
    } 

    private static void SetCU(string[] args) 
    { 
     Console.WriteLine("Set CU"); 
     SendKeys.SendWait("{UP}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{UP}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{UP}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{UP}"); 
     Thread.Sleep(100); 
     SendKeys.SendWait("{UP}"); 
     Thread.Sleep(100); 
     if (args[0].Equals("1")) 
     { 
      SendKeys.SendWait("{DOWN}"); 
     } 
     else 
     if (args[0].Equals("2")) 
     { 
      SendKeys.SendWait("{DOWN}"); 
      Thread.Sleep(100); 
      SendKeys.SendWait("{DOWN}"); 
     } 
     Thread.Sleep(100); 
    } 

    [DllImportAttribute("User32.dll")] 
    private static extern int SetForegroundWindow(int hWnd); 

    private static bool AppActivate(string titleName) 
    { 
     var success = true; 
     var process = Process.GetProcesses() 
         .Where(p => p.MainWindowTitle.StartsWith(titleName)) 
         .FirstOrDefault(); 
     if (process != null) 
     { 
      SetForegroundWindow(process.MainWindowHandle.ToInt32()); 
     } 
     else 
     { 
      success = false; 
     } 
     return success; 
    }