findwindow

Zaug 306 Reputation points
2021-08-17T11:35:38.243+00:00

I have a question with findwindow: I said findwindow a find VALORANT window, but even anywhere it triggers events under findwindow, I want it to run only in VALORANT window
code this :
int hwnd = FindWindow(null, "VALORANT");
SetForegroundWindow(hwnd);
SendKeys.SendWait("+{ENTER}iyi oyunlar...{ENTER}");

Developer technologies Windows Forms
0 comments No comments
{count} votes

Accepted answer
  1. Castorix31 90,521 Reputation points
    2021-08-17T11:49:13.197+00:00

    Are you sure "VALORANT" is the right title ?
    Have you checked if hwnd is not null ?

    A test with Notepad shows it works :

    // Class = "Notepad"
    IntPtr hWnd = FindWindow("Notepad", null);
    if (hWnd != IntPtr.Zero)
    {                    
        SwitchToThisWindow(hWnd, true);
        SendKeys.SendWait("+{ENTER}iyi oyunlar...{ENTER}");                   
    }
    

    with :

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

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.