Simulate “Windows” key and “+” key to zoom in

笑着哭i 提交于 2019-12-19 04:05:08

问题


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#.


回答1:


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);



回答2:


You almost had it right ... the actual syntax is Send("{LWIN DOWN}" & "+" & "{LWIN UP}").




回答3:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!