나는 아주 기본적인 아니라 매우 우아한 솔루션을 선택했습니다,하지만 필요한 작업을 수행합니다 물어 수
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;
}
는 당신이 왜 필요를? 우리는 다른 방법도 생각할 수 있습니다. – Sak
@Sak 일부 원격 뷰어 프로그램은 100 % 이상의 DPI에서는 제대로 작동하지 않습니다. –
질문에 대한 답변은 https://stackoverflow.com/questions/35233182/how-can-i-change-windows-10-display-scaling-programmatically-using-c-sharp – FCin