sendkeys RRS feed

  • Question

  • i want to use the ENTER key and use the TAB key in other window. please help me
    Saturday, January 18, 2020 9:44 AM

All replies

  • For example, this sends ENTER + TAB to Notepad :

    Process proc = System.Diagnostics.Process.Start(new ProcessStartInfo("notepad"));
    if ((proc.MainWindowTitle != ""))
        SwitchToThisWindow(proc.MainWindowHandle, true);                    

    [DllImport("User32.dll", SetLastError= true)]                           
    public static extern bool SwitchToThisWindow(IntPtr hWnd, bool fAltTab);

    Saturday, January 18, 2020 10:03 AM
  • Hi moosavi061,

    Thank you for posting here.

    Just a reminder:

    The code example of Castorix31 can be run directly in the WinForm application, but if you want to use it in the Console application, please replace SendKeys.Send ("{ENTER} {TAB}"); with SendKeys.SendWait ("{ENTER} { TAB} ");

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 20, 2020 1:49 AM