Search code examples
c#automationautoitkeystroke

Simulate "Windows" key and "+" key to zoom in


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


Solution

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