Simulating Key Press c#

后端 未结 8 1133
青春惊慌失措
青春惊慌失措 2020-11-22 05:48

I want to simulate F5 key press in my c# program, When IE is open I want to be able refresh my website automatically.

8条回答
  •  隐瞒了意图╮
    2020-11-22 05:53

    The easiest way to send (simulate) KeyStrokes to any window is to use the SendKeys.Send method of .NET Framework.

    Checkout this very intuitive MSDN article http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.aspx


    Particularly for your case, if your browser window is in focus, sending F5 would just involve the following line of code:

    SendKeys.Send("{F5}");
    

提交回复
热议问题