Windows 7 (finally) has built-in zoom feature for the screen. Hold down the "Windows" key and you can then use the "+" key to zoom in and the "-" key to zoom out. As a result I have been trying to simulate this combination. With AutoIt I have tried:
1)
Send("{LWINDOWN}" & "+" & "{LWINUP}")
2)
$x = Chr(43)
Send("{LWINDOWN}" & $x & "{LWINUP}")
3)
Send("#{+}") ;//works but it also sends "+" key
4)
Send("{LWINDOWN}")
Sleep(10)
Send("+",1)
Sleep(10)
Send("{LWINUP}")
None of those 4 steps work...
I actually want to use this functionality on c#. If I manage to do it with autoit I could invoke that script with c# so I don't mind the langauage. I am also simulating keystrokes because I don't know how I will be able to zoom in using c#.
Import the library located at:
http://inputsimulator.codeplex.com/
then do:
WindowsInput.InputSimulator.SimulateKeyDown
(WindowsInput.VirtualKeyCode.LWIN);
WindowsInput.InputSimulator.SimulateKeyPress
(WindowsInput.VirtualKeyCode.OEM_PLUS);
WindowsInput.InputSimulator.SimulateKeyUp
(WindowsInput.VirtualKeyCode.LWIN);
You almost had it right ... the actual syntax is Send("{LWIN DOWN}" & "+" & "{LWIN UP}").
You can do something like this
SendKeys.SendWait("{F1}");
If you want to call it to somewindow you can use
[DllImport("user32.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
and then
Process[] processes = Process.GetProcessesByName("Some.exe");
foreach(Process proc in processes)
{
SetForegroundWindow(proc.MainWindowHandle);
SendKeys.SendWait("{F1}");
}
来源:https://stackoverflow.com/questions/10546069/simulate-windows-key-and-key-to-zoom-in